SA-MP Forums Archive
MySQL Loading Weapons, Not working.... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL Loading Weapons, Not working.... (/showthread.php?tid=286787)



MySQL Loading Weapons, Not working.... - Dokins - 30.09.2011

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.


Re: MySQL Loading Weapons, Not working.... - Dokins - 01.10.2011

Still un-resolved.


Re: MySQL Loading Weapons, Not working.... - MadeMan - 01.10.2011

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]);
                    }