SA-MP Forums Archive
[REP+]/setlevel cmd for all people?? wtfff - 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: [REP+]/setlevel cmd for all people?? wtfff (/showthread.php?tid=324422)



[REP+]/setlevel cmd for all people?? wtfff - niels44 - 09.03.2012

hey guys,
i have this /setlevel cmd in my admin system but somehow it is failing...
it is cuz EVERY player can do /setlevel... but it should be only for rcon admins...
and its not in my only admin system cuz i have 3 admin systems in filterscripts folder so i tried first ladmin, that one failed so i tried luxadmin, failed too then i tried Gadmin, failed also??
i dont know whats wrong with this cmd but here is the command:
pawn Код:
CMD:setlevel(playerid,params[]) {
        if(PlayerInfo[playerid][Level] >= 7 || !IsPlayerAdmin(playerid)) {
            new tmp[256], tmp2[256], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
            if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /setlevel [playerid] [level]");
            new player1, level, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
            player1 = strval(tmp);
            if(isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setlevel [playerid] [level]");
            level = strval(tmp2);

            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
                if(PlayerInfo[player1][LoggedIn] == 1) {
                    if(level > ServerInfo[MaxAdminLevel] ) return SendClientMessage(playerid,red,"ERROR: Incorrect Level");
                    if(level == PlayerInfo[player1][Level]) return SendClientMessage(playerid,red,"ERROR: Player is already this level");
                    CMDMessageToAdmins(playerid,"SETLEVEL");
                    GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
                    new year,month,day;   getdate(year, month, day); new hour,minute,second; gettime(hour,minute,second);

                    if(level > 0) format(string,sizeof(string),"Administrator %s has set you to Administrator Status [level %d]",adminname, level);
                    else format(string,sizeof(string),"Administrator %s has set you to Player Status [level %d]",adminname, level);
                    SendClientMessage(player1,blue,string);

                    if(level > PlayerInfo[player1][Level]) GameTextForPlayer(player1,"~g~Promoted", 2000, 3);
                    else GameTextForPlayer(player1,"~r~Demoted", 2000, 3);

                    format(string,sizeof(string),"You have made %s Level %d on %d/%d/%d at %d:%d:%d", playername, level, day, month, year, hour, minute, second); SendClientMessage(playerid,blue,string);
                    format(string,sizeof(string),"Administrator %s has made %s Level %d on %d/%d/%d at %d:%d:%d",adminname, playername, level, day, month, year, hour, minute, second);
                    SaveToFile("AdminLog",string);
                    dUserSetINT(PlayerName2(player1)).("level",(level));
                    PlayerInfo[player1][Level] = level;
                    return PlayerPlaySound(player1,1057,0.0,0.0,0.0);
                } else return SendClientMessage(playerid,red,"ERROR: Player must be registered and logged in to be admin");
            } else return SendClientMessage(playerid, red, "Player is not connected");
        } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
pls help

greets niels


Re: [REP+]/setlevel cmd for all people?? wtfff - SuperViper - 09.03.2012

Change

pawn Код:
!IsPlayerAdmin(playerid)
to

pawn Код:
IsPlayerAdmin(playerid)



Re: [REP+]/setlevel cmd for all people?? wtfff - SpiritEvil - 09.03.2012

Replace:

pawn Код:
if(PlayerInfo[playerid][Level] >= 7 || !IsPlayerAdmin(playerid)) {
With:

pawn Код:
if(PlayerInfo[playerid][Level] >= 7 || IsPlayerAdmin(playerid)) {
You are basically saying if the player's level is higher than 7 OR the player is NOT logged in as rcon (basically all players) then allow them to to perform the command.


Re: [REP+]/setlevel cmd for all people?? wtfff - Campbell- - 09.03.2012

pawn Код:
if(PlayerInfo[playerid][Level] >= 7 || !IsPlayerAdmin(playerid))
Код:
If the player has the Admin-Level 7 or higher or is -NOT- an administrator.



Re: [REP+]/setlevel cmd for all people?? wtfff - niels44 - 09.03.2012

huh? but !IsPlayerAdmin is rcon right? or not? cuz i thought that with a ! is rcon... if this isnt then can you tell me what rcon is? cuz i want the cmd for RCON only..., also the player has to be lvl 7


Re: [REP+]/setlevel cmd for all people?? wtfff - Campbell- - 09.03.2012

A '!' does always stay for 'is not'.

Examples:

pawn Код:
if(1 != 1)
{
   /* If one -IS NOT- equal to one ... */
}
pawn Код:
if(!IsPlayerAdmin(playerid))
{
   /* If playerid -IS NOT- an admin ... */
}
pawn Код:
if(IsPlayerAdmin(playerid))
{
   /* If playerid is an admin ... */
}



Re: [REP+]/setlevel cmd for all people?? wtfff - SpiritEvil - 09.03.2012

The "!" character means NOT. For example if you type "if(!IsPlayerAdmin(playerid))" it means if the player is NOT RCON admin the do the following. So you want to type:

pawn Код:
if(PlayerInfo[playerid][Level] >= 7 || IsPlayerAdmin(playerid)) {

//The rest of the code here
}



Re: [REP+]/setlevel cmd for all people?? wtfff - niels44 - 09.03.2012

yeah but now i have thius line:
pawn Код:
if(PlayerInfo[playerid][Level] >= 7 || IsPlayerAdmin(playerid)) {
but i can just use this command without logging in to rcon first


Re: [REP+]/setlevel cmd for all people?? wtfff - Campbell- - 09.03.2012

Check if it works like that:

Код:
Returns	1 if the player is logged into RCON, otherwise 0
pawn Код:
if(PlayerInfo[playerid][Level] >= 7 || IsPlayerAdmin(playerid) == 1) {



Re: [REP+]/setlevel cmd for all people?? wtfff - niels44 - 09.03.2012

eeehm sorry but this isnt working also