MYSQL Weapon saving/reloading
#1

Hey guys!

I'm scripting a server mostly for fun and I somehow made a part of my script work(I'm really new to MYSQL and I'm happy to see it work).

I want to make a script that saves the player's weapons on disconnecting IN A COMPLETELY SEPERATE TABLE and then loads it when he logs back in[this part partially works].

I managed to get the loading part, but it only loads the first weapon in the database and ignores the rest.

My example:

I put a Deagle with 24 bullets in it and an MP5 after it with 29 bullets and it ONLY loaded the Deagle.


I'm using timers because the player doesn't spawn immediately in the gamemode.

pawn Код:
forward spawnweapons(playerid);
public spawnweapons(playerid)
{
    mysql_debug(1);
    format(mainstring,sizeof(mainstring),"SELECT * FROM weapons WHERE PlayerID = '%d'",PlayerInfo[playerid][pID]);
    mysql_query(mainstring);
    mysql_store_result();
    new result[64];
    new weapon[MAX_WEAPONS];
    new ammo[MAX_WEAPONS];
    new id;
    if(mysql_retrieve_row())
    {
        mysql_fetch_field_row(result,"WeaponID");
        weapon[id] = strval(result);
        mysql_fetch_field_row(result,"WeaponAmmo");
        ammo[id] = strval(result);
        GivePlayerWeapon(playerid, weapon[id], ammo[id]);
        id++;
    }
    mysql_free_result();
    mysql_debug(0);    
       
}
So can you help me out with what I need to add to make it load the other weapons too?
And also can you please help me with saving them on disconnecting?

Thank you very much in advance!
Reply
#2

Still need help with this
Reply
#3

Bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)