SA-MP Forums Archive
Stickenkid's MySQL assistance - 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: Stickenkid's MySQL assistance (/showthread.php?tid=554160)



Stickenkid's MySQL assistance - LocMax - 02.01.2015

I'm trying to load player's weapons, but I'm not sure how to assign the field to a variable so that I could use it in GivePlayerWeapon..
Can anybody please show me an example?

pawn Код:
format(Query, sizeof(Query), "SELECT weapons, ammo FROM weapons WHERE id = %d", PlayerInfo[playerid][DBID]);
                    mysql_query(Query);
                    mysql_store_result();
                    if(mysql_num_rows())
                    {
                        for(new i, j = mysql_num_rows(); i < j; i++)
                        {
                            mysql_fetch_field_num(i, "weapons");
                            mysql_fetch_field_num(i, "ammo");
                            if(!(0 <= PlayerInfo[playerid][Weapons] <= 46)) continue;
                            GivePlayerWeapon(playerid, PlayerInfo[playerid][Weapons], PlayerInfo[playerid][Ammo]);
                        }
                    }