Raised This Month: $51 Target: $400
 12% 

How to allow to use the command !afk only to terrorists.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bad Cold Man
Senior Member
Join Date: Apr 2014
Old 11-18-2015 , 07:44   How to allow to use the command !afk only to terrorists.
Reply With Quote #1

Hello.

How to allow to use the command !afk only to terrorists. This is required for zombie mod


PHP Code:
//////////////////////////////////////////////////////////////////
// Spectator Switch By HSFighter / www.hsfighter.net
//////////////////////////////////////////////////////////////////

#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#define PLUGIN_VERSION "1.1.1"

#undef REQUIRE_PLUGIN
#include <updater>

/* Updater */
#define UPDATE_URL    "http://update.hsfighter.net/sourcemod/spectatorswitch/spectatorswitch.txt"

//////////////////////////////////////////////////////////////////
// Declaring variables and handles
//////////////////////////////////////////////////////////////////

new Handle:SpecMoveEnabled;

//////////////////////////////////////////////////////////////////
// Plugin Info
//////////////////////////////////////////////////////////////////

public Plugin:myinfo =
{
    
name "Spectator Switch",
    
author "HSFighter",
    
description "Allows player to move himself to spectator",
    
version PLUGIN_VERSION,
    
url "http://www.hsfighter.net"
};

//////////////////////////////////////////////////////////////////
// Plugin Start
//////////////////////////////////////////////////////////////////

public OnPluginStart()
{
    
// Register Cvars
    
CreateConVar("sm_spec_version"PLUGIN_VERSION"Spectator Switch Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);        
    
SpecMoveEnabled  CreateConVar("sm_spec_enable""1""Enable/Disable Spectator Switch"FCVAR_PLUGINtrue0.0true1.0);
    
    
// Register Admin Commands
    
RegAdminCmd("sm_spec"Command_MoveADMFLAG_KICK"sm_spec <#userid|name>");    
    
    
// Register Console Commands
    
RegConsoleCmd("sm_afk"Move"Move you self to spectator"FCVAR_PLUGIN);
    
    
// Updater
    
if(LibraryExists("updater"))
    {
        
Updater_AddPlugin(UPDATE_URL);
    }
}

//////////////////////////////////////////////////////////////////
// Library Checks
//////////////////////////////////////////////////////////////////

public OnLibraryAdded(const String:name[])
{
    if (
StrEqual(name"updater"))
    {
        
Updater_AddPlugin(UPDATE_URL);
    }
}

//////////////////////////////////////////////////////////////////
// Action: Move Command from Amdin
//////////////////////////////////////////////////////////////////

public Action:Command_Move(clientargs)
{
    
// Check if plugin is disbaled
    
if(GetConVarInt(SpecMoveEnabled) != 1)
    {  
        return 
Plugin_Handled;
    }
    
    if (!
CheckClient(client)) return Plugin_Continue;
    
    
//Return usage if no arguments
    
if (args 1)
    {
        
ReplyToCommand(client"sm_spec <#userid|name>");
        return 
Plugin_Handled;
    }
    
    
//Validate the target
    
decl String:arg1[65];
    
GetCmdArg(1arg1sizeof(arg1));

    new 
target FindTarget(clientarg1);
    if (
target == -1)
    {
        return 
Plugin_Handled;
    }

    if (
GetClientTeam(client) != 1)
    {
        
PrintToChatAll("\x01[Spectator Switch] \x03%N\x04 was moved to spectator by:  \x03%N"targetclient);
        
Move(target0);
    }
    return 
Plugin_Handled;    
}

//////////////////////////////////////////////////////////////////
// Action: Move client
//////////////////////////////////////////////////////////////////

public Action:Move(targetargs){

    if (!
CheckClient(target)) return Plugin_Handled;

    
//move the player to the spectator
    
if (GetClientTeam(target) != 1)
    {
        
ChangeClientTeam(target1);
        
ForcePlayerSuicide(target);
    }
    return 
Plugin_Handled;
}

//////////////////////////////////////////////////////////////////
// Action: Playercheck
//////////////////////////////////////////////////////////////////

public bool:CheckClient(client)
{
    if ( !( 
<= client <= MaxClients ) || !IsClientInGame(client) || IsFakeClient(client) )
    {
        return 
false;
    }
    return 
true;

__________________
Bad Cold Man is offline
nhnkl159
Senior Member
Join Date: Jul 2012
Location: Israel 3>
Old 11-18-2015 , 07:49   Re: How to allow to use the command !afk only to terrorists.
Reply With Quote #2

Code:
////////////////////////////////////////////////////////////////// 
// Spectator Switch By HSFighter / www.hsfighter.net 
////////////////////////////////////////////////////////////////// 

#include <sourcemod> 
#include <sdktools> 
#pragma semicolon 1 
#define PLUGIN_VERSION "1.1.1" 

#undef REQUIRE_PLUGIN 
#include <updater> 

/* Updater */ 
#define UPDATE_URL    "http://update.hsfighter.net/sourcemod/spectatorswitch/spectatorswitch.txt" 

////////////////////////////////////////////////////////////////// 
// Declaring variables and handles 
////////////////////////////////////////////////////////////////// 

new Handle:SpecMoveEnabled; 

////////////////////////////////////////////////////////////////// 
// Plugin Info 
////////////////////////////////////////////////////////////////// 

public Plugin:myinfo = 
{ 
    name = "Spectator Switch", 
    author = "HSFighter", 
    description = "Allows player to move himself to spectator", 
    version = PLUGIN_VERSION, 
    url = "http://www.hsfighter.net" 
}; 

////////////////////////////////////////////////////////////////// 
// Plugin Start 
////////////////////////////////////////////////////////////////// 

public OnPluginStart() 
{ 
    // Register Cvars 
    CreateConVar("sm_spec_version", PLUGIN_VERSION, "Spectator Switch Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);         
    SpecMoveEnabled  = CreateConVar("sm_spec_enable", "1", "Enable/Disable Spectator Switch", FCVAR_PLUGIN, true, 0.0, true, 1.0); 
     
    // Register Admin Commands 
    RegAdminCmd("sm_spec", Command_Move, ADMFLAG_KICK, "sm_spec <#userid|name>");     
     
    // Register Console Commands 
    RegConsoleCmd("sm_afk", Move, "Move you self to spectator", FCVAR_PLUGIN); 
     
    // Updater 
    if(LibraryExists("updater")) 
    { 
        Updater_AddPlugin(UPDATE_URL); 
    } 
} 

////////////////////////////////////////////////////////////////// 
// Library Checks 
////////////////////////////////////////////////////////////////// 

public OnLibraryAdded(const String:name[]) 
{ 
    if (StrEqual(name, "updater")) 
    { 
        Updater_AddPlugin(UPDATE_URL); 
    } 
} 

////////////////////////////////////////////////////////////////// 
// Action: Move Command from Amdin 
////////////////////////////////////////////////////////////////// 

public Action:Command_Move(client, args) 
{ 
    // Check if plugin is disbaled 
    if(GetConVarInt(SpecMoveEnabled) != 1) 
    {   
        return Plugin_Handled; 
    } 
     
    if (!CheckClient(client)) return Plugin_Continue; 
     
    //Return usage if no arguments 
    if (args < 1) 
    { 
        ReplyToCommand(client, "sm_spec <#userid|name>"); 
        return Plugin_Handled; 
    } 
     
    //Validate the target 
    decl String:arg1[65]; 
    GetCmdArg(1, arg1, sizeof(arg1)); 

    new target = FindTarget(client, arg1); 
    if (target == -1) 
    { 
        return Plugin_Handled; 
    } 

    if (GetClientTeam(client) != 1) 
    { 
        PrintToChatAll("\x01[Spectator Switch] \x03%N\x04 was moved to spectator by:  \x03%N", target, client); 
        Move(target, 0); 
    } 
    return Plugin_Handled;     
} 

////////////////////////////////////////////////////////////////// 
// Action: Move client 
////////////////////////////////////////////////////////////////// 

public Action:Move(target, args){ 

    if (!CheckClient(target)) return Plugin_Handled; 
    
    //if player is terrorist
    if(GetClientTeam(client) != 2)
    {
    	PrintToChat(client, "[SM] You must be a terrorist to use this command.");
    	return Plugin_Handled;
    }
    //move the player to the spectator 
    if (GetClientTeam(target) != 1) 
    { 
        ChangeClientTeam(target, 1); 
        ForcePlayerSuicide(target); 
    } 
    return Plugin_Handled; 
} 

////////////////////////////////////////////////////////////////// 
// Action: Playercheck 
////////////////////////////////////////////////////////////////// 

public bool:CheckClient(client) 
{ 
    if ( !( 1 <= client <= MaxClients ) || !IsClientInGame(client) || IsFakeClient(client) ) 
    { 
        return false; 
    } 
    return true; 
}
__________________
nhnkl159 is offline
Send a message via Skype™ to nhnkl159
Bad Cold Man
Senior Member
Join Date: Apr 2014
Old 11-18-2015 , 09:09   Re: How to allow to use the command !afk only to terrorists.
Reply With Quote #3

Thank you very much, but I got this:

//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// spectatorswitch_t.sp
//
// D:\servercsgo_unlimited\csgo\addons\sourcemod \scripting\spectatorswitch_t.sp(
11 : error 017: undefined symbol "client"
// D:\servercsgo_unlimited\csgo\addons\sourcemod \scripting\spectatorswitch_t.sp(
120) : error 017: undefined symbol "client"
//
// 2 Errors.
//
// Compilation Time: 0,36 sec
// ----------------------------------------

Press enter to exit ...
__________________
Bad Cold Man is offline
Blowst
Senior Member
Join Date: Feb 2011
Location: Korea, Republic of
Old 11-18-2015 , 09:30   Re: How to allow to use the command !afk only to terrorists.
Reply With Quote #4

Quote:
Originally Posted by Bad Cold Man View Post
Thank you very much, but I got this:

//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// spectatorswitch_t.sp
//
// D:\servercsgo_unlimited\csgo\addons\sourcemod \scripting\spectatorswitch_t.sp(
11 : error 017: undefined symbol "client"
// D:\servercsgo_unlimited\csgo\addons\sourcemod \scripting\spectatorswitch_t.sp(
120) : error 017: undefined symbol "client"
//
// 2 Errors.
//
// Compilation Time: 0,36 sec
// ----------------------------------------

Press enter to exit ...
PHP Code:
////////////////////////////////////////////////////////////////// 
// Action: Move client 
////////////////////////////////////////////////////////////////// 

public Action:Move(targetargs){ 

    if (!
CheckClient(target)) return Plugin_Handled
    
    
//if player is terrorist
    
if(GetClientTeam(target) != 2)
    {
        
PrintToChat(target"[SM] You must be a terrorist to use this command.");
        return 
Plugin_Handled;
    }
    
//move the player to the spectator 
    
if (GetClientTeam(target) != 1
    { 
        
ChangeClientTeam(target1); 
        
ForcePlayerSuicide(target); 
    } 
    return 
Plugin_Handled

__________________
Sorry about my poor English


Last edited by Blowst; 11-18-2015 at 09:30.
Blowst is offline
Bad Cold Man
Senior Member
Join Date: Apr 2014
Old 11-18-2015 , 09:55   Re: How to allow to use the command !afk only to terrorists.
Reply With Quote #5

I did it. Thank you all!
__________________
Bad Cold Man is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode