03.12.2012, 23:53
Hey people! So I have a problem. I made a rank system and everything is good but a command /giverank to give a rank to a player is not good. It gives me no errors/warnings! Here is the code...
And also if you could help me... Do you know maybe why am I or some other player on my server getting spawned in the sea after I killed him/ he killed me <<<<Only sometimes, not every time!!!!
pawn Код:
CMD:giverank(playerid, params[])
{
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new giveplayerid;
new tmp[256];
new idx;
GetPlayerName(playerid, sendername, sizeof(sendername));
new rnk;
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayer,sizeof(giveplayer));
tmp = strtok(params, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid,COLOR_WHITE,"Use: /giverank [ID] [rank 0-10]");
return 1;
}
giveplayerid = strval(tmp);
tmp = strtok(params, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid,COLOR_WHITE,"Use: /giverank [ID] [rank 0-10]");
return 1;
}
if(rnk < 0 || rnk > 10 ) {
SendClientMessage(playerid, COLOR_GREY, "Rank must be between 0 and 10!" );
return 1;
}
if(AccInfo[playerid][LoggedIn] == 1)
{
if(AccInfo[playerid][Level] >= 4)
{
if(IsPlayerConnected(giveplayerid)) {
new name1[30];
new name2[30];
new fs[100];
new fs2[100];
GetPlayerName(playerid, name1, 30);
GetPlayerName(giveplayerid, name2, 30);
if( rnk >= 0 && rnk < 11 ) {
rank[giveplayerid] = rnk;
SetPlayerRankStars(giveplayerid);
format(fs, 100, "You have gave %s Rank %i !", name2, rnk);
SendClientMessage(playerid, COLOR_YELLOW, fs);
format(fs2, 100, "You have recieved Rank %i from Administrator %s !", rnk,name1);
SendClientMessage(giveplayerid, COLOR_GREEN, fs2);
printf("Administrator: %s gave %s rank %i !", name1, name2, rnk);
}else
SendClientMessage(playerid, COLOR_NICERED, "Invalid Rank ! Rank must be between 0 and 10 (including 0 and 10) !");
}
else {
SendClientMessage(playerid, COLOR_GREY,"** That player is Offline!" );
}
}
else {
SendClientMessage(playerid, COLOR_NICERED, "You do not have permission to use this command!");
}
}
else {
SendClientMessage(playerid, COLOR_GREY, "You must be logged in to use this command!");
}
return 1;
}