Save Weapons system not working..
#1

I'm working on a large script and the weapons save system doesn't seem to work...

pawn Код:
SaveWeaps(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    new weap1, ammo1, weap2, ammo2, weap3, ammo3, weap4, ammo4, weap5, ammo5, weap6, ammo6, weap7, ammo7;
     GetPlayerWeaponData(playerid,2,weap1,ammo1);// handgun
    GetPlayerWeaponData(playerid,3,weap2,ammo2);//shotgun
    GetPlayerWeaponData(playerid,4,weap3,ammo3);// SMG
    GetPlayerWeaponData(playerid,5,weap4,ammo4);// AK47 / M4
    GetPlayerWeaponData(playerid,6,weap5,ammo5);// rifle
    GetPlayerWeaponData(playerid,7,weap6,ammo6);// rocket launcher
    GetPlayerWeaponData(playerid,8,weap7,ammo7);// Grenades
    new query[512];
    format(query, sizeof(query), "UPDATE users SET weap1 = '%d' ammo1 = '%d' weap2 = '%d' ammo2 = '%d' weap3 = '%d' ammo3 = '%d' weap4 = '%d' ammo4 = '%d' weap5 = '%d' ammo5 = '%d' weap6 = '%d' ammo6 = '%d' weap7 = '%d' ammo7 = '%d' WHERE username = '%s'", weap1, ammo1, weap2, ammo2, weap3, ammo3, weap4, ammo4, weap5, ammo5, weap6, ammo6, weap7, ammo7, name);
    mysql_query(query);
}

And of course I have SaveWeaps(playerid); under public OnPlayerDisconnect

I give myself an M4, I disconnect, I look at the mysql DB and the values aren't saved in there.. I know I can connect with the db fine because my register/login system works fine and my snippet to save player money also works fine which is..

pawn Код:
GetPlayerName(playerid, pName, sizeof(pName));
format(query,sizeof(query),"UPDATE users SET money = '%d' WHERE username = '%s'",GetPlayerMoney(playerid),pName);
mysql_query(query);
Thats also under OnPlayerDisconnect
Reply
#2

Fell down to the second page with no replies. I really need to continue coding, please throw in some ideas.
Reply
#3

The code was freaking long.. Try to debug it (printf(query)).
Reply
#4

I tried using both SendPlayerMessage and printf to print query but neither returned any output in-game or in server_log.txt
Reply
#5

pawn Код:
format(query, sizeof(query), "UPDATE users SET weap1=%d, ammo1=%d, weap2=%d, ammo2 =%d, weap3=%d, ammo3=%d, weap4=%d, ammo4=%d, weap5=%d, ammo5=%d, weap6=%d, ammo6=%d, weap7=%d, ammo7=%d WHERE username = '%s'", weap1, ammo1, weap2, ammo2, weap3, ammo3, weap4, ammo4, weap5, ammo5, weap6, ammo6, weap7, ammo7, name);
If server doesn't crash, but only mysql data isn't updated run the query from mysql debug in phpmyadmin and it will show you the errors
Reply
#6

Okay so I tried putting the query through phpmyadmin, replacing any %d with a random value and %s with my username and the query went through fine.. So it's not the query that's the problem. I suspect GetPlayerWeaponData isn't working right..

because for example if I try to print the variables that GetPlayerWeaponData returns such as weap1 and ammo1, it doesn't print/return anything.
Reply
#7

Show the prints (printf).
Reply
#8

If you mean their output, *There is none!* if you mean the actual lines then it's just like... printf(query);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)