15.08.2009, 06:11
Sorry for double post, I have a new problem. This is my code:
It compiles fine and all, but when I use the command it always returns rank as 0. If I type /setrank 0 5 it would say "Invalid Rank".
pawn Code:
zcmd(setrank, playerid, params[])
{
new string[128];
new idx;
new tmp[256];
new sendername[MAX_PLAYER_NAME];
new giveplayername[MAX_PLAYER_NAME];
if (AccountInfo[playerid][AdminLevel] >= 3 || IsPlayerAdmin(playerid))
{
tmp = strtok(params, idx);
if(isnull(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /giverank [playername/id] [rank 1-8]");
SendClientMessage(playerid, COLOR_WHITE, "FUNCTION: Will give selected player selective rank.");
return 1;
}
new giveplayerid = ReturnUser(tmp, playerid);
new rank = strval(tmp);
if(giveplayerid != INVALID_PLAYER_ID)
{
if ((rank >= 1) && (rank <= 8))
{
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
GetPlayerName(playerid, sendername, sizeof(sendername));
printf("ADMIN: %s gave %s rank %s.", sendername, giveplayername, RankNames[rank-1]);
format(string, sizeof(string), "Admin %s has set your rank to %s.", sendername, RankNames[rank-1]);
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "ADMIN: Administrator %s has given %s rank %s.", sendername,giveplayername,RankNames[rank-1]);
SendClientMessageToAll(COLOR_LIGHTRED, string);
AccountInfo[giveplayerid][Rank] = rank-1;
format(string, sizeof(string), "You have given %s rank %s.", giveplayername,RankNames[AccountInfo[giveplayerid][Rank]]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
else return SendClientMessage(playerid, COLOR_RED, "Invalid Rank!");
}
}
else SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
return 1;
}