SA-MP Forums Archive
How can i fix this cmd? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How can i fix this cmd? (/showthread.php?tid=94239)



How can i fix this cmd? - Battlaman - 28.08.2009

There is something wrong in this code. If i typ /makeadmin (my own id) 3 then it says 255 is not connected

Can anybody tell me whats wrong?

Quote:

if(strcmp(cmd, "/makeadmin", true) == 0)
{
new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
new giveplayerid;
if (IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD, "USAGE: /makeadmin [playerid] [level]");
return 1;
}
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
new level = strval(tmp);
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));
adminlevel[giveplayerid] = level;
printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
SendClientMessage(giveplayerid, 0x00C2ECFF, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,adminlevel[giveplayerid]);
SendClientMessage(playerid, 0x00C2ECFF, string);
}
else if(giveplayerid == INVALID_PLAYER_ID)
{
format(string, sizeof(string), "%d is not an active player.", giveplayerid);
SendClientMessage(playerid, 0xE60000FF, string);
}
}
else
{
SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!");
}
return 1;
}




Re: How can i fix this cmd? - StrickenKid - 28.08.2009

Flip:
Код:
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
So:

Код:
tmp = strtok(cmdtext, idx);
giveplayerid = ReturnUser(tmp);
you used ReturnUser before you assigned the variable, thus error-ing.


Re: How can i fix this cmd? - Dark_Kostas - 28.08.2009

Quote:
Originally Posted by <__Ǝthan__>
Flip:
Код:
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
So:

Код:
tmp = strtok(cmdtext, idx);
giveplayerid = ReturnUser(tmp);
you used ReturnUser before you assigned the variable, thus error-ing.
The problem is not there. The 2nd tmp = strtok is for what level he want to set the player. And the first one for playerid/name. But code seems to be ok... Try to put your name and not ID.


Re: How can i fix this cmd? - StrickenKid - 28.08.2009

oh sorry, didn't look that close at it.


Re: How can i fix this cmd? - Battlaman - 28.08.2009

It works, thanks!