Okay,there you go:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
new tmp[256],string[128],string2[128],namea[MAX_PLAYER_NAME],namep[MAX_PLAYER_NAME];
if(strcmp(cmdtext,"/makepolice",true) == 0)
{
if(IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid,0xF0182DFF,"USAGE: /makepolice [playerid]");
if(!IsNumeric(tmp)) return SendClientMessage(playerid,0xF0182DFF,"Please enter a numeric player ID.");
if(!IsPlayerConnected(strval(tmp))) return SendClientMessage(playerid,0xF0182DFF,"ERROR: Player is not connected.");
if(gTeam[strval(tmp)] == TEAM_COPS) return SendClientMessage(playerid,0xF0182DFF,"ERROR: Player is already a cop.");
else {
gTeam[strval(tmp)] = TEAM_COPS;
GetPlayerName(strval(tmp),namep,MAX_PLAYER_NAME);
GetPlayerName(playerid,namea,MAX_PLAYER_NAME);
format(string,128,"You have successfuly made %s a cop.",namep);
format(string2,128,"The administrator %s has made you a cop.",namea);
SendClientMessage(playerid,0xFFFDFDFF,string);
SendClientMessage(strval(tmp),0xFFFDFDFF,string2);}
return 1;
}
}
return 0;
}
Of course I haven't defined the team skin,the team color,spawnpoints etc,since I believe you've already made it.
Oh and btw,in order for the command to work,you're gonna need those two in your gamemode/filterscript.
Just put them in the bottom:
First,strtok:
pawn Код:
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;
}
And IsNumeric
pawn Код:
stock IsNumeric(string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
No errors,untested though.