26.03.2012, 11:47
Hi all!
I am trying to make a /setadmin command but whenever I try to do the command on myself, it gives returns with Invalid Player ID automatically. Is this normal? Did I make a mistake in my code?
I'm pretty sure it's a newbie mistake.
Thanks!
BTW:
I am trying to make a /setadmin command but whenever I try to do the command on myself, it gives returns with Invalid Player ID automatically. Is this normal? Did I make a mistake in my code?
pawn Код:
CMD:setadmin(playerid,params[])
{
if (PlayerInfo[playerid][AdminLevel] <= 5)
{
MESSAGE(cred, errorna);
}
if (PlayerInfo[playerid][AdminLevel] >= 6)
{
new id, pname[MAX_PLAYER_NAME], lvl;
GetPlayerName(id, pname, sizeof(pname));
if(sscanf(params, "ud", id, fString, lvl)) return MESSAGE(cred, "USAGE:{FFFFFF} /setadmin [name/id] [level]");
else if(id == INVALID_PLAYER_ID) return MESSAGE(cred, invalid);
else
{
PlayerInfo[id][AdminLevel] = 6;
format(fString2, sizeof(fString2), "Admin level set for %s", id);
MESSAGE(cyellow, fString2);
format(fString3, sizeof(fString3), "Admin level (%d) set by admin", lvl);
SendClientMessage(id, cwhite, fString3);
}
}
return 1;
}
Thanks!
BTW:
pawn Код:
MESSAGE(color, const[]); //I defined this at the top, this is SendClientMessage(playerid