Is it possible to save Player Health and Armor BEFORE he disconnect ?
#1

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

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

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

BUMP
Reply
#5

Read this , it's very usefull

https://sampforum.blast.hk/showthread.php?tid=132

Good luck
Reply
#6

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

Код:
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.
Reply
#8

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 ?
Reply
#9

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

Then show us your load script.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)