For some reason my weapon saving system is not working, it is supposed to put the data in the MySQL database depending on the slot, this is what it outputs when I have a Desert Eagle with 9999 ammo in my hand (the second line is my account), it just outputs some random numbers.. the heck?
pawn Код:
new wep[13], wep2[13];
for (new a = 0; a < 13; a++)
{
GetPlayerWeaponData(playerid, a, wep[a], wep2[a]);
}
format(UserStats[playerid][Wep0], 5, "%d", wep[0]); format(UserStats[playerid][WepAmmo0], 6, "%d", wep2[0]);
format(UserStats[playerid][Wep1], 5, "%d", wep[1]); format(UserStats[playerid][WepAmmo1], 6, "%d", wep2[1]);
format(UserStats[playerid][Wep2], 5, "%d", wep[2]); format(UserStats[playerid][WepAmmo2], 6, "%d", wep2[2]);
format(UserStats[playerid][Wep3], 5, "%d", wep[3]); format(UserStats[playerid][WepAmmo3], 6, "%d", wep2[3]);
format(UserStats[playerid][Wep4], 5, "%d", wep[4]); format(UserStats[playerid][WepAmmo4], 6, "%d", wep2[4]);
format(UserStats[playerid][Wep5], 5, "%d", wep[5]); format(UserStats[playerid][WepAmmo5], 6, "%d", wep2[5]);
format(UserStats[playerid][Wep6], 5, "%d", wep[6]); format(UserStats[playerid][WepAmmo6], 6, "%d", wep2[6]);
format(UserStats[playerid][Wep7], 5, "%d", wep[7]); format(UserStats[playerid][WepAmmo7], 6, "%d", wep2[7]);
format(UserStats[playerid][Wep8], 5, "%d", wep[8]); format(UserStats[playerid][WepAmmo8], 6, "%d", wep2[8]);
format(UserStats[playerid][Wep9], 5, "%d", wep[9]); format(UserStats[playerid][WepAmmo9], 6, "%d", wep2[9]);
format(UserStats[playerid][Wep10], 5, "%d", wep[10]); format(UserStats[playerid][WepAmmo10], 6, "%d", wep2[10]);
format(UserStats[playerid][Wep11], 5, "%d", wep[11]); format(UserStats[playerid][WepAmmo11], 6, "%d", wep2[11]);
new string[500];
format(string, sizeof(string), "UPDATE users SET Wep0='%d',WepAmmo0='%d',Wep1='%d',WepAmmo1='%d',Wep2='%d',WepAmmo2='%d',Wep3='%d',WepAmmo3='%d',Wep4='%d',WepAmmo4='%d' WHERE Name='%s'", UserStats[playerid][Wep0], UserStats[playerid][WepAmmo0], UserStats[playerid][Wep1], UserStats[playerid][WepAmmo1], UserStats[playerid][Wep2], UserStats[playerid][WepAmmo2], UserStats[playerid][Wep3], UserStats[playerid][WepAmmo3], UserStats[playerid][Wep4], UserStats[playerid][WepAmmo4], UserStats[playerid][Name]);
mysql_query(string);
format(string, sizeof(string), "UPDATE users SET Wep5='%d',WepAmmo5='%d',Wep6='%d',WepAmmo6='%d',Wep7='%d',WepAmmo7='%d',Wep8='%d',WepAmmo8='%d' WHERE Name='%s'", UserStats[playerid][Wep5], UserStats[playerid][WepAmmo5], UserStats[playerid][Wep6], UserStats[playerid][WepAmmo6], UserStats[playerid][Wep7], UserStats[playerid][WepAmmo7], UserStats[playerid][Wep8], UserStats[playerid][WepAmmo8], UserStats[playerid][Name]);
mysql_query(string);
format(string, sizeof(string), "UPDATE users SET Wep9='%d',WepAmmo9='%d',Wep10='%d',WepAmmo10='%d',Wep11='%d',WepAmmo11='%d', WHERE Name='%s'", UserStats[playerid][Wep9], UserStats[playerid][WepAmmo9], UserStats[playerid][Wep10], UserStats[playerid][WepAmmo10], UserStats[playerid][Wep1], UserStats[playerid][WepAmmo1], UserStats[playerid][Name]);
mysql_query(string);
//-----------TOP:--------------//
enum pEnum
{
Name[MAX_PLAYER_NAME],
//some other variables here, not necessary to show..
Wep0,
WepAmmo0,
Wep1,
WepAmmo1,
Wep2,
WepAmmo2,
Wep3,
WepAmmo3,
Wep4,
WepAmmo4,
Wep5,
WepAmmo5,
Wep6,
WepAmmo6,
Wep7,
WepAmmo7,
Wep8,
WepAmmo8,
Wep9,
WepAmmo9,
Wep10,
WepAmmo10,
Wep11,
WepAmmo11,
};
new UserStats[MAX_PLAYERS][pEnum];
This doesn't make any sense at all. Why on earth are you trying to cast an integer to a string? Also you should restructure your table. Read my tutorial on it.
pawn Код:
new wep[13], wep2[13];
for (new a = 0; a < 13; a++)
{
GetPlayerWeaponData(playerid, a, wep[a], wep2[a]);
}
new string[500];
format(string, sizeof(string), "UPDATE users SET Wep0='%d',WepAmmo0='%d',Wep1='%d',WepAmmo1='%d',Wep2='%d',WepAmmo2='%d',Wep3='%d',WepAmmo3='%d',Wep4='%d',WepAmmo4='%d' WHERE Name='%s'", wep[0], wep2[0], wep[1], wep2[1], wep[2], wep2[2], wep[3], wep2[3], wep[4], wep2[4], UserStats[playerid][Name]);
mysql_query(string);
format(string, sizeof(string), "UPDATE users SET Wep5='%d',WepAmmo5='%d',Wep6='%d',WepAmmo6='%d',Wep7='%d',WepAmmo7='%d',Wep8='%d',WepAmmo8='%d' WHERE Name='%s'", wep[5], wep2[5], wep[6], wep2[6], wep[7], wep2[7], wep[8], wep2[8], UserStats[playerid][Name]);
mysql_query(string);
format(string, sizeof(string), "UPDATE users SET Wep9='%d',WepAmmo9='%d',Wep10='%d',WepAmmo10='%d',Wep11='%d',WepAmmo11='%d', WHERE Name='%s'", wep[9], wep2[9], wep[10], wep2[10], wep[11], wep2[11], UserStats[playerid][Name]);
mysql_query(string);
I don't really understand Vince's topic about the child tables and restructuration but I'll have to look into it if it improve speed.