25.12.2013, 01:22
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
if(is_logged[playerid] == true)
{
new
mQuery[128];
new
pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(mQuery, sizeof(mQuery), "SELECT `id` from `accounts` WHERE `username` = '%s'", pName);
mysql_function_query(myConnection, mQuery, true, "SavePlayerData", "i", playerid);
}
return 1;
}
pawn Code:
forward public SavePlayerData(playerid);
public SavePlayerData(playerid)
{
new
mQuery[500];
new
chr,
cyr,
cday,
cmo,
cmin,
csec;
getdate(cyr, cmo, cday);
gettime(chr, cmin, csec);
format(mQuery, sizeof(mQuery), "UPDATE `accounts` SET `Admin` = '%d', `CustomSkin` = '%d', `ActiveBuff` = '%d', `Killstreak` = '%d', `LastVisitedMonth` = '%d', `LastVisitedDay` = '%d', `LastVisitedYear` = '%d', `LastVisitedHour` = '%d', `LastVisitedMinute` = '%d'",
PlayerInfo[playerid][Admin], PlayerInfo[playerid][CustomSkin], PlayerInfo[playerid][ActiveBuff],
PlayerInfo[playerid][Killstreak], cmo, cday, cyr, chr, cmin
);
mysql_function_query(myConnection, mQuery, false, "", "");
for(new i; i < 13; i++)
{
format(mQuery, sizeof(mQuery), "UPDATE `weapons` SET `weapon` = '%d', `ammo` = '%d' WHERE `id` = '%d' AND `index` = '%d'",
PlayerInfo[playerid][SpawnWeapon][i], PlayerInfo[playerid][SpawnAmmo][i], PlayerInfo[playerid][pAccountID], i
);
mysql_function_query(myConnection, mQuery, false, "", "");
}
for(new i; i < 46; i++)
{
format(mQuery, sizeof(mQuery), "UPDATE `weaponkills` SET `weapon` = '%d', `kills` = '%d' WHERE `id` = '%d'",
i, PlayerInfo[playerid][WeaponKills][i], PlayerInfo[playerid][pAccountID]
);
mysql_function_query(myConnection, mQuery, false, "", "");
}
is_logged[playerid] = false;
return 1;
}