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(1, team, charsmax(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 target, args_num = read_argc() - 1
if(args_num > 1)
{
new szPlayer[MAX_NAME_LENGTH]
read_argv(2, szPlayer, charsmax(szPlayer))
target = cmd_target(executor, szPlayer, CMDTARGET_ALLOW_SELF)
if(!target) // player is NOT found
{
console_print(executor, "[%s] Error: wrong argument 2 (Player ^"%s^" not found)", PLUGIN_NAME, szPlayer)
return PLUGIN_HANDLED
}
new kill[5]
read_argv(3, kill, charsmax(kill))
if(kill[0])
{
if(equali(kill, "kill"))
_kill(target)
else {
console_print(executor, "[%s] Error: wrong argument 3 (%s)", PLUGIN_NAME, kill)
return PLUGIN_HANDLED
}
}
}
else target = executor
switch(team[0])
{
case 't': cs_set_user_team(target, CS_TEAM_T)
case 'c': cs_set_user_team(target, CS_TEAM_CT)
case 's': cs_set_user_team(target, CS_TEAM_SPECTATOR)
}
}
else client_print(executor, print_console, "[%s] Error: wrong argument 1 (%s)", PLUGIN_NAME, team)
return PLUGIN_HANDLED
}
__________________