open.mp forum
[Pawn] How to save player stats in mysql? - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] How to save player stats in mysql? (/showthread.php?tid=2116)



How to save player stats in mysql? - CrypticSin - 2021-06-16

Hi, i need help with saving player stats like kills, deaths, health etc in mysql.



I've created columns for them on php myadmin using xampp?but i dont know how to input them into code on Pawn.



Any help would be appreciated.


RE: How to save player stats in mysql? - Kwarde - 2021-06-16

You'll need a MySQL plugin to do that. https://github.com/pBlueG/SA-MP-MySQL/ - That repository comes with a wiki with all it's functions, consult it if you have any questions about the functions.



In case you need examples, there are alot (alot alot) of scripts using MySQL. Here're two examples (note that those aren't perfect examples but atleast it's something).



https://github.com/MichaelBelgium/MV_cPanel

https://github.com/zeelorenc/sf-cnr


RE: How to save player stats in mysql? - PutuSuhartawan - 2021-06-19

stats with coordinate? https://www.youtube.com/watch?v=KNj2O6c9-uo


RE: How to save player stats in mysql? - CrypticSin - 2021-06-19

(2021-06-19, 01:09 AM)PutuSuhartawan Wrote: stats with coordinate? https://www.youtube.com/watch?v=KNj2O6c9-uo



The only thing i've done so far is creating a stock for saving user stats.?



I don't know what to do from this point after as it's still not storing the data in mysql (phpmyadmin)



When i run the code, im not getting any errors on but im getting two warning stating: "number of arguments does not match definition"



PHP Code:
stock SaveUserStats(playerid)

{



new 
Float:x,Float:y,Float:z;

GetPlayerPos(playerid,Float:x,Float:y,Float:z);



if(
PlayerInfo[playerid][pLoggedIn] == true)

{

PlayerInfo[playerid][pX] = x;

PlayerInfo[playerid][pY] = y;

PlayerInfo[playerid][pZ] = z;

}



new 
query[256];

strcat(query"UPDATE `playerinfo` SET `skin` = '%d', `score` = '%d', `money` = '%d', `murders` = '%d', `zombieskilled` = '%d', `health` = '%d', `armour` = '%d',`deaths` = '%d', `hunger` = '%d', `thirst` = '%d', `pX` = '%i', `pY` = '%i', `pZ` = '%i',? WHERE 'acc_name' = '%e'");

format(querysizeof(query), queryPlayerInfo[playerid][pSkin],

PlayerInfo[playerid][pScore],

PlayerInfo[playerid][pMoney],

PlayerInfo[playerid][pKills],

PlayerInfo[playerid][pZombiesKilled],

PlayerInfo[playerid][pHealth],

PlayerInfo[playerid][pArmour],

PlayerInfo[playerid][pDeaths],

PlayerInfo[playerid][pHunger],

PlayerInfo[playerid][pX],

PlayerInfo[playerid][pY],

PlayerInfo[playerid][pZ],

GetPlayerName(playerid));

mysql_tquery(handlequery"""");

printf("%s"query);

return 
1;