09.11.2010, 22:46
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/setteam", false))
{
new tmp[128], tmp2[128], id, teams;
tmp = strtok(cmd, idx);
id = strval(tmp);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xF0F0F0AA, "Player not connected.");
{
tmp2 = strtok(tmp, idx);
teams = strval(tmp2);
if(teams > 7 || 1 < teams) return SendClientMessage(playerid, 0xF0F0F0AA, "Valid teams are from 1 to 7.");
{
team[id] = teams;
SetPlayerTeam(id, teams);
SpawnPlayer(id);
}
}
}
return 0;
}
stock strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}