SA-MP Forums Archive
Wanted level saving to database. - 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: Wanted level saving to database. (/showthread.php?tid=594899)



Wanted level saving to database. - yvoms - 25.11.2015

Greetings samp community.
Im trying to save wanted level to my database, so players regain it when they reconnect.

However my question is.
is this a correct stock?

Код:
stock SavePlayerData(playerid)
{
        new query[100];
        mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `IP`='%s', `Admin`=%d, `VIP`=%d, `Kills`=%d, `Deaths`=%d, `Score`=%d, `Wanted`=%d, `Money`=%d WHERE `ID`=%d",\
        IP[playerid], pData[playerid][Admin], pData[playerid][VIP], pData[playerid][Kills], pData[playerid][Deaths], GetPlayerScore(playerid), GetPlayerWantedLevel(playerid), pData[playerid][Money], pData[playerid][ID]);
        mysql_tquery(mysql, query, "", "");
}



Re: Wanted level saving to database. - RedCounty - 25.11.2015

It is, though you need to rectify "new query[100];" to a higher value, as your current query withholds more than 100 characters.

Set it to 256 just to be on the safe side.


Re: Wanted level saving to database. - MartinSwag - 25.11.2015

What's the '\' for after `ID` = %d"?

Код:
stock SavePlayerData(playerid)
{
        new query[256];
        mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `IP`='%s', `Admin`=%d, `VIP`=%d, `Kills`=%d, `Deaths`=%d, `Score`=%d, `Wanted`=%d, `Money`=%d WHERE `ID`=%d",
        IP[playerid], pData[playerid][Admin], pData[playerid][VIP], pData[playerid][Kills], pData[playerid][Deaths], GetPlayerScore(playerid), GetPlayerWantedLevel(playerid), pData[playerid][Money], pData[playerid][ID]);
        mysql_tquery(mysql, query);
}



Re: Wanted level saving to database. - Dokins - 25.11.2015

I would increase the query size, but apart from that it seems alright.


Re: Wanted level saving to database. - yvoms - 25.11.2015

Quote:
Originally Posted by MartinSwag
Посмотреть сообщение
What's the '\' for after `ID` = %d"?

Код:
stock SavePlayerData(playerid)
{
        new query[256];
        mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `IP`='%s', `Admin`=%d, `VIP`=%d, `Kills`=%d, `Deaths`=%d, `Score`=%d, `Wanted`=%d, `Money`=%d WHERE `ID`=%d",
        IP[playerid], pData[playerid][Admin], pData[playerid][VIP], pData[playerid][Kills], pData[playerid][Deaths], GetPlayerScore(playerid), GetPlayerWantedLevel(playerid), pData[playerid][Money], pData[playerid][ID]);
        mysql_tquery(mysql, query);
}
A typo lol, allright guys ill set the query size a bit higher


Re: Wanted level saving to database. - yvoms - 25.11.2015

What could this mean?
[04:06:50] [ERROR] mysql_format - destination size is too small


Re: Wanted level saving to database. - CmZxC - 25.11.2015

Seems like you need to increase it even further.


Re: Wanted level saving to database. - MartinSwag - 25.11.2015

Yeah the size is still too small. Try 256.


Re: Wanted level saving to database. - yvoms - 25.11.2015

I set it to 256, maybe i need to set it even bigger?


Re: Wanted level saving to database. - CmZxC - 25.11.2015

What is the string size for "IP[playerid]"?

Also yes, you can set it bigger. I've seen queries with 512 size.