Quote:
Originally Posted by nikhilgupta345
PHP Code:
public cmd_getak(id){ if( cs_get_user_team( id ) != CS_TEAM_CT ) ColorChat(id, RED,"[Jailbreak]Only Guards Can Use Weapons Cmds")
else give_item(id, "weapon_ak47") }
|
This would allow spectators to use the command.
In addition to using cs_get_user_team() instead of get_use_team(), you should also use the CS_TEAM_ team constants to improve readability. You should also try to call natives as sparingly as possible, here you are checking a players team twice when one call will suffice.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <engine>
#include <colorchat>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
public plugin_init()
{
register_plugin( PLUGIN , VERSION , AUTHOR )
register_clcmd( "say /buyak" , "cmd_getak" )
}
public cmd_getak( id )
{
if ( is_user_alive( id ) )
{
if ( cs_get_user_team( id ) == CS_TEAM_T )
{
ColorChat( id , RED , "[Jailbreak]Only Guards Can Use Weapons Cmds" );
}
else
{
give_item( id , "weapon_ak47" );
}
}
// - Or -
if ( is_user_alive( id ) )
( cs_get_user_team( id ) == CS_TEAM_T ) ? ColorChat( id , RED , "[Jailbreak]Only Guards Can Use Weapons Cmds" ) : give_item( id , "weapon_ak47" );
}
__________________