MySQL Admin problems
#1

Hi. I have found out how to make a basic admin command with MySQL but I cannot figure out how to make an if-function where I ask whether the player typing the command is admin or not and then depending on what the playerinfo shows for the player he succeeds making the other player admin or not. I tried to use GetPVarInt but with no success.

To sum this up; I basically need to know how to receive information from the MySQL database.

This is how far I have got:
pawn Код:
COMMAND:makeadmin(playerid, params[]) //using ZCMD this is how your command will start off looking like.
{
    if(GetPVarInt(playerid, "Adminlevel" == 1) // gives me errors, obviously something wrong
    {
        new otherplayerid;
        if(sscanf(params, "ui", otherplayerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "/makeadmin [playerid/name] [adminlevel]");
        else if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "This player is not connected");
        else
        {
            SendClientMessage(otherplayerid,0xFFFFFFFF,"An admin has set you as administrator.");
            SetPVarInt(otherplayerid, "Adminlevel", 1);

            SendClientMessage(playerid, 0xFFFFFFFF, "You have given someone administrator rights.");
        }
    }
    return 1;
}
As you can see it's not really finished yet.

I also would like to ask, how can I instead of directly setting the adminlevel to 1 set it to whatever the admin chooses to set it to?

Example: /makeadmin 1 3
Explaination: [Command] [ID] [Level]

Thank you!
Reply
#2

I normally never bump my threads but I need to know this to continue my scripting. Please have a look at my questions above, I would very much appreciate it.
Reply
#3

add me in msn i help u ! pyrokar@libero.it
Reply
#4

if(GetPVarInt(playerid, "Adminlevel") == 1)
Reply
#5

Try:
pawn Код:
COMMAND:makeadmin(playerid, params[]) //using ZCMD this is how your command will start off looking like.
{
    if(GetPVarInt(playerid, "Adminlevel") > 0) // player level more (>) 0
    {
        new
            otherplayerid,
            level;
        if(sscanf(params, "ui", otherplayerid, level) || level < 0 || level > 5) // split input string and check level value 0 to 5
            SendClientMessage(playerid, 0xFFFFFFFF, "/makeadmin [playerid/name] [adminlevel 1 - 5]");  
        else if(otherplayerid == INVALID_PLAYER_ID) // Check player connected
            SendClientMessage(playerid, 0xFFFFFFFF, "This player is not connected");
        else
        {
            SendClientMessage(otherplayerid, 0xFFFFFFFF, "An admin has set you as administrator."); // message new admin player
            SetPVarInt(otherplayerid, "Adminlevel", level); // Set admin level
            SendClientMessage(playerid, 0xFFFFFFFF, "You have given someone administrator rights.");
        }
    }
    return 1;
}
Reply
#6

@[ISS]jumbo. I appreciate the help you tried to give me but due to your lack of English it was hard to understand what you was saying. No offence man, I really am thankful for you trying. Anyone else got any idea how to figure this out?

Edit: Testing that smeti
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)