Код:
static DisconnectState[MAX_PLAYERS char];
public OnPlayerDisconnect(playerid, reason)
{
if(!DisconnectState{playerid}) Kick(playerid), DisconnectState{playerid} = 1;
else DisconnectState{playerid} = 0;
pTemp[playerid][pWorkSalary] = 0;
if(plInRace[playerid] != 999)
{
plInRace[playerid] = 999;
playersOnRace--;
DestroyVehicle(raceVehicle[playerid]);
}
DeletePVar(playerid, "code");
pTemp[playerid][pLogin4] = true;
poxavat[playerid] = 0;
DestroyObject(object[playerid]);
Delete3DTextLabel(Text3D:blocktext[playerid]);
DeletePVar(playerid,"nnick");
admloged[playerid] = 0;
if(GetPVarInt(playerid, "ArendKey") != -1)
{
new v = GetPVarInt(playerid, "ArendKey");
if(ArendInfo[v][aPlayerID] == playerid)
{
ArendInfo[v][aPlayerID] = INVALID_PLAYER_ID;
SetVehicleToRespawnEx(ArendInfo[v][aID]);
}
}
if(GetPVarInt(playerid, "DrugsPlayerVeh") - 2 == MaxMafiaDrugs[GetPVarInt(playerid, "MafiaDrugsPlace")])
{
new slot = GetPVarInt(playerid, "MafiaDrugsPlace");
DeletePVar(playerid, "DrugsPlayerVeh");
DeletePVar(playerid, "DrugsPlayerID");
DeletePVar(playerid, "MafiaDrugsPlace");
MaxMafiaDrugs[slot] = -1;
for(new p = 0; p < 5; p++) MafiaDrugs[slot][p] = false;
for(new p = 0; p < GetMaxPlayers(); p++)
{
if(!IsPlayerConnected(p) || p == playerid) continue;
if(GetPVarInt(p, "DrugsPlayerVeh") > 0 && pData[p][pFraction] == pData[playerid][pFraction])
{
DeletePVar(p, "DrugsPlayerVeh");
DeletePVar(p, "DrugsPlayerID");
}
}
}
//Защита от реконекта
new slot;
for(new i;i<MAX_PLAYERS;i++)
{
if(!gReconnectTime[i]) {slot = i; break;}
}
format(gReconnectIP[slot],32,"%s",pTemp[playerid][pIP]);
gReconnectTime[slot] = 5;
if(GetPVarInt(playerid,"pgunobject"))
{
new objectid = GetPVarInt(playerid,"pgunobject");
if(IsValidDynamicObject(objectid)) DestroyDynamicObject(objectid);
}
if(pData[playerid][pJob] == 1 && pTemp[playerid][pBusID] != INVALID_VEHICLE_ID)
{
SetVehicleToRespawnEx(pTemp[playerid][pBusID]);
}
if(pData[playerid][pJob] == 6 && pTemp[playerid][pTruckID] != INVALID_VEHICLE_ID)
{
SetVehicleToRespawn(pTemp[playerid][pTruckID]);
if(IsValid3DTextLabel(pTemp[playerid][pTruckWagonText])) DestroyDynamic3DTextLabel(pTemp[playerid][pTruckWagonText]);
pTemp[playerid][pTruckID] = INVALID_VEHICLE_ID;
if(pTemp[playerid][pTruckWagonID] != INVALID_VEHICLE_ID)
{
fuelOrders++;
zFuelUpdate();
SetVehicleToRespawn(pTemp[playerid][pTruckWagonID]);
pTemp[playerid][pTruckWagonID] = INVALID_VEHICLE_ID;
}
}
if(pData[playerid][pJob] == 2 && pTemp[playerid][pTruckID] != INVALID_VEHICLE_ID)
{
SetVehicleToRespawnEx(pTemp[playerid][pTruckID]);
if(IsValid3DTextLabel(pTemp[playerid][pTruckWagonText])) DestroyDynamic3DTextLabel(pTemp[playerid][pTruckWagonText]);
pTemp[playerid][pTruckID] = INVALID_VEHICLE_ID;
if(pTemp[playerid][pTruckWagonID] != INVALID_VEHICLE_ID)
{
DestroyVehicle(pTemp[playerid][pTruckWagonID]);
pTemp[playerid][pTruckWagonID] = INVALID_VEHICLE_ID;
}
for(new i2;i2<2;i2++)
{
for(new i;i<10;i++)
{
if(gTruckLoadTurn[i2][i] == playerid || gTruckLoadTurn[i2][i] == playerid) gTruckLoadTurn[i2][i] = INVALID_PLAYER_ID;
}
}
}
if(pData[playerid][pJob] == 3 && pTemp[playerid][pTaxiID] != INVALID_VEHICLE_ID)
{
SetVehicleToRespawnEx(pTemp[playerid][pTaxiID]);
if(IsValid3DTextLabel(pTemp[playerid][pTaxi3DText])) DestroyDynamic3DTextLabelEx(pTemp[playerid][pTaxi3DText]);
}
if(GetPVarInt(playerid,"pgunlocat"))
{
new locat = GetPVarInt(playerid,"pgunlocat") - 1;
gGunWorkTableStat[locat] = false;
}
if(pTemp[playerid][pCuffee] != INVALID_PLAYER_ID)
{
new id = pTemp[playerid][pCuffee];
if(id == playerid)
{
new cuffer = pTemp[playerid][pCuffer];
new mes[128];
format(mes,sizeof(mes),"Арестованный {"#cWHITE"}%s {"#cINFO"}вышел из игры",pData[playerid][pNickname]);
SendClientMessage(cuffer,CINFO,mes);
pTemp[cuffer][pCuffer] = INVALID_PLAYER_ID;
pTemp[cuffer][pCuffee] = INVALID_PLAYER_ID;
pTemp[playerid][pCuffee] = INVALID_PLAYER_ID;
pTemp[playerid][pCuffer] = INVALID_PLAYER_ID;
}
else if(IsPlayerConnected(id))
{
SetPlayerSpecialAction(id,SPECIAL_ACTION_NONE);
RemovePlayerAttachedObject(id,0);
pTemp[id][pCuffer] = INVALID_PLAYER_ID;
pTemp[id][pCuffee] = INVALID_PLAYER_ID;
pTemp[playerid][pCuffee] = INVALID_PLAYER_ID;
pTemp[playerid][pCuffer] = INVALID_PLAYER_ID;
SendClientMessage(playerid,CGREEN,"Офицер, надевший на вас наручники, вышел из игры. Наручники сняты");
}
}
if(gCalls[playerid][g_caller] == playerid || gCalls[playerid][g_callee] == playerid)
{
new id;
if(gCalls[playerid][g_caller] == playerid) id = gCalls[playerid][g_callee];
else if(gCalls[playerid][g_callee] == playerid) id = gCalls[playerid][g_caller];
else return SendClientMessage(playerid,CGRAY,"Ошибка (#112)");
SendClientMessage(id,CYELLOW,"Собеседник вышел из игры");
SetPlayerSpecialAction(id,SPECIAL_ACTION_STOPUSECELLPHONE);
SetTimerEx("ClearPhone",2000,false,"i",id);
gCalls[playerid][g_caller] = INVALID_PLAYER_ID;
gCalls[playerid][g_callee] = INVALID_PLAYER_ID;
gCalls[id][g_caller] = INVALID_PLAYER_ID;
gCalls[id][g_callee] = INVALID_PLAYER_ID;
pTemp[playerid][pCall] = false;
pTemp[id][pCall] = false;
}
if(pTemp[playerid][pDFTID] != INVALID_VEHICLE_ID) SetVehicleToRespawnEx(pTemp[playerid][pDFTID]);
for(new i; i<3; i++) {
if(gNewsDialee[i] == playerid)
{
gNewsDialee[i] = INVALID_PLAYER_ID;
SendClientMessage(gNewsDialer[i], CSYSTEM, "Игрок вышел из игры");
}
if(gNewsDialer[i] == playerid) OnPlayerCommandText(playerid, "/stopdial");
}
if(pTemp[playerid][pExamCandidate] != INVALID_PLAYER_ID)
{
new actplayerid = pTemp[playerid][pExamCandidate];
if(IsPlayerConnected(actplayerid) && pTemp[actplayerid][pOnExam])
{
SendClientMessage(actplayerid,CGRAY,"Ваш инструктор вышел из игры, экзамен прерван");
RemovePlayerFromVehicle(actplayerid);
pTemp[actplayerid][pOnExam] = false;
}
}
new h,m,s;
gettime(h,m,s);
RemovePlayerFromWantedList(playerid);
new gunids[56],ammos[56],cnt,pgun[128];
for (new i;i<13;i++)
{
new weapid,ammo;
GetPlayerWeaponData(playerid,i,weapid,ammo);
if(weapid && ammo && gGuns[playerid][i] == weapid && gAmmos[playerid][i] <= ammo)
{
if(!cnt)
{
format(gunids,sizeof(gunids),"%d",gGuns[playerid][i]);
format(ammos,sizeof(ammos),"%d",gAmmos[playerid][i]);
}
else
{
format(gunids,sizeof(gunids),"%s|%d",gunids,gGuns[playerid][i]);
format(ammos,sizeof(ammos),"%s|%d",ammos,gAmmos[playerid][i]);
}
cnt++;
if(cnt >= 6) break;
}
}
if(!pTemp[playerid][pLogined] || !pTemp[playerid][pJoined]) return 1;
if(strlen(gunids) && strlen(ammos)) format(pgun,sizeof(pgun),"%s:%s",gunids,ammos);
new query[532];
format(pData[playerid][pSkills],80,"%d,%d,%d,%d,%d,%d",
pTemp[playerid][pGunSkill][0],pTemp[playerid][pGunSkill][1],pTemp[playerid][pGunSkill][2],
pTemp[playerid][pGunSkill][3],pTemp[playerid][pGunSkill][4],pTemp[playerid][pGunSkill][5]);
format(query,sizeof(query),"UPDATE `accounts` SET `skills`='%s',`health` = '%.2f',`money` = %d,`jail`='%d',`gun`='%s',`otigral`='%d',`status`='0' WHERE `nickname`='%s'", pData[playerid][pSkills], pData[playerid][pHealth],pData[playerid][pMoney],pData[playerid][pJail], pgun, pTemp[playerid][pGiveExp], pData[playerid][pNickname]);
sql_query(zConn, query, QUERY_THREADED);
SetPlayerDataToDefault(playerid);
return 1;
}