MySQL saving variable help
#1

Hey,

So i sorted the issue out with my random server crash seems to work fine now, however my variables don't, the MySQL information works fine however when i makeadmin someone it will save the in game var for only that game, for some reason my loading system isn't working.

pawn Код:
public OnQueryFinish(query[], resultid, extraid, connectionHandle) // this is for threaded SQL queries
{
    switch(resultid)
    {
        case qDefault: return 1;
        case qAuthentication:
        {
            mysql_store_result();
            if(mysql_num_rows() == 1)
            {
                new szResult[500];
                while(mysql_fetch_row_format(szResult, "|"))
                {
                    sscanf(szResult, "e<p<|>s[25]s[30]ddddddddddddddffdddd>", PlayerInfo[extraid]);
                    SPD(extraid, diagAuthentication);
                }
            }
            else if(mysql_num_rows() < 1) SPD(extraid, diagRegistration);
            else SendClientMessage(extraid, COLOR_RED, "There appears to be a problem in our database, please contact an administrator.");
            mysql_free_result();
        }
    }
    return 1;
}
I think that is the code, i had a friend who scripted the base for me, if anyone could help it would be great.
Reply
#2

show us your makeadmin cmd and tell us what:
your admin var is,
your accounts table in db is,
ur admin field name in table is
Reply
#3

pawn Код:
CMD:makeadmin(playerid,params[])
{
    if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] >= 1337) //the one who typed it
    {
        new string[128],name[MAX_PLAYER_NAME],pID,Level;
        GetPlayerName(playerid,name,MAX_PLAYER_NAME);
        if(j_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;
}
pAdminLevel

Accounts

AdminLevel
Reply
#4

pawn Код:
CMD:makeadmin(playerid,params[])
{
    if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] >= 1337) //the one who typed it
    {
        new string[128],name[MAX_PLAYER_NAME],pID,Level,query[128];
        if(j_sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_GREY,"/makeadmin <player> <level>");
        GetPlayerName(pID,name,MAX_PLAYER_NAME);//i think there was a mistake here. You were getting the name of who typed it instead of whom you made admin
        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);
                    format(query,128,"UPDATE Accounts SET AdminLevel=%d Where Name='%s'",Level,name);//Name field is correct right?
                    mysql_query(query);
                }
                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;
                    format(query,128,"UPDATE Accounts SET AdminLevel=%d Where Name='%s'",Level,name);
                    mysql_query(query);
                }
            }
            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;
}
The Users AdminLevel will be saved as soon as he is made admin or demoted.
Reply
#5

Not sure you are understanding what i mean, basically no PlayerInfo is working.
Reply
#6

ok so you mean the vars dont load on login?

post your Login code here then
Reply
#7

Hey,

Do you have skype and team viewer? Basically my friend scripted the account login system so it would be alot easier if you took a look at it yourself, I am not very good with MySQL at the moment.

Skype: mike.is.here2011.

Thanks

-Michael
Reply
#8

added.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)