Weapons won't save- MYSQL(Code inside)
#1

pawn Код:
SaveWeapons()
{
    for(new p = 0; p < MAX_PLAYERS; p++)
    {
        if(LoggedIn[p] == 1 && IsPlayerConnected(p))
        {
            for(new w = 0; w < 13; w++)
            {
                GetPlayerWeaponData(p, w, PlayerWeapons[p][w], PlayerWeaponAmmo[p][w]);

                new fieldname[50], Float:armour;
                format(fieldname, sizeof(fieldname), "Weapon%d", w);
                MySQL_SetInteger(PlayerSQLID[p], fieldname, PlayerWeapons[p][w], "Accounts");
                format(fieldname, sizeof(fieldname), "Weapon%dAmmo", w);
                MySQL_SetInteger(PlayerSQLID[p], fieldname, PlayerWeaponAmmo[p][w], "Accounts");

                GetPlayerArmour(p, armour);
                MySQL_SetFloat(PlayerSQLID[p], "Armour", armour, "Accounts");
            }
        }
    }
    return 1;
}
As the title says, weapons won't save at all which is very strange, also the above code is placed in a timer which saves every 5 seconds. It simply will not save although, I gave myself a weapon via mysql and then connected and it loaded.
Reply
#2

Why you don't update through mysql_query?

pawn Код:
new name[MAX_PLAYER_NAME], GetPlayerName(p, name, sizeof(name));
mysql_query("UPDATE 'Accounts' SET 'Weapons' = '%d' AND 'Ammo' = '%d' AND Armour = '%f' WHERE name = '%s'", PlayerWeapons[p][w], PlayerWeaponAmmo[p][w], armour, name);
Reply
#3

Ew .. 2x13x500 = 13000 queries (in the worst case) every 5 seconds.
Reply
#4

Resolved. Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)