How can I save stats? -
Fratello - 17.04.2017
Hello, I'm intrested in how to save database/player stats by using a command. I know how it works with if player is conected and for max players but I'm intrested in function.
I'm using mySQL database,
https://github.com/pBlueG/SA-MP-MySQ...stem-cache.pwn
Here is the link, if you want to find more about my data structure.
Re: How can I save stats? -
LazzyBoy - 17.04.2017
can you give some more informations please , like what you mean by saving player stats , like you want a command where you write a name and it will auto update player's status ?
Re: How can I save stats? - Astralis - 17.04.2017
You just give player score, kills, deaths and update each time by running a query to MySQL.
Re: How can I save stats? -
Fratello - 17.04.2017
@LazzyBoy, I want to make a command which can save player's data. (For example: /save mystats). I can work on automatic saves (for example: after 5 minutes database gets updated).
@Astralis Well that is already happening in my script but it doesn't apply to player's data, either MySQL. Here is an example of query update:
Code:
UpdatePlayerKills(killer)
{
// we must check before if the killer wasn't valid (connected) player to avoid run time error 4
if (killerid == INVALID_PLAYER_ID) return 0;
if (Player[killerid][IsLoggedIn] == false) return 0;
Player[killerid][Kills]++;
new query[70];
mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `kills` = %d WHERE `id` = %d LIMIT 1", Player[killerid][Deaths], Player[killerid][ID]);
mysql_tquery(g_SQL, query);
return 1;
}
Hope I explained my needs now.
Re: How can I save stats? -
DarkSkull - 17.04.2017
I don't see what's the problem. You just have to put this in a command
PHP Code:
new query[70];
mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `kills` = %d, `score` = %d WHERE `id` = %d LIMIT 1", Player[playerid][Deaths], Player[playerid][Score], Player[playerid][ID]);
Just put commas and add how many ever stats you want to save.
Re: How can I save stats? -
Fratello - 18.04.2017
@DarkSkull, I thou' about that too last night.
I'll try it. Hope I don't make a spelling error again *hehe*