[HELP] Makeadmin
#1

Hello there,

The following command that i made for some reason does not work:

pawn Код:
CMD:makeadmin(playerid,params[])
{
    if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] >= 7)
    {
        new string[128],name[MAX_PLAYER_NAME],pID,Level;
        GetPlayerName(playerid,name,MAX_PLAYER_NAME);
        if(sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_GREY,"/makeadmin <player> <level>");
        if(IsPlayerConnected(pID))
        {
            if(PlayerInfo[pID][pAdminLevel] != Level)
            {
                if(PlayerInfo[pID][pAdminLevel] < Level)
                {
                    PlayerInfo[pID][pAdminLevel] = Level;
                    format(string,sizeof(string),"** ADMIN PROMOTE: %s Is Now An Administrator Level %d!",name,Level);
                    SendClientMessageToAll(COLOR_PINK,string);
                    GameTextForPlayer(pID,"~g~Promoted",3000,4);
                }
                else
                {
                    GameTextForPlayer(pID,"~r~Demoted",3000,4);
                    format(string,sizeof(string),"** ADMIN DEMOTE: %s Has Been Demoted To Level %d!",name,Level);
                    SendClientMessageToAll(COLOR_PINK,string);
                    PlayerInfo[pID][pAdminLevel] = Level;
                }
            }
            else return SendClientMessage(playerid, COLOR_RED, "This player is already that level.");
        }
        else return SendClientMessage(playerid, COLOR_RED, "Invalid Player Specified.");
    }
    else return 0;
    return 1;
}
As it will return at IsPlayerConnected even if the player is connected.

I was testing this command on myself and entered my id = 0 then my name, however the command still didn't work.

Anyone have any idea?

Thanks

-Michael
Reply
#2

pawn Код:
CMD:makeadmin(playerid,params[])
{
    if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] >= 7)
    {
        new string[128],name[MAX_PLAYER_NAME],pID,Level;
        GetPlayerName(playerid,name,MAX_PLAYER_NAME);
        if(sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_GREY,"/makeadmin <player> <level>");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,COLOR_GREY,"ERROR: Player not connected!");
        if(PlayerInfo[pID][pAdminLevel] != Level)
        {
            if(PlayerInfo[pID][pAdminLevel] < Level)
            {
                  PlayerInfo[pID][pAdminLevel] = Level;
                  format(string,sizeof(string),"** ADMIN PROMOTE: %s Is Now An Administrator Level %d!",name,Level);
                  SendClientMessageToAll(COLOR_PINK,string);
                  GameTextForPlayer(pID,"~g~Promoted",3000,4);
            }
            else
            {
                GameTextForPlayer(pID,"~r~Demoted",3000,4);
                format(string,sizeof(string),"** ADMIN DEMOTE: %s Has Been Demoted To Level %d!",name,Level);
                SendClientMessageToAll(COLOR_PINK,string);
                PlayerInfo[pID][pAdminLevel] = Level;
            }
        }
            else return SendClientMessage(playerid, COLOR_RED, "This player is already that level.");
    }
    else return 0;
    return 1;
}
Reply
#3

Thanks, I believe that its a MySQL Error, due to the fact it all return 0 after IsPlayerConnected, It wasn't happening before I changed a function, however if i change that function back it won't save PlayerInfo, any ideas?
Reply
#4

Its an issue of sscanf because it doesnt support 0.3d i think
Reply
#5

As I said, it has nothing to do with an incorrect code, it is to do with MySQL, please read before you post.

Thanks.
Reply
#6

Then.. Post your mysql code? Check if your mysql database accepts and writes the data from your server?
Reply
#7

Quote:
Originally Posted by king_hual
Посмотреть сообщение
Its an issue of sscanf because it doesnt support 0.3d i think
sscanf is working fine on 0.3d.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)