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

Need help with change command syntax


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 09-11-2021 , 08:36   Need help with change command syntax
Reply With Quote #1

Hi men! I made some command to set player's team. (I needed it and I made it) It works cool, but not as I wanted first.
Syntax now: setteam <team: t|ct|spec> [name or #userid] [kill]
Is it possible to make it like this: setteam [name or #userid] <team: t|ct|spec> [kill]
I think it is possible but players can't have names like in teams' tokens, am i right?

PHP Code:
public setteam_command(executor)
{
    new 
team[5]
    
read_argv(1teamcharsmax(team))
    
    if(!
team[0]) console_print(executor"[%s] Usage: setteam <team: t|ct|spec> [name or #userid] [kill]"PLUGIN_NAME)
    else if(
equali(team"t") || equali(team"ct") || equali(team"spec"))
    {
        new 
targetargs_num read_argc() - 1
        
if(args_num 1)
        {
            new 
szPlayer[MAX_NAME_LENGTH]
            
read_argv(2szPlayercharsmax(szPlayer))
            
            
target cmd_target(executorszPlayerCMDTARGET_ALLOW_SELF)
            
            if(!
target// player is NOT found
            
{
                
console_print(executor"[%s] Error: wrong argument 2 (Player ^"%s^" not found)"PLUGIN_NAMEszPlayer)
                return 
PLUGIN_HANDLED
            
}
            
            new 
kill[5]
            
read_argv(3killcharsmax(kill))
            if(
kill[0])
            {
                if(
equali(kill"kill"))
                    
_kill(target)
                else {
                    
console_print(executor"[%s] Error: wrong argument 3 (%s)"PLUGIN_NAMEkill)
                    return 
PLUGIN_HANDLED
                
}
            }
        }
        else 
target executor
        
        
switch(team[0])
        {
            case 
't'cs_set_user_team(targetCS_TEAM_T)
            case 
'c'cs_set_user_team(targetCS_TEAM_CT)
            case 
's'cs_set_user_team(targetCS_TEAM_SPECTATOR)
        }
    }
    else 
client_print(executorprint_console"[%s] Error: wrong argument 1 (%s)"PLUGIN_NAMEteam)
    
    return 
PLUGIN_HANDLED

__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951

Last edited by kww; 09-11-2021 at 08:39.
kww is offline
 



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 16:57.


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