MYSQL Saving Problem
#1

Hey guys, I'm scripting a zombie survival server for fun, don't know if I'll ever finish it but I came across a pretty annoying problem: When someone disconnects MYSQL doesn't save their stats.

When players register it does, but when they disconnect the stats don't refresh. I tried editing values in phpMyAdmin then logging in and out, the value stays the same so it's not even ,,zeroing" all the values on exit.

It saves all the player files if the player is Logged in ( if(PlayerInfo[playerid][pLogged] == 1) ), and the script itself works ( I've put a sendclientmessage in the end and it displayed it, but didn't save the other stuff ).

The script looks like this:
pawn Код:
format(mainstring,sizeof(mainstring),"UPDATE `players` SET 'Logged'=%d,'Admin'=%d,'Money'=%d,'Credit'=%d,'Diamond'=%d,'Level'=%d,'ZLevel'=%d,'PlayHours'=%d,'Rep'=%d,'VIP'=%d,'VIPLevel'=%d,'VIPTime'=%d,'Class'=%d,'IsHuman'=%d,'Faction'=%d,'FactionRank'=%d,'HumanKills'=%d,'ZombieKills'=%d,'Infects'=%d,'Infected'=%d,'InfectionTimer'=%d,'AmpArm'=%d,'AmpLeg'=%d,'WalkStyle'=%d,'FightStyle'=%d,'Skin'=%d WHERE Name = '%s'",
        PlayerInfo[playerid][pLogged],
        PlayerInfo[playerid][pAdmin],
        PlayerInfo[playerid][pMoney],
        PlayerInfo[playerid][pCredit],
        PlayerInfo[playerid][pDiamond],
        PlayerInfo[playerid][pLevel],
        PlayerInfo[playerid][pZLevel],
        PlayerInfo[playerid][pPlayHours],
        PlayerInfo[playerid][pRep],
        PlayerInfo[playerid][pVIP],
        PlayerInfo[playerid][pVIPLevel],
        PlayerInfo[playerid][pVIPTime],
        PlayerInfo[playerid][pClass],
        PlayerInfo[playerid][pIsHuman],
        PlayerInfo[playerid][pFaction],
        PlayerInfo[playerid][pFactionRank],
        PlayerInfo[playerid][pHumanKills],
        PlayerInfo[playerid][pZombieKills],
        PlayerInfo[playerid][pInfects],
        PlayerInfo[playerid][pInfected],
        PlayerInfo[playerid][pInfectionTimer],
        PlayerInfo[playerid][pAmpArm],
        PlayerInfo[playerid][pAmpLeg],
        PlayerInfo[playerid][pWalkStyle],
        GetPlayerFightingStyle(playerid),
        PlayerInfo[playerid][pSkin],
        GetName(playerid));
        mysql_query(mainstring);
If this isn't enough information I can PM you my skype if you can help me out.

Thanks in advance!

EDIT:

Removed the Walk and Fighting style saves, but it still does not work.
Reply
#2

What is the string size? Also i recommend using a newer version of Mysql as this one is deprecated
Reply
#3

Enable debugging:
Код:
mysql_debug(1);
in the top of that script and
Код:
mysql_debug(0);
at the end of it and post the result.
Reply
#4

First why don't you use R31? It's better and faster and as thimo mentioned, this version you are using is deprecated.

Anyway I think i founded your issue. Try to remove the ' ' you got in i.e 'Logged' = %d etc..

pawn Код:
format(mainstring,sizeof(mainstring),"UPDATE `players` SET Logged=%d,Admin=%d,Money=%d,Credit=%d,Diamond=%d,Level=%d,ZLevel=%d,PlayHours=%d,Rep=%d,VIP=%d,VIPLevel=%d,VIPTime=%d,Class=%d,IsHuman=%d,Faction=%d,FactionRank=%d,HumanKills=%d,ZombieKills=%d,Infects=%d,Infected=%d,InfectionTimer=%d,AmpArm=%d,AmpLeg=%d,WalkStyle=%d,FightStyle=%d,Skin=%d WHERE Name = '%s'",
        PlayerInfo[playerid][pLogged],
        PlayerInfo[playerid][pAdmin],
        PlayerInfo[playerid][pMoney],
        PlayerInfo[playerid][pCredit],
        PlayerInfo[playerid][pDiamond],
        PlayerInfo[playerid][pLevel],
        PlayerInfo[playerid][pZLevel],
        PlayerInfo[playerid][pPlayHours],
        PlayerInfo[playerid][pRep],
        PlayerInfo[playerid][pVIP],
        PlayerInfo[playerid][pVIPLevel],
        PlayerInfo[playerid][pVIPTime],
        PlayerInfo[playerid][pClass],
        PlayerInfo[playerid][pIsHuman],
        PlayerInfo[playerid][pFaction],
        PlayerInfo[playerid][pFactionRank],
        PlayerInfo[playerid][pHumanKills],
        PlayerInfo[playerid][pZombieKills],
        PlayerInfo[playerid][pInfects],
        PlayerInfo[playerid][pInfected],
        PlayerInfo[playerid][pInfectionTimer],
        PlayerInfo[playerid][pAmpArm],
        PlayerInfo[playerid][pAmpLeg],
        PlayerInfo[playerid][pWalkStyle],
        GetPlayerFightingStyle(playerid),
        PlayerInfo[playerid][pSkin],
        GetName(playerid));
        mysql_query(mainstring);
Quote:
Originally Posted by SoulRipper113
Посмотреть сообщение
Enable debugging:
Код:
mysql_debug(1);
in the top of that script and
Код:
mysql_debug(0);
at the end of it and post the result.
It's only for lazy people, who don't bother reading the mysql code they scripted.
Reply
#5

new mainstring[3024];

I'm pretty much new when it comes to MYSQL, I know I'm using R5 and there's R7 avaliable, but when I use that it says a bunch of errors which I can't correct because I'm new to it.
Reply
#6

Yes that is because it use different callbacks.
Reply
#7

Quote:
Originally Posted by DRCharlie
Посмотреть сообщение
new mainstring[3024];

I'm pretty much new when it comes to MYSQL, I know I'm using R5 and there's R7 avaliable, but when I use that it says a bunch of errors which I can't correct because I'm new to it.
https://sampforum.blast.hk/showthread.php?tid=337810 This tutorial is very useful, and you can see also the change log of the latest mysql version to see which functions that has been changed and added.
Reply
#8

Quote:
Originally Posted by CrazyChoco
Посмотреть сообщение
First why don't you use R31? It's better and faster and as thimo mentioned, this version you are using is deprecated.

Anyway I think i founded your issue. Try to remove the ' ' you got in i.e 'Logged' = %d etc..

pawn Код:
format(mainstring,sizeof(mainstring),"UPDATE `players` SET Logged=%d,Admin=%d,Money=%d,Credit=%d,Diamond=%d,Level=%d,ZLevel=%d,PlayHours=%d,Rep=%d,VIP=%d,VIPLevel=%d,VIPTime=%d,Class=%d,IsHuman=%d,Faction=%d,FactionRank=%d,HumanKills=%d,ZombieKills=%d,Infects=%d,Infected=%d,InfectionTimer=%d,AmpArm=%d,AmpLeg=%d,WalkStyle=%d,FightStyle=%d,Skin=%d WHERE Name = '%s'",
        PlayerInfo[playerid][pLogged],
        PlayerInfo[playerid][pAdmin],
        PlayerInfo[playerid][pMoney],
        PlayerInfo[playerid][pCredit],
        PlayerInfo[playerid][pDiamond],
        PlayerInfo[playerid][pLevel],
        PlayerInfo[playerid][pZLevel],
        PlayerInfo[playerid][pPlayHours],
        PlayerInfo[playerid][pRep],
        PlayerInfo[playerid][pVIP],
        PlayerInfo[playerid][pVIPLevel],
        PlayerInfo[playerid][pVIPTime],
        PlayerInfo[playerid][pClass],
        PlayerInfo[playerid][pIsHuman],
        PlayerInfo[playerid][pFaction],
        PlayerInfo[playerid][pFactionRank],
        PlayerInfo[playerid][pHumanKills],
        PlayerInfo[playerid][pZombieKills],
        PlayerInfo[playerid][pInfects],
        PlayerInfo[playerid][pInfected],
        PlayerInfo[playerid][pInfectionTimer],
        PlayerInfo[playerid][pAmpArm],
        PlayerInfo[playerid][pAmpLeg],
        PlayerInfo[playerid][pWalkStyle],
        GetPlayerFightingStyle(playerid),
        PlayerInfo[playerid][pSkin],
        GetName(playerid));
        mysql_query(mainstring);


It's only for lazy people, who don't bother reading the mysql code they scripted.
Thank you very much, I pasted your script and it solved the problem. I might post again because I started working with MYSQL yesterday, and updating it might be a pain in the arse for me.

Thank you all for the help!
Reply
#9

Well, if you have skype, you could just add me: Pandi002
I'll be on there for a couple of hours, so i'm free to help you through it from there.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)