if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) .... -
Kyance - 16.12.2013
Basically, i just started with the pAdmin stuff, but i keep getting this message ->
pawn Код:
CMD:adminduty(playerid,params[]) {
if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - You're not a high enough level to use this command!");
//rest of script
Even though i set myself to level 1 or higher, it will keep saying the "You're not a high enough level to use this command!"
But if i log in via the RCON, it will let me use the command.
Wikipedia(
https://sampwiki.blast.hk/wiki/Control_Structures ) says the "||" should mean "or"..
Re: if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) .... -
Jstylezzz - 16.12.2013
The command is fine. I think the pAdmin variable is not being set correctly. In other words, can you show the code where you set the variable?
Re: if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) .... -
Kyance - 16.12.2013
Quote:
Originally Posted by Jstylezzz
The command is fine. I think the pAdmin variable is not being set correctly. In other words, can you show the code where you set the variable?
|
I suppose that this is what you need?
pawn Код:
CMD:setlevel(playerid, params[]) {
new id;
new level;
new string[128];
if(PlayerInfo[playerid][pAdmin] < 5 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - You're not a high enough level to use this command!");
if(sscanf(params, "ud", id, level)) return SendClientMessage(playerid, COLOR_RED, "[USAGE] - /setlevel [ID] [Level 0 - 7]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "[ERROR] - Player not found!");
if(level > 7) return SendClientMessage(playerid, COLOR_RED, "[ERROR] - Choose a valid level! [ 0 - 7 ]!");
if(level == PlayerInfo[id][pAdmin]) return SendClientMessage(playerid, COLOR_RED, "[ERROR] - Player is already that level!");
new pname[MAX_PLAYER_NAME],recievername[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
GetPlayerName(id,recievername,sizeof(recievername));
if(level > PlayerInfo[id][pAdmin])
{
GameTextForPlayer(id, "~g~PROMOTED", 2500, 1);
PlayerInfo[id][pAdmin] = level;
format(string, sizeof(string), "* Admin %s[%d] has used SETLEVEL on %s[%d] | Level: %d |!", pname, playerid, recievername, id, level);
SendMessageToAdmins(string);
format(string, sizeof(string), "* Admin %s[%d] has promoted %s[%d] to Level %d!", pname, playerid, recievername, id, level);
SendClientMessageToAll(COLOR_GREEN, string);
}
else
{
GameTextForPlayer(id, "~r~DEMOTED", 2500, 1);
PlayerInfo[id][pAdmin] = level;
format(string, sizeof(string), "* Admin %s[%d] has used SETLEVEL on %s[%d] | Level: %d |!", pname, playerid, recievername, id, level);
SendMessageToAdmins(string);
format(string, sizeof(string), "* Admin %s[%d] has demoted %s[%d] to Level %d!", pname, playerid, recievername, id, level);
SendClientMessageToAll(COLOR_RED, string);
}
return 1;
}
Re : if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) .... -
Younes44 - 16.12.2013
Can you Guys Give Link About Best Admin Cmds and vip too pls
Re: Re : if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) .... -
Jstylezzz - 16.12.2013
Quote:
Originally Posted by Younes44
Can you Guys Give Link About Best Admin Cmds and vip too pls
|
No. Search.
Quote:
Originally Posted by Kyance
I suppose that this is what you need?
|
Let's debug the adminduty command.Try this, and tell me what it says.
pawn Код:
CMD:adminduty(playerid,params[]) {
printf("ADMINDUTY DEBUG - Level: %d",PInfo[playerid][pAdmin]);
if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - You're not a high enough level to use this command!");
//rest of script
Add that little printf thingie above the if(...) code, then the console/server_log.txt will show us what the value of the pAdmin variable is when the command is performed.
Re: Re : if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) .... -
Kyance - 16.12.2013
Quote:
Originally Posted by Jstylezzz
No. Search.
Let's debug the adminduty command.Try this, and tell me what it says.
pawn Код:
CMD:adminduty(playerid,params[]) { printf("ADMINDUTY DEBUG - Level: %d",PInfo[playerid][pAdmin]); if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - You're not a high enough level to use this command!"); //rest of script
Add that little printf thingie above the if(...) code, then the console/server_log.txt will show us what the value of the pAdmin variable is when the command is performed.
|
Sorry for the(possibly) late answer..
[19:01:08] Incoming connection: 127.0.0.1:58224
[19:01:08] [join] Kyance has joined the server (0:127.0.0.1)
[19:01:17] ADMINDUTY DEBUG - Level: 7
Re: if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) .... -
Brandon_More - 16.12.2013
pawn Код:
if(!PlayerInfo[playerid][pAdmin] && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED, "You cannot use this command");
Works for me :/
Re: if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) .... -
Kyance - 16.12.2013
Quote:
Originally Posted by Brandon_More
pawn Код:
if(!PlayerInfo[playerid][pAdmin] && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED, "You cannot use this command");
Works for me :/
|
Yep, this works for me, thanks!
+repped both for trying to help

EDIT: Yes, but.. Now there's another problem.
pawn Код:
CMD:givescoreall(playerid, params[]) {
new score;
if(PlayerInfo[playerid][pAdmin] < 3 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - You're not a high enough level to use this command!");
This will work with every level if it's set to "!PlayerInfo..."
Well, should i just remove the "!IsPlayerAdmin"? ;d
Re: if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) .... -
Vince - 16.12.2013
You quoted the answer in your post.
Re: if(PlayerInfo[playerid][pAdmin] < 1 || !IsPlayerAdmin(playerid)) .... -
SilentSoul - 16.12.2013
Quote:
Originally Posted by Kyance
Well, should i just remove the "!IsPlayerAdmin"? ;d
|
I think that's not a solution because you can't customize admin commands for each level , Let's try by that only instead of using that with rcon admin !
pawn Код:
CMD:givescoreall(playerid, params[]) {
new score;
printf("-Admin debug | Level : %d",PlayerInfo[playerid][pAdmin]);
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - You're not a high enough level to use this command!");
Tell me if that's work please without the rcon admin !