Is it possible to save Player Health and Armor BEFORE he disconnect ? -
anou1 - 24.01.2014
Hi
My question is in the title
I did this:
Код:
public OnPlayerDisconnect(playerid, reason)
{
new query[512];
new Float:vie[1], Float:armure[1];
GetPlayerHealth(playerid, vie[0]);
GetPlayerArmour(playerid, armure[0]);
mysql_format(mysql, query, sizeof(query), "UPDATE `joueurs` SET `Vie`=%f, `Armure`=%f WHERE `ID`=%d", vie[0], armure[0], pInfo[playerid][ID]);
mysql_tquery(mysql, query, "", "");
return 1;
}
But it always save life/armor to 0.
Re: Is it possible to save Player Health and Armor BEFORE he disconnect ? -
Weponz - 24.01.2014
Its possible try changing to this:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new query[512];
new Float:vie, Float:armure;
GetPlayerHealth(playerid, vie);
GetPlayerArmour(playerid, armure);
mysql_format(mysql, query, sizeof(query), "UPDATE `joueurs` SET `Vie`=%f, `Armure`=%f WHERE `ID`=%d", vie, armure, pInfo[playerid][ID]);
mysql_tquery(mysql, query, "", "");
return 1;
}
EDIT: And make sure mysql_tquery is an actual function.
Re : Is it possible to save Player Health and Armor BEFORE he disconnect ? -
anou1 - 24.01.2014
Thank you, I tried it, but it doesn't work. What's wrong with this please :
Код:
public OnAccountLoad(playerid)
{
pInfo[playerid][Vie] = cache_get_row_float(0, 18);
pInfo[playerid][Armure] = cache_get_row_float(0, 19);
printf("%f %f", pInfo[playerid][Vie], pInfo[playerid][Armure]);
return 1;
}
Код:
public OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid, pInfo[playerid][Vie]);
SetPlayerArmour(playerid, pInfo[playerid][Armure]);
return 1;
}
Код:
public OnPlayerDisconnect(playerid, reason)
{
new query[512];
new Float:vie, Float:armure;
GetPlayerHealth(playerid, vie);
GetPlayerArmour(playerid, armure);
mysql_format(mysql, query, sizeof(query), "UPDATE `joueurs` SET `Vie`=%f, `Armure`=%f WHERE `ID`=%d", vie, armure, pInfo[playerid][ID]);
mysql_tquery(mysql, query, "", "");
printf("%f %f", vie, armure);
return 1;
}
For every printf I still have 0 as life/armor.
Could you help me with this please ?
Thank you.
Re : Is it possible to save Player Health and Armor BEFORE he disconnect ? -
anou1 - 25.01.2014
BUMP
Re : Is it possible to save Player Health and Armor BEFORE he disconnect ? -
MCZOFT - 25.01.2014
Read this , it's very usefull
https://sampforum.blast.hk/showthread.php?tid=132
Good luck
Re : Is it possible to save Player Health and Armor BEFORE he disconnect ? -
anou1 - 25.01.2014
Thank you,
But I don't want to only Copy/Paste or something like that.
I want to learn and know why my code isn't working :/
Somebody have an idea to solve it ?
Thank you !
Re: Is it possible to save Player Health and Armor BEFORE he disconnect ? -
Shetch - 25.01.2014
Код:
public OnPlayerDisconnect(playerid, reason)
{
new query[512];
new Float:vie, Float:armure;
GetPlayerHealth(playerid, vie);
GetPlayerArmour(playerid, armure);
mysql_format(mysql, query, sizeof(query), "UPDATE `joueurs` SET `Vie` = '%f', `Armure` = '%f' WHERE `ID` = '%d'", vie, armure, pInfo[playerid][ID]);
mysql_query(mysql, query);
return 1;
}
If this doesn't work, then show us your database structurte.
Re : Is it possible to save Player Health and Armor BEFORE he disconnect ? -
MCZOFT - 25.01.2014
it's not copy and past , you learning by tutorial, anyway it's your idea ,
okey , did you add the columns of saving stats in your MYSQL datebase ?
Re : Is it possible to save Player Health and Armor BEFORE he disconnect ? -
anou1 - 25.01.2014
Pastbin:
http://pastebin.com/0DLjmcwU
mysql:
http://www.noelshack.com/2014-04-1390652318-mysql.png
in OnAccountLoad, when it loads player informations. With printf it shows my that player life/armor is 0.0 even when it's 100.0 on the database before I start the server.
Thank you
Re: Is it possible to save Player Health and Armor BEFORE he disconnect ? -
Shetch - 25.01.2014
Then show us your load script.