Wanted level saving to database.
#1

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, "", "");
}
Reply
#2

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.
Reply
#3

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);
}
Reply
#4

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

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
Reply
#6

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

Seems like you need to increase it even further.
Reply
#8

Yeah the size is still too small. Try 256.
Reply
#9

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

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

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


Forum Jump:


Users browsing this thread: 4 Guest(s)