08.06.2015, 04:19
PHP код:
enum pdata //players' data
{
IDD,
Name[24],
Money,
Skin,
}
PHP код:
stock SaveStats(playerid)
{
if(LoggedIn[playerid] == 1)
{
new SessionTime = gettime() - Connected[playerid]; //calculate their current session length
pData[playerid][Money] = GetPlayerMoney(playerid);
pData[playerid][Score] = GetPlayerScore(playerid);
mysql_format(ch, query, sizeof(query),
"UPDATE `players` SET ip='%s', level=%d, colour=%d, onlinetime=%d, score=%d, money=%d WHERE id=%d",
pData[playerid][IP], pData[playerid][Level], pData[playerid][Colour], pData[playerid][OnlineTime] + SessionTime,
pData[playerid][Score], pData[playerid][Money], pData[playerid][IDD]);
switch(Disconnecting[playerid])
{
case 0: mysql_pquery(ch, query);
case 1: mysql_pquery(ch, query, "OnStatsSave", "i", playerid);
default: mysql_pquery(ch, query);
}
}
return 1;
}
PHP код:
forward OnStatsSave(playerid);
public OnStatsSave(playerid)
{
pData[playerid][IDD] = 0;
format(pData[playerid][Name], 24, "");
format(pData[playerid][IP], 16, "");
pData[playerid][Level] = 0;
pData[playerid][Money] = 0;
pData[playerid][Skin] = 0;