How to put Limit in this?
#1

I just want to add the Limit. like: if a PLayer do /makeadmin 0 7 then it should display that Ranks only from 1-6
+ I want to add that If a Player is Higher Rank than Other or same Rank than other then it should not Promote demote someone.

PLZ HELP.

This is my Pawn code
pawn Code:
CMD:makeadmin(playerid, params[])
{
                                                  //24 is max player  name
    new playerid2,level,aName[24],pName2[24],string[128];
    if(level > 6 || level < 0) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, ERROR,"You cannot promote/demote a Higher rank admin than you.");
    if(PlayerInfo[playerid][pAdmin] > 4 || IsPlayerAdmin(playerid)) {
        if(sscanf(params,"ud",playerid2,level)) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
        if(!IsPlayerConnected(playerid2)) return SendClientMessage(playerid,ERROR,"Invalid Player.");

        GetPlayerName(playerid, aName,24);
        GetPlayerName(playerid2, pName2,24);

        format(string,sizeof(string), "Admin %s gave you Admin level %d",aName,level);
        SendClientMessage(playerid2, COLOR_YELLOW, string);

        format(string,sizeof(string), "You gave Admin level %d to %s",level,pName2);
        SendClientMessage(playerid, ADMIN, string);
       
        format(string, sizeof(string),"Admin %s gave admin level %d to %s",aName,level,pName2);
        SendAdminMessage(COLOR_RED, string);

        PlayerInfo[playerid2][pAdmin] = level;
        return 1;
    }
    SendClientMessage(playerid, ERROR, "You are not authorized to use that command.");
    return 1;
}
Reply
#2

Quote:
Originally Posted by Harry_Sandhu
View Post
I just want to add the Limit. like: if a PLayer do /makeadmin 0 7 then it should display that Ranks only from 1-6
+ I want to add that If a Player is Higher Rank than Other or same Rank than other then it should not Promote demote someone.

PLZ HELP.

This is my Pawn code
pawn Code:
CMD:makeadmin(playerid, params[])
{
                                                  //24 is max player  name
    new playerid2,level,aName[24],pName2[24],string[128];
    if(level > 6 || level < 0) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, ERROR,"You cannot promote/demote a Higher rank admin than you.");
    if(PlayerInfo[playerid][pAdmin] > 4 || IsPlayerAdmin(playerid)) {
        if(sscanf(params,"ud",playerid2,level)) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
        if(!IsPlayerConnected(playerid2)) return SendClientMessage(playerid,ERROR,"Invalid Player.");

        GetPlayerName(playerid, aName,24);
        GetPlayerName(playerid2, pName2,24);

        format(string,sizeof(string), "Admin %s gave you Admin level %d",aName,level);
        SendClientMessage(playerid2, COLOR_YELLOW, string);

        format(string,sizeof(string), "You gave Admin level %d to %s",level,pName2);
        SendClientMessage(playerid, ADMIN, string);
       
        format(string, sizeof(string),"Admin %s gave admin level %d to %s",aName,level,pName2);
        SendAdminMessage(COLOR_RED, string);

        PlayerInfo[playerid2][pAdmin] = level;
        return 1;
    }
    SendClientMessage(playerid, ERROR, "You are not authorized to use that command.");
    return 1;
}
pawn Code:
if (pAdmin > 6 || pAdmin < 0) return SendClientMessage(playerid, COLOR_RED,"System: Valid Admin Levels: 0-6!");
Reply
#3

Where to add it in the Code?
And the Second thing.
A player cannot Promote Demote the admin Equal to his level and Higher Than his level.
Reply
#4

pawn Code:
CMD:makeadmin(playerid, params[])
{
                                                  //24 is max player  name
    new playerid2,level,aName[24],pName2[24],string[128];
    if(level > 6 || level < 0) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, ERROR,"You cannot promote/demote a Higher rank admin than you.");
  if (pAdmin > 6 || pAdmin < 0) return SendClientMessage(playerid, COLOR_RED,"System: Valid Admin Levels: 0-6!");
    if(PlayerInfo[playerid][pAdmin] > 4 || IsPlayerAdmin(playerid)) {
        if(sscanf(params,"ud",playerid2,level)) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
        if(!IsPlayerConnected(playerid2)) return SendClientMessage(playerid,ERROR,"Invalid Player.");

        GetPlayerName(playerid, aName,24);
        GetPlayerName(playerid2, pName2,24);

        format(string,sizeof(string), "Admin %s gave you Admin level %d",aName,level);
        SendClientMessage(playerid2, COLOR_YELLOW, string);

        format(string,sizeof(string), "You gave Admin level %d to %s",level,pName2);
        SendClientMessage(playerid, ADMIN, string);
       
        format(string, sizeof(string),"Admin %s gave admin level %d to %s",aName,level,pName2);
        SendAdminMessage(COLOR_RED, string);

        PlayerInfo[playerid2][pAdmin] = level;
        return 1;
    }
    SendClientMessage(playerid, ERROR, "You are not authorized to use that command.");
    return 1;
}
So you want it so you can demote/promote people that are the same level?
Reply
#5

Its giving these 3 warnings.

Code:
F:\My Server\Server\gamemodes\IN-RP.pwn(388) : warning 213: tag mismatch
F:\My Server\Server\gamemodes\IN-RP.pwn(388) : warning 213: tag mismatch
F:\My Server\Server\gamemodes\IN-RP.pwn(388) : warning 205: redundant code: constant expression is zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Reply
#6

Quote:
Originally Posted by Harry_Sandhu
View Post
Its giving these 3 warnings.

Code:
F:\My Server\Server\gamemodes\IN-RP.pwn(388) : warning 213: tag mismatch
F:\My Server\Server\gamemodes\IN-RP.pwn(388) : warning 213: tag mismatch
F:\My Server\Server\gamemodes\IN-RP.pwn(388) : warning 205: redundant code: constant expression is zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Sorry about that

pawn Code:
CMD:makeadmin(playerid, params[])
{
                                                  //24 is max player  name
    new playerid2,level,aName[24],pName2[24],string[128];
    if(level > 6 || level < 0) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, ERROR,"You cannot promote/demote a Higher rank admin than you.");
  if(level > 6 || level < 0) return SendClientMessage(playerid, COLOR_RED,"System: Valid Admin Levels: 0-6!");
    if(PlayerInfo[playerid][pAdmin] > 4 || IsPlayerAdmin(playerid)) {
        if(sscanf(params,"ud",playerid2,level)) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
        if(!IsPlayerConnected(playerid2)) return SendClientMessage(playerid,ERROR,"Invalid Player.");

        GetPlayerName(playerid, aName,24);
        GetPlayerName(playerid2, pName2,24);

        format(string,sizeof(string), "Admin %s gave you Admin level %d",aName,level);
        SendClientMessage(playerid2, COLOR_YELLOW, string);

        format(string,sizeof(string), "You gave Admin level %d to %s",level,pName2);
        SendClientMessage(playerid, ADMIN, string);
       
        format(string, sizeof(string),"Admin %s gave admin level %d to %s",aName,level,pName2);
        SendAdminMessage(COLOR_RED, string);

        PlayerInfo[playerid2][pAdmin] = level;
        return 1;
    }
    SendClientMessage(playerid, ERROR, "You are not authorized to use that command.");
    return 1;
}
Reply
#7

Thanks and how can i add it.

A person cannot Promote/demote Higher or Equal Rank than him

Sorry but its again gives more than lvl 6 if we give, lol.
Reply
#8

Quote:
Originally Posted by Harry_Sandhu
View Post
Thanks and how can i add it.

A person cannot Promote/demote Higher or Equal Rank than him
The code that you have now doesn't work?
Reply
#9

No its dosent work and the Code you have given also Dosent Work.
Reply
#10

And it gives lvl 7 also if we give. The Code dosent Work
Reply
#11

Quote:
Originally Posted by Harry_Sandhu
View Post
And it gives lvl 7 also if we give. The Code dosent Work
THe problem isnt the code. I know your problem is somewhere around

Code:
if(level > 6 || level < 0)
Reply
#12

?
Reply
#13

Quote:
Originally Posted by Harry_Sandhu
View Post
?
What admin script is this?
Reply
#14

I have not downloaded.
I have made it from Scratch.
Reply
#15

Quote:
Originally Posted by Harry_Sandhu
View Post
I have not downloaded.
I have made it from Scratch.
Can i see your SetAdmin command or SetLevel?
Reply
#16

There is no Setadmin command.
There is command /makeadmin
Reply
#17

Quote:
Originally Posted by Harry_Sandhu
View Post
There is no Setadmin command.
There is command /makeadmin
Show me /makeadmin
Reply
#18

pawn Code:
CMD:makeadmin(playerid, params[])
{
                                                  //24 is max player  name
    new playerid2,level,aName[24],pName2[24],string[128];
    if(level > 6 || level < 0) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, ERROR,"You cannot promote/demote a Higher rank admin than you.");
    if(level > 6 || level < 0) return SendClientMessage(playerid, COLOR_RED,"System: Valid Admin Levels: 0-6!");
    if(PlayerInfo[playerid][pAdmin] > 4 || IsPlayerAdmin(playerid)) {
        if(sscanf(params,"ud",playerid2,level)) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
        if(!IsPlayerConnected(playerid2)) return SendClientMessage(playerid,ERROR,"Invalid Player.");

        GetPlayerName(playerid, aName,24);
        GetPlayerName(playerid2, pName2,24);

        format(string,sizeof(string), "Admin %s gave you Admin level %d",aName,level);
        SendClientMessage(playerid2, COLOR_YELLOW, string);

        format(string,sizeof(string), "You gave Admin level %d to %s",level,pName2);
        SendClientMessage(playerid, ADMIN, string);

        format(string, sizeof(string),"Admin %s gave admin level %d to %s",aName,level,pName2);
        SendAdminMessage(COLOR_RED, string);

        PlayerInfo[playerid2][pAdmin] = level;
        return 1;
    }
    SendClientMessage(playerid, ERROR, "You are not authorized to use that command.");
    return 1;
}
Reply
#19

Quote:
Originally Posted by Harry_Sandhu
View Post
pawn Code:
CMD:makeadmin(playerid, params[])
{
                                                  //24 is max player  name
    new playerid2,level,aName[24],pName2[24],string[128];
    if(level > 6 || level < 0) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, ERROR,"You cannot promote/demote a Higher rank admin than you.");
    if(level > 6 || level < 0) return SendClientMessage(playerid, COLOR_RED,"System: Valid Admin Levels: 0-6!");
    if(PlayerInfo[playerid][pAdmin] > 4 || IsPlayerAdmin(playerid)) {
        if(sscanf(params,"ud",playerid2,level)) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
        if(!IsPlayerConnected(playerid2)) return SendClientMessage(playerid,ERROR,"Invalid Player.");

        GetPlayerName(playerid, aName,24);
        GetPlayerName(playerid2, pName2,24);

        format(string,sizeof(string), "Admin %s gave you Admin level %d",aName,level);
        SendClientMessage(playerid2, COLOR_YELLOW, string);

        format(string,sizeof(string), "You gave Admin level %d to %s",level,pName2);
        SendClientMessage(playerid, ADMIN, string);

        format(string, sizeof(string),"Admin %s gave admin level %d to %s",aName,level,pName2);
        SendAdminMessage(COLOR_RED, string);

        PlayerInfo[playerid2][pAdmin] = level;
        return 1;
    }
    SendClientMessage(playerid, ERROR, "You are not authorized to use that command.");
    return 1;
}
haha fail, forgot we were already working on this.

The problem isnt my code i dont think.

Try my code.

pawn Code:
CMD:setadmin(playerid, params[])
{
    new victimname[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], admlvl, id;
    if(IsPlayerAdmin(playerid))
    {
        if (sscanf(params, "ui", id, admlvl)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setadmin [id] [adminlevel]");
        if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "System: Invalid ID");
        if (admlvl > 10 || admlvl < 0) return SendClientMessage(playerid, COLOR_RED,"System: Valid Admin Levels: 1-10!");
        PlayerInfo[id][pAdminLevel] = admlvl;
        GetPlayerName(id, victimname, sizeof(victimname));
        GetPlayerName(playerid, adminname, sizeof(adminname));
        new str[128];
        format(str,128,"System: %s [ID %d] has set %s [ID %d] admin level to %i",adminname, playerid, victimname, id, admlvl);
        SendClientMessage(playerid,COLOR_GREEN,str);
        return 1;
    }
    else return SendClientMessage(playerid,COLOR_RED,"  You are not allowed to use this command!");
}
Reply
#20

There is Still a Problem in this Code.
I have put
pawn Code:
if(IsPlayerAdmin(playerid) && PlayerInfo[playerid][pAdmin] >= 5)
But when i am lvl5 also then it also says you are not authorized.
And when i RCon log then it worx but if i am less than lvl 5 then on Rcon also it wont Work. plZ HELP
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)