[dcmd] setlevel dosen't work - 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: [dcmd] setlevel dosen't work (
/showthread.php?tid=254933)
[dcmd] setlevel dosen't work -
jonnyboy - 13.05.2011
i need help with this dcmd code D:
it compiles right but it says you need to be admin lvl 10 when i am lvl 10 O.o
if someone can fix this it would be very helpful!
pawn Код:
dcmd_setlevel(playerid, params[])
{
new
id,
lvl;
if (sscanf(params, "uc", id, lvl)) SendClientMessage(playerid, 0xFF0000AA, "USAGE: /setlevel playerid level");
else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
if(lvl >= 10) return SendClientMessage(playerid, 0xFF0000AA, "You must be administrator level 10 to use that command!");
else
{
if(PlayerInfo[playerid][AdminLevel] >= 10) return 0;
PlayerInfo[playerid][AdminLevel] = lvl;
new name[MAX_PLAYER_NAME], string2[44];
GetPlayerName(playerid, name, sizeof(name));
format(string2, sizeof(string2), "You have set player %s to AdminLevel %s",name,lvl);
SendClientMessage(playerid,0xFF0000AA,string2);
}
return 1;
}
Re: [dcmd] setlevel dosen't work -
Seven_of_Nine - 13.05.2011
Because what you type in (/setlevel [id] [for example: 3]), that has been sscanfed into the lvl variable (sscanf(params,"ui",id,lvl)) and after that you check the lvl variable. (lvl >= 10), but it's not 10, it's 3. So that is the problem.
Re: [dcmd] setlevel dosen't work -
Laronic - 13.05.2011
pawn Код:
dcmd_setlevel(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] != 10) return SendClientMessage(playerid, 0xFF0000AA, "You must be administrator level 10 to use that command!");
{
new targetid, level;
if(sscanf(params, "ud", targetid, level)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /setlevel [playerid | name] [level]");
else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
{
new targetname[MAX_PLAYER_NAME], string[44];
GetPlayerName(targetid, targetname, sizeof(targetname));
PlayerInfo[targetid][AdminLevel] = level;
format(string, sizeof(string), "You have set player %s to AdminLevel %s", targetname, level);
SendClientMessage(playerid, 0xFF0000AA, string);
}
}
return 1;
}
Re: [dcmd] setlevel dosen't work -
jonnyboy - 13.05.2011
Quote:
Originally Posted by CyberGhost
pawn Код:
dcmd_setlevel(playerid, params[]) { if(PlayerInfo[playerid][AdminLevel] != 10) return SendClientMessage(playerid, 0xFF0000AA, "You must be administrator level 10 to use that command!"); { new targetid, level; if(sscanf(params, "ud", targetid, level)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /setlevel [playerid | name] [level]"); else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000AA, "Player not found"); { new targetname[MAX_PLAYER_NAME], string[44]; GetPlayerName(targetid, targetname, sizeof(targetname)); PlayerInfo[targetid][AdminLevel] = level; format(string, sizeof(string), "You have set player %s to AdminLevel %s", targetname, level); SendClientMessage(playerid, 0xFF0000AA, string); } } return 1; }
|
thanks! works perfectly!