18.05.2011, 17:22
I messed up a bit sorry try this, i've tested and it works.
pawn Код:
COMMAND:setname(playerid, params[])
{
new
oldname[MAX_PLAYER_NAME], newname[MAX_PLAYER_NAME];
if(sscanf(params, "s[24]s[24]", oldname, newname))
{
SendClientMessage(playerid, -1, "ERROR: Usage /setname [oldname][newname]");
return 1;
}
else
{
new
pCount,
p_zName[MAX_PLAYER_NAME];
for(new i; i != MAX_PLAYERS; i++)//would be better using foreach
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, p_zName, MAX_PLAYER_NAME);
if(!strcmp(oldname, p_zName, true, 4))//case insensitive and only the first four letters of the name are compared.
{
SetPlayerName(i, newname);
pCount++;
break;
}
}
}
if(!pCount)
SendClientMessage(playerid, -1, "ERROR: Player Not Found!");
}
return 1;
}