new LoginTimer[MAX_PLAYERS];
new PlayerAFK[MAX_PLAYERS];
enum pInfo
{
pID,
pLogged,
pAdmin,
pKills,
pDeaths,
pInAdmCar,
pSecondTimer,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
stock pName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
public OnPlayerDisconnect(playerid, reason)
{
KillTimer(LoginTimer[playerid]);
printf("["SERVER_NAME3"] Таймер №%d удален у игрока %s[%d]", PlayerInfo[playerid][pSecondTimer], pName(playerid), playerid);
KillTimer(PlayerInfo[playerid][pSecondTimer]);
UnLoadTextDraws(playerid);
if(PlayerInfo[playerid][pLogged])
{
if(PlayerInfo[playerid][pAdmin] > 0) Iter_Remove(Admins_ITER, playerid);
static const fmt_query[] = "UPDATE `accounts` SET `pKills` = '%d', `pDeaths` = '%d' WHERE `pID` = '%d'";
new query[sizeof(fmt_query)+(-2+16)+(-2+16)+(-2+8)];
mysql_format(dbHandle, query, sizeof(query), fmt_query,
PlayerInfo[playerid][pKills],
PlayerInfo[playerid][pDeaths],
PlayerInfo[playerid][pID]);
mysql_tquery(dbHandle, query);
PlayerInfo[playerid][pLogged] = false;
}
if(PlayerInfo[playerid][pInAdmCar] != -1)
{
DestroyVehicle(PlayerInfo[playerid][pInAdmCar]);
PlayerInfo[playerid][pInAdmCar] = -1;
}
return true;
}
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerAFK[playerid] = -2;
PlayerInfo[playerid][pDeaths]++;
if(killerid != INVALID_PLAYER_ID)
{
PlayerInfo[killerid][pKills]++;
SetPlayerScore(killerid, PlayerInfo[killerid][pKills]);
SetPlayerHealth(killerid, 160);
SetPlayerArmour(killerid, 100);
}
return true;
}
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][pKills] = 0;
PlayerInfo[playerid][pDeaths] = 0;
return true;
}
LoadPlayerData(playerid)
{
new query[128];
mysql_format(dbHandle, query, sizeof(query), "SELECT * FROM `accounts` WHERE `pID` = '%d'", PlayerInfo[playerid][pID]);
mysql_tquery(dbHandle, query, "OnPlayerDataLoaded", "i", playerid);
}
public OnPlayerDataLoaded(playerid)
{
cache_get_value_name_int(0, "pKills", PlayerInfo[playerid][pKills]);
cache_get_value_name_int(0, "pDeaths", PlayerInfo[playerid][pDeaths]);
}
На
Рабочая версия, тут только добавление киллов
public OnPlayerDisconnect(playerid, reason)
{
KillTimer(LoginTimer[playerid]);
printf("["SERVER_NAME3"] Òàéìåð ¹%d óäàëåí ó èãðîêà %s[%d]", PlayerInfo[playerid][pSecondTimer], pName(playerid), playerid);
KillTimer(PlayerInfo[playerid][pSecondTimer]);
UnLoadTextDraws(playerid);
if(PlayerInfo[playerid][pLogged])
{
if(PlayerInfo[playerid][pAdmin] > 0) Iter_Remove(Admins_ITER, playerid);
static const fmt_query[] = "UPDATE `accounts` SET `pKills` = '%d' WHERE `pID` = '%d'";
new query[sizeof(fmt_query)+(-2+16)+(-2+8)];
mysql_format(dbHandle, query, sizeof(query), fmt_query, PlayerInfo[playerid][pKills], PlayerInfo[playerid][pID]);
mysql_tquery(dbHandle, query);
PlayerInfo[playerid][pLogged] = false;
}
if(PlayerInfo[playerid][pInAdmCar] != -1)
{
DestroyVehicle(PlayerInfo[playerid][pInAdmCar]);
PlayerInfo[playerid][pInAdmCar] = -1;
}
return true;
}
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerAFK[playerid] = -2;
if(killerid != INVALID_PLAYER_ID)
{
if (killerid != INVALID_PLAYER_ID)
{
PlayerInfo[killerid][pKills]++;
SetPlayerScore(killerid, PlayerInfo[killerid][pKills]);
}
}
if (killerid != INVALID_PLAYER_ID) SetPlayerHealth(killerid,160);
if (killerid != INVALID_PLAYER_ID) SetPlayerArmour(killerid,100);
return true;
}
Вот какую ошибку выдаёт в serverlog если пытаюсь вписать смерти
[23:36:14] [MySQL] Text: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `pID` = '15'' at line 1
[23:36:14] [MySQL] Callback:
[23:36:14] [MySQL] Query: INSERT INTO accounts SET `pKills` = '0', `pDeaths` = '0' WHERE `pID` = '15'
[23:36:14] [MySQL] Error: 1064 ID