Help with setlevel (admin)
#1

Hello, this is my Script!

Код:
CMD:setlevel(playerid, params[])
{
	new level, id;
	if(sscanf(params, "ud", id, level)) return SendClientMessage(playerid, RED, "[USAGE]: /setlevel [name/id] [level]");
	if(!IsPlayerConnected(id) ) return SendClientMessage(playerid, RED, "Player not found.");
    if(IsLoggedIn{id} == 0) return SendClientMessage(playerid, RED, "Player not logged in.");
    if(IsPlayerAdmin(playerid))
	{
	    PlayerInfo[id][aLevel] = level;
	    PlayerPlaySound(id,1085,0.0,0.0,0.0);
	    format(fstr, sizeof(fstr), "You have set %s [%d] admin level to %d.", GetName(id), id, level);
	    SendClientMessage(playerid, YELLOW, fstr);
	    format(fstr, sizeof(fstr), "Admin %s [%d] has set your admin level to %d.", GetName(playerid), playerid, level);
	    SendClientMessage(id, LIGHTGREEN, fstr);
	    SaveUserStats(id);
    }
	else if(PlayerInfo[playerid][aLevel] == 4)
	{
	    PlayerInfo[id][aLevel] = level;
	    PlayerPlaySound(id,1085,0.0,0.0,0.0);
	    format(fstr, sizeof(fstr), "You have set %s [%d] admin level to %d.", GetName(id), id, level);
	    SendClientMessage(playerid, YELLOW, fstr);
	    format(fstr, sizeof(fstr), "Admin %s [%d] has set your admin level to %d.", GetName(playerid), playerid, level);
	    SendClientMessage(id, LIGHTGREEN, fstr);
	    SaveUserStats(id);
    }
    else
    {
        SendClientMessage(playerid, RED, "Only admin level 4 can use this command.");
    }
	return true;
}
My problem is that, if I make /setlevel (my id) (level) as Rcon Admin it says: Player not found
please help me, thx
Reply
#2

There was a bug with "u" specifier but was fixed by Emmet_: https://sampforum.blast.hk/showthread.php?tid=570927
Another alternative is to use "r" specifier.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
There was a bug with "u" specifier but was fixed by Emmet_: https://sampforum.blast.hk/showthread.php?tid=570927
Another alternative is to use "r" specifier.
Can you may explain better what I should correct, cause im a scripting noob
Reply
#4

"u" specifier is for players and NPCs while "r" specifier is for players only.
pawn Код:
if(sscanf(params, "rd", id, level)) ...
Reply
#5

////
Reply
#6

It still says, Player not logged in
please help!!!!
Reply
#7

Quote:
Originally Posted by Charalambos26
Посмотреть сообщение
My problem is that, if I make /setlevel (my id) (level) as Rcon Admin it says: Player not found
Quote:
Originally Posted by Charalambos26
Посмотреть сообщение
It still says, Player not logged in
It says different error message so the player was found.

pawn Код:
if(IsLoggedIn{id} == 0) return SendClientMessage(playerid, RED, "Player not logged in.");
Do you use char-array for IsLoggedIn? If not, it should be [id] instead.
Also do you set it to 1 when the player logs in successfully?
Reply
#8

Код:
CMD:setlevel(playerid, params[])
{
	new level, id;
	if(sscanf(params, "rd", id, level)) return SendClientMessage(playerid, RED, "[USAGE]: /setlevel [name/id] [level]");
	if(!IsPlayerConnected(id) ) return SendClientMessage(playerid, RED, "Player not found.");
    if(IsLoggedIn{id} == 0) return SendClientMessage(playerid, RED, "Player not logged in.");
    if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][aLevel] == 4)
	{
	    PlayerInfo[id][aLevel] = level;
	    PlayerPlaySound(id,1085,0.0,0.0,0.0);
	    format(fstr, sizeof(fstr), "You have set %s [%d] admin level to %d.", GetName(id), id, level);
	    SendClientMessage(playerid, YELLOW, fstr);
	    format(fstr, sizeof(fstr), "Admin %s [%d] has set your admin level to %d.", GetName(playerid), playerid, level);
	    SendClientMessage(id, LIGHTGREEN, fstr);
	    SaveUserStats(id);
    }
    else
    {
        SendClientMessage(playerid, RED, "Only admin level 4 can use this command.");
    }
	return true;
}
you use if(IsLoggedIn{id} == 0) '{}' what is this? enum?
Reply
#9

Quote:
Originally Posted by FplayerGR
Посмотреть сообщение
Код:
CMD:setlevel(playerid, params[])
{
	new level, id;
	if(sscanf(params, "rd", id, level)) return SendClientMessage(playerid, RED, "[USAGE]: /setlevel [name/id] [level]");
	if(!IsPlayerConnected(id) ) return SendClientMessage(playerid, RED, "Player not found.");
    if(IsLoggedIn{id} == 0) return SendClientMessage(playerid, RED, "Player not logged in.");
    if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][aLevel] == 4)
	{
	    PlayerInfo[id][aLevel] = level;
	    PlayerPlaySound(id,1085,0.0,0.0,0.0);
	    format(fstr, sizeof(fstr), "You have set %s [%d] admin level to %d.", GetName(id), id, level);
	    SendClientMessage(playerid, YELLOW, fstr);
	    format(fstr, sizeof(fstr), "Admin %s [%d] has set your admin level to %d.", GetName(playerid), playerid, level);
	    SendClientMessage(id, LIGHTGREEN, fstr);
	    SaveUserStats(id);
    }
    else
    {
        SendClientMessage(playerid, RED, "Only admin level 4 can use this command.");
    }
	return true;
}
you use if(IsLoggedIn{id} == 0) '{}' what is this? enum?
Still not workin :/
Do you think its maybe because I have an NPC on the server?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)