Raised This Month: $ Target: $400
 0% 

invaild function


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-24-2011 , 11:05   Re: invaild function
Reply With Quote #7

Quote:
Originally Posted by nikhilgupta345 View Post
PHP Code:
public cmd_getak(id){  
    if( 
cs_get_user_teamid ) != CS_TEAM_CT )
        
ColorChat(idRED,"[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_pluginPLUGIN VERSION AUTHOR 
    
register_clcmd"say /buyak" "cmd_getak" 


public 
cmd_getakid )

    if ( 
is_user_aliveid ) )
    {
        if ( 
cs_get_user_teamid ) == CS_TEAM_T )
        {
            
ColorChatid RED "[Jailbreak]Only Guards Can Use Weapons Cmds" );
        }
        else
        {
            
give_itemid "weapon_ak47" ); 
        }
    }
    
    
// - Or -

    
if ( is_user_aliveid ) )
        ( 
cs_get_user_teamid ) == CS_TEAM_T ) ? ColorChatid RED "[Jailbreak]Only Guards Can Use Weapons Cmds" ) : give_itemid "weapon_ak47" );

__________________

Last edited by Bugsy; 04-24-2011 at 11:15.
Bugsy is online now
 



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 20:01.


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