PHP код:
enum pdata //players' data
{
IDD,
Name[24],
IP[16],
Level,
Colour,
RegTime,
OnlineTime,
Score,
Money,
Skin
}
PHP код:
stock SaveStats(playerid)
{
if(LoggedIn[playerid] == 1)
{
new SessionTime = gettime() - Connected[playerid]; //calculate their current session length
pData[playerid][Money] = GetPlayerCash(playerid);
pData[playerid][Score] = GetPlayerScore(playerid);
pData[playerid][Skin] = GetPlayerSkin(playerid);
mysql_format(ch, query, sizeof(query),
"UPDATE `players` SET ip='%s', level=%d, colour=%d, onlinetime=%d, score=%d, money=%d, skin=%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][Skin], 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;
}
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][Colour] = -1;
pData[playerid][RegTime] = 0;
pData[playerid][OnlineTime] = 0;
pData[playerid][Score] = 0;
pData[playerid][Money] = 0;
pData[playerid][Skin] = 0;
Connected[playerid] = -1;
LoggedIn[playerid] = 0;
PasswordAttempts[playerid] = 0;
Disconnecting[playerid] = -1;
return 1;
}
PHP код:
stock LogPlayerIn(playerid)
{
cache_get_row(0, 0, strr); pData[playerid][IDD] = strval(strr); //Load player's stats from the database
cache_get_row(0, 4, strr); pData[playerid][Level] = strval(strr);
cache_get_row(0, 5, strr); pData[playerid][Colour] = strval(strr);
cache_get_row(0, 6, strr); pData[playerid][RegTime] = strval(strr);
cache_get_row(0, 7, strr); pData[playerid][OnlineTime] = strval(strr);
cache_get_row(0, 8, strr); pData[playerid][Score] = strval(strr);
cache_get_row(0, 9, strr); pData[playerid][Money] = strval(strr);
cache_get_row(0, 10, strr); pData[playerid][Skin] = strval(strr);
PHP код:
public OnPlayerSpawn(playerid)
{
if(LoggedIn[playerid] == 0) return 0;
if(LoggedIn[playerid] == 1)
{
SetPlayerCash(playerid, pData[playerid][Money]);
SetPlayerScore(playerid, pData[playerid][Score]);
SetPlayerSkin(playerid, pData[playerid][Skin];
}
return 1;
}
Whenever i add "SetPlayerSkin(playerid, pData[playerid][Skin];" so it spawns with CJ SKIN.