SA-MP Forums Archive
Admin Commands not working - 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)
+--- Thread: Admin Commands not working (/showthread.php?tid=371474)



Admin Commands not working - Sanady - 23.08.2012

Hello.Today I made Admin system but from start all commands was working but now commands are not working I don`t know why..Giving this message "[ERROR]You are not authorized to use this command!"

pawn Код:
CMD:setlevel(playerid,params[])
{
    if(UserStats[playerid][Admin] >= 5 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
    new id,str[250],level;
    if(sscanf(params, "ud", id, level)) return SendClientMessage(playerid, yellow, "[Usage]"embed_white "/setlevel "embed_white"<id> <level>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, red, "[ERROR]"embed_white "That player is not connected");
    if(level < 0 || level > 5) return SendClientMessage(playerid, red, "[ERROR]"embed_white "Invalid level! | MIN 0  | MAX 5");
    if(UserStats[id][Admin] == level) return SendClientMessage(playerid, red, "[ERROR]"embed_white "Player is already that level!");
    new action;
    if(UserStats[id][Admin] < level)
    {
        action = 1;
    }
    else
    {
        action = 0;
    }
    UserStats[id][Admin] = level;
    format(str, sizeof(str), "UPDATE `Users` SET `Admin` = %i WHERE `Name` = '%s'", UserStats[id][Admin], UserStats[id][Name]);
    mysql_query(str);

    format(str, 128,""embed_blue"[Admin]"embed_white"Admin "embed_blue"%s[%i]"embed_white" %s "embed_white"you to "embed_sw"%d"embed_white"!", UserStats[playerid][Name], playerid,action ? (embed_green"promote") : (embed_red"demote"), level);
    SendClientMessage(id, white, str);

    format(str, 128,"You %s "embed_blue"%s[%i]"embed_white" to "embed_sw"%d"embed_white"!", action ? (embed_green"promote"embed_white) : (embed_red"demote"embed_white),UserStats[id][Name], id, level);
    SendClientMessage(playerid, white, str);
    return 1;
}
CMD:kick(playerid,params[])
{
    if(UserStats[playerid][Admin] >= 1 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
    new id,string[158],reason[78];
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, red, "[ERROR]"embed_white "That player is not connected");
    if(sscanf(params,"uS(No Reason)[78]", id, reason)) return SendClientMessage(playerid, yellow, "[Usage]"embed_white "/kick [Part Of Name/ID] [Reason]");
    if(UserStats[playerid][Admin] < UserStats[id][Admin]) return SendClientMessage(playerid, red, "[ERROR]"embed_white "You can not kick that player! Report him on forum");

    format(string, sizeof(string),"You kicked "embed_blue"%s "embed_white"for: {ED136A}%s", UserStats[id][Name], reason);
    SendClientMessage(playerid, white, string);
   
    format(string, sizeof(string),""embed_blue"[Admin]"embed_white"You are kicked by admin "embed_blue"%s "embed_white"for: {ED136A}%s", UserStats[playerid][Name], reason);
    SendClientMessage(id,white, string);

    format(string, sizeof(string),""embed_blue"[Admin]"embed_white"Admin "embed_blue"%s "embed_white"kicked "embed_blue"%s "embed_white"for: {ED136A}%s", UserStats[playerid][Name], UserStats[id][Name], reason);
    SendClientMessageToAll(white, string);
   
    Kick(id);
    return 1;
}
CMD:setexp(playerid,params[])
{
    if(UserStats[playerid][Admin] >= 5 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
    new id,str[250],exp;
    if(sscanf(params, "ud", id, exp)) return SendClientMessage(playerid, yellow, "[Usage]"embed_white "/setlevel "embed_white"<id> <level>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, red, "[ERROR]"embed_white "That player is not connected");
    if(exp < 0 || exp > 50000) return SendClientMessage(playerid, red, "[ERROR]"embed_white "Invalid level! | MIN 0  | MAX 50.000");
   
    UserStats[id][Exp] = exp;
    format(str, sizeof(str), "UPDATE `Users` SET `Exp` = %i WHERE `Name` = '%s'", UserStats[id][Exp], UserStats[id][Name]);
    mysql_query(str);

    format(str, sizeof(str),""embed_blue"[Admin]"embed_white"Admin "embed_blue"%s[%i] "embed_white"gave you "embed_orange"%d "embed_white"experience!", UserStats[playerid][Name], exp);
    SendClientMessage(id, white, str);

    format(str, sizeof(str),"You gave "embed_orange"%d "embed_white"experience to"embed_blue"%s[%i]"embed_white"!", exp,UserStats[id][Name], id);
    SendClientMessage(playerid, white, str);
    return 1;
}
CMD:ban(playerid,params[])
{
    if(UserStats[playerid][Admin] >= 1 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
    new id,string[158],reason[78];
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, red, "[ERROR]"embed_white "That player is not connected");
    if(sscanf(params,"uS(No Reason)[78]", id, reason)) return SendClientMessage(playerid, yellow, "[Usage]"embed_white "/ban [Part Of Name/ID] [Reason]");
    if(UserStats[playerid][Admin] < UserStats[id][Admin]) return SendClientMessage(playerid, red, "[ERROR]"embed_white "You can not ban that player! Report him on forum");

    format(string, sizeof(string),"You banned "embed_blue"%s "embed_white"for: {ED136A}%s", UserStats[id][Name], reason);
    SendClientMessage(playerid, white, string);

    format(string, sizeof(string),""embed_blue"[Admin]"embed_white"You are banned by admin "embed_blue"%s "embed_white"for: {ED136A}%s", UserStats[playerid][Name], reason);
    SendClientMessage(id,white, string);

    format(string, sizeof(string),""embed_blue"[Admin]"embed_white"Admin "embed_blue"%s "embed_white"banned "embed_blue"%s "embed_white"for: {ED136A}%s", UserStats[playerid][Name], UserStats[id][Name], reason);
    SendClientMessageToAll(white, string);

    Ban(id);
    return 1;
}



Re: Admin Commands not working - ZBits - 23.08.2012

try to rcon login and try


Re: Admin Commands not working - Sanady - 23.08.2012

Quote:
Originally Posted by Domnic Toretto
Посмотреть сообщение
try to rcon login and try
I try with RCON and it`s not working anyone can help me


Re: Admin Commands not working - [KHK]Khalid - 23.08.2012

Well, your checks are totally wrong. Let's take /ban as an example:

pawn Код:
if(UserStats[playerid][Admin] >= 1 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
Here you're checking if their level is above 0 (In other words, if they're admins) OR if they are logged as rcon admin, and if that's true then you tell them that they aren't allowed to use this command (Which you shouldn't do). Your check is supposed to be like this:

pawn Код:
if(UserStats[playerid][Admin] < 1 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
This will check if their level is less than 1 (In other words, regular player) OR if they aren't logged in as rcon admins, then tells them they aren't allowed to use this command.


Re: Admin Commands not working - Sanady - 23.08.2012

Quote:
Originally Posted by HellSphinX
Посмотреть сообщение
Well, your checks are totally wrong. Let's take /ban as an example:

pawn Код:
if(UserStats[playerid][Admin] >= 1 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
Here you're checking if their level is above 0 (In other words, if they're admins) OR if they are logged as rcon admin, and if that's true then you tell them that they aren't allowed to use this command (Which you shouldn't do). Your check is supposed to be like this:

pawn Код:
if(UserStats[playerid][Admin] < 1 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
This will check if their level is less than 1 (In other words, regular player) OR if they aren't logged in as rcon admins, then tells them they aren't allowed to use this command.
I changed that but still same problem..


Re: Admin Commands not working - DeadLy™ - 23.08.2012

Use RCON. Then go in game. See yur plugins update if needed. Try to saw .amx
I think some bugs will find.


Re: Admin Commands not working - ZBits - 23.08.2012

i think

go to your server foldr called Scriptfiles look for the player account files and Edit the Admin level
check if that works


Re: Admin Commands not working - scottyishere - 23.08.2012

REPLACE THIS:
pawn Код:
if(UserStats[playerid][Admin] >= 5 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
WITH THIS:
pawn Код:
if(UserStats[playerid][Admin] < 5 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
EDIT:

and this

pawn Код:
if(UserStats[playerid][Admin] >= 1 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
WITH THIS:

pawn Код:
if(UserStats[playerid][Admin] < 1 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");



Re: Admin Commands not working - Lordzy - 23.08.2012

Quote:
Originally Posted by scottyishere
Посмотреть сообщение
REPLACE THIS:
pawn Код:
if(UserStats[playerid][Admin] >= 5 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
WITH THIS:
pawn Код:
if(UserStats[playerid][Admin] < 5 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
EDIT:

and this

pawn Код:
if(UserStats[playerid][Admin] >= 1 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
WITH THIS:

pawn Код:
if(UserStats[playerid][Admin] < 1 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
Well then the player needs to be Admin Lv 5 and Rcon.
Here player cant set admin even though he is rcon or admin.


Try updating your sscanf then.


Re: Admin Commands not working - Sanady - 23.08.2012

Quote:
Originally Posted by scottyishere
Посмотреть сообщение
REPLACE THIS:
pawn Код:
if(UserStats[playerid][Admin] >= 5 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
WITH THIS:
pawn Код:
if(UserStats[playerid][Admin] < 5 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
EDIT:

and this

pawn Код:
if(UserStats[playerid][Admin] >= 1 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
WITH THIS:

pawn Код:
if(UserStats[playerid][Admin] < 1 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,""embed_red"[ERROR]"embed_white"You are not authorized to use this command!");
This one is working thanks +rep