MySQL Loading Weapons, Not working....
#1

It saves the weapons to the database under the user account, but wont load them, I can't figure why.

Where would be a good place to add this code, also, I've tried OnPlayerSpawn and under DIALOG_LOGIN.

pawn Код:
for(new p = 0; p < MAX_PLAYERS; p++)
                    {
                    if(LoggedIn[p] == 1 && IsPlayerConnected(p))
                        {
                            for(new w = 0; w < 13; w++)
                            {
                                new fieldname[50];
                                PlayerSQLID[p] = MySQL_GetValue(p, "id", "Accounts");
                                format(fieldname, sizeof(fieldname), "Weapon%d", w);
                                PlayerWeapons[p][w] = MySQL_GetValue(PlayerSQLID[p], fieldname, "Accounts");
                                format(fieldname, sizeof(fieldname), "Weapon%dAmmo", w);
                                PlayerWeaponAmmo[p][w] = MySQL_GetValue(PlayerSQLID[p], fieldname, "Accounts");
                               
                                if(PlayerWeapons[p][w] > 0) GivePlayerWeapon(p, PlayerWeapons[p][w], PlayerWeaponAmmo[p][w]);
                            }
                        }
                    }
I also added a function LoadWeapons(); which contains all of that. Still no sucess.

Thats all under dialog_login.

Thanks in advance.
Reply
#2

Still un-resolved.
Reply
#3

Under DIALOG_LOGIN should be fine, but make sure player is spawned.

pawn Код:
new fieldname[50];
                    PlayerSQLID[playerid] = MySQL_GetValue(playerid, "id", "Accounts");
                    for(new w = 0; w < 13; w++)
                    {
                        format(fieldname, sizeof(fieldname), "Weapon%d", w);
                        PlayerWeapons[playerid][w] = MySQL_GetValue(PlayerSQLID[playerid], fieldname, "Accounts");
                        format(fieldname, sizeof(fieldname), "Weapon%dAmmo", w);
                        PlayerWeaponAmmo[playerid][w] = MySQL_GetValue(PlayerSQLID[playerid], fieldname, "Accounts");
                       
                        if(PlayerWeapons[playerid][w] > 0) GivePlayerWeapon(playerid, PlayerWeapons[playerid][w], PlayerWeaponAmmo[playerid][w]);
                    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)