AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Issue with command (https://forums.alliedmods.net/showthread.php?t=128823)

RedRobster 06-05-2010 20:33

Issue with command
 
Hey, so basically what this command is supposed to do is get the kills and wins of the person after the command. .stats <target>

However, whenever I type .stats RedRobster it doesn't show anything. But if I type .stats by itself, it shows my stats. Aswell as whenever anyone else types .stats it shows my stats, not theirs.

PHP Code:

public plugin_init()
{
    
//...Other Cvars, Commands, etc.
    
register_clcmd("say .stats","show_stats",ADMIN_ALL,"<target>"//Registers reg. chat command
    
register_clcmd("say_team .stats","show_stats",ADMIN_ALL"<target>"//Registers team chat command


PHP Code:

public show_stats(id)
{    
    new 
Arg2[24//Where <target> will be stored
    
    
read_argv(2,Arg2,23//Reads <target> and stores as Arg2
        
    
new player cmd_target(id,Arg2,0//Gets ID of command target stored as "player"
    
new playername[25//Where the target name will be stored
            
    
if(!player//If target "player" doesn't exist
    
{
        
client_print_color(id,DontChange,"^3%s ^1could not be found.",Arg2//Target doesn't exist
        
return PLUGIN_HANDLED
    
}
    else
    {
        
get_user_name(player,playername,24//Gets full name of target
    
        
client_print_color(id,DontChange,"^3%s ^1has ^3%i Kills ^1and ^3%i Wins.",playername,PlayerKills[player],PlayerWins[player])
    }
    return 
PLUGIN_HANDLED



fysiks 06-05-2010 22:09

Re: Issue with command
 
You can't do "arguments" with registered chat commands.

RedRobster 06-05-2010 22:54

Re: Issue with command
 
Okay. Thank you fysiks :)

fysiks 06-06-2010 00:09

Re: Issue with command
 
Quote:

Originally Posted by RedRobster (Post 1200958)
Okay. Thank you fysiks :)

I will elaborate on that. You can do arguments if you register only "say" or "say_team" but you will need to filter out everything but the .stats command. There are several examples of how it is done if you search (likely in a chat command request somwhere).


All times are GMT -4. The time now is 05:17.

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