public OnPlayerDisconnect(playerid, reason) { SetPlayerColor(playerid, 0xFFFFFFFF); if(playerData[playerid][playerLoggedIn]) { savePlayerStats(playerid); } if(reason == 1) // Manual game-quit. { new administratorAlert[128]; if(playerData[playerid][playerIsTazed]) { format(administratorAlert, sizeof(administratorAlert), "{C73E3E}[AVOID-DETECTION] {FFFFFF}%s(%i) quit the game while tazed.", playerData[playerid][playerNamee], playerid); adminchat(COLOR_WHITE, administratorAlert); } else if(playerData[playerid][playerIsCuffed]) { format(administratorAlert, sizeof(administratorAlert), "{C73E3E}[AVOID-DETECTION] {FFFFFF}%s(%i) quit the game while cuffed.", playerData[playerid][playerNamee], playerid); adminchat(COLOR_WHITE, administratorAlert); } else if(playerData[playerid][playerIsTied]) { format(administratorAlert, sizeof(administratorAlert), "{C73E3E}[AVOID-DETECTION] {FFFFFF}%s(%i) quit the game while tied.", playerData[playerid][playerNamee], playerid); adminchat(COLOR_WHITE, administratorAlert); } } if(playerData[playerid][playerGangID] != INVALID_GANG_ID) { cmd_g(playerid, "leave"); } ClearStats(playerid); removePlayerRoadblocks(playerid); destroyPlayersExplosives(playerid); // Delete labels Delete3DTextLabel(playerData[playerid][playerAdminLabel]); // Destroy timers KillTimer(playerData[playerid][unfreezeTimer]); KillTimer(playerData[playerid][arrestTimer]); KillTimer(playerData[playerid][untieTimer]); KillTimer(playerData[playerid][uncuffTimer]); KillTimer(playerData[playerid][recuffTimer]); KillTimer(playerData[playerid][retazeTimer]); KillTimer(playerData[playerid][fixTimer]); KillTimer(playerData[playerid][nosTimer]); KillTimer(playerData[playerid][mechREMPTimer]); KillTimer(playerData[playerid][reactivateRapeStatus]); KillTimer(playerData[playerid][reactivateRobStatus]); KillTimer(playerData[playerid][hcpTimer]); KillTimer(playerData[playerid][courierTimer]); KillTimer(playerData[playerid][playerCanKidnap]); KillTimer(playerData[playerid][rapedTimer]); KillTimer(playerData[playerid][jailTimer]); KillTimer(playerData[playerid][spawnPlayerTimer]); KillTimer(playerData[playerid][truckExitTimer]); KillTimer(playerData[playerid][breakCuffsTimer]); KillTimer(playerData[playerid][achieveTimer]); KillTimer(playerData[playerid][spamTimer]); KillTimer(playerData[playerid][CheckSpeed]); KillTimer(playerData[playerid][retruckTimer]); KillTimer(playerData[playerid][saveStatsTimer]); KillTimer(playerData[playerid][rehealTimer]); KillTimer(playerData[playerid][recureTimer]); KillTimer(playerData[playerid][breakinTimer]); KillTimer(playerData[playerid][houseTimer]); playerData[playerid][shotTime] = 0; playerData[playerid][shot] = 0; playerData[playerid][shotWarnings] = 0; // Reset weapons for next player ResetPlayerWeapons(playerid); SendDeathMessage(INVALID_PLAYER_ID, playerid, 201); // Vehicles /*for(new v = 0; v < MAX_SCRIPT_VEHICLES; v++) { if (oVehicle[v][vehicle_id] != -1) { if(!strcmp(oVehicle[v][vehicle_owner], playerData[playerid][playerNamee], true)) { DestroyVehicle(oVehicle[v][vehicle_sid]); } } }*/ for(new i; i < MAX_SAVED_VEHICLES; i++) { if(VehicleInfo[i][vOwner] != playerData[playerid][actualID]) continue; DestroyVehicle(VehicleInfo[i][vehicleID]); VehicleInfo[i][vehicleID] = INVALID_VEHICLE_ID; } return 1; }
savePlayerStats(playerid);
ClearStats(playerid); Show both these function code. |
That both function code is already defined.
See the code of ShowPlayerDisconnect |
public saveStats() { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && playerData[i][playerLoggedIn]) { savePlayerStats(i); } } }
stock ClearStats(playerid) { if (playerData[playerid][playerLoggedIn]) { forceRobberyCancel(playerid); // Reset main stats playerData[playerid][playerLevel] = 0; playerData[playerid][playerMoney] = 0; playerData[playerid][playerBank] = 0; playerData[playerid][playerScore] = 0; playerData[playerid][playerXP] = 0; playerData[playerid][playerIP] = 0; playerData[playerid][playerInterior] = 0; playerData[playerid][playerVWorld] = 0; playerData[playerid][playerJailTime] = 0; playerData[playerid][playerMuteTime] = 0; playerData[playerid][playerCheckpointTime] = 0; playerData[playerid][playerRobTime] = 0; playerData[playerid][playerSafeObj] = 0; playerData[playerid][playerClass] = 0; playerData[playerid][playerWantedLevel] = 0; playerData[playerid][playerVIPLevel] = 0; playerData[playerid][playerRope] = 0; playerData[playerid][playerJailKit] = 0; playerData[playerid][playerScissors] = 0; playerData[playerid][playerButtPlug] = 0; playerData[playerid][playerBiggerPockets] = 0; playerData[playerid][playerSecureWallet] = 0; playerData[playerid][playerCourierLevel] = 0; playerData[playerid][playerBanned] = 0; playerData[playerid][playerLastVehicleID] = 0; playerData[playerid][playerWarnings] = 0; playerData[playerid][playerHelper] = 0; playerData[playerid][playerWeed] = 0; playerData[playerid][playerExplosives] = 0; playerData[playerid][vipWeapon] = 0; playerData[playerid][innocentKills] = 0; playerData[playerid][aInnocentKills] = 0; playerData[playerid][healthInsurance] = 0; // Reset stats playerData[playerid][playerKills] = 0; playerData[playerid][playerDeaths] = 0; playerData[playerid][playerRobberies] = 0; playerData[playerid][playerTimesJailed] = 0; playerData[playerid][copArrests] = 0; playerData[playerid][rulesRead] = 0; playerData[playerid][streetRobberies] = 0; playerData[playerid][streetRapes] = 0; playerData[playerid][playersTied] = 0; playerData[playerid][playersKidnapped] = 0; playerData[playerid][copDetains] = 0; playerData[playerid][copKills] = 0; playerData[playerid][forkliftCompleted] = 0; playerData[playerid][bankRobs] = 0; playerData[playerid][bombsDefused] = 0; // Reset Jobs playerData[playerid][lastCarDrop] = -1; playerData[playerid][playerJob] = -1; // Reset ID systems playerData[playerid][playerLastTicket] = -1; playerData[playerid][playerBailTo] = -1; playerData[playerid][playerBailPrice] = -1; playerData[playerid][playerAdminJailed] = -1; playerData[playerid][playerGunOffer] = -1; playerData[playerid][playerGunDealer] = -1; playerData[playerid][playerHousePass] = -1; playerData[playerid][lastRecipient] = -1; playerData[playerid][playerCustomSkin] = -1; playerData[playerid][vehicleMenu] = -1; playerData[playerid][playerStoreID] = 0; playerData[playerid][playerCheckID] = 0; playerData[playerid][playerInsideHouse] = 0; playerData[playerid][playerInsideBusiness] = 0; playerData[playerid][adDetected] = 0; playerData[playerid][shotWarnings] = 0; playerData[playerid][cbugWarnings] = 0; playerData[playerid][carSwing] = 0; // Reset Trucking if (playerData[playerid][truckingStatus] > 0) { DestroyDynamicRaceCP(playerData[playerid][truckingCheckpoint]); } playerData[playerid][truckingStatus] = -1; playerData[playerid][truckingMission] = -1; playerData[playerid][playerMissionCPTime] = 0; // Reset Forklift if (playerData[playerid][forkliftStatus] > 0) { DestroyObject(playerData[playerid][forkliftObject]); } playerData[playerid][forkliftStatus] = -1; playerData[playerid][forkliftDamage] = -1; // Reset Bus if (playerData[playerid][busStatus] > 0) { DestroyDynamicRaceCP(playerData[playerid][busCP]); } playerData[playerid][busStatus] = -1; // Reset Sweeper if (playerData[playerid][sweepStatus] > 0) { DestroyDynamicRaceCP(playerData[playerid][sweepCP]); } // Reset medic if (playerData[playerid][medicStatus] > 0) { playerData[playerid][medicStatus] = -1; playerData[playerid][medicMission] = -1; RemovePlayerMapIcon(playerid, 69); DestroyDynamicRaceCP(playerData[playerid][medicCheckpoint]); } playerData[playerid][sweepStatus] = -1; // Reset DM playerData[playerid][dmStreak] = 0; // Reset booleans playerData[playerid][playerGangID] = INVALID_GANG_ID; playerData[playerid][hasSTD] = false; playerData[playerid][isInEvent] = false; playerData[playerid][playerPingImmune] = false; playerData[playerid][hasSpawned] = false; playerData[playerid][playerLoggedIn] = false; playerData[playerid][playerAdminDuty] = false; playerData[playerid][playerCanTaze] = false; playerData[playerid][playerCanCuff] = false; playerData[playerid][playerCanArrest] = false; playerData[playerid][playerCanEMP] = false; playerData[playerid][playerIsTazed] = false; playerData[playerid][playerIsCuffed] = false; playerData[playerid][playerIsInHouse] = false; playerData[playerid][playerHitmarker] = false; playerData[playerid][playerCanRape] = false; playerData[playerid][playerCanRob] = false; playerData[playerid][playerCanRepair] = false; playerData[playerid][adminWeapon] = false; playerData[playerid][pEnterHouse] = false; playerData[playerid][showALog] = false; playerData[playerid][iscourier] = false; playerData[playerid][pmSpy] = false; playerData[playerid][isBanned] = false; playerData[playerid][playerBeenBanned] = false; playerData[playerid][playerDied] = false; playerData[playerid][suicide] = false; playerData[playerid][vipColour] = false; playerData[playerid][isInDM] = false; playerData[playerid][hasBackpack] = false; playerData[playerid][hasParrot] = false; playerData[playerid][luckyCharm] = false; playerData[playerid][weaponSkill] = false; playerData[playerid][playerDefuseKit] = false; playerData[playerid][allowSpec] = true; playerData[playerid][canEscape] = true; playerData[playerid][canAsk] = true; playerData[playerid][canReport] = true; playerData[playerid][useAdminName] = false; if (playerData[playerid][vSellTo] != -1) { // Remove the sale new sellto = playerData[playerid][vSellTo]; playerData[sellto][vBuyFrom] = -1; SendClientMessage(sellto, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}The vehicle offer has expired, the seller has quit."); } if (playerData[playerid][vBuyFrom] != -1) { // Remove the sale new buyfrom = playerData[playerid][vBuyFrom]; playerData[buyfrom][vSellTo] = -1; SendClientMessage(buyfrom, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}The vehicle offer has expired, the buyer has quit."); } // Progress Bars if (GetProgressBarValue(playerData[playerid][breakin]) != INVALID_BAR_VALUE) { DestroyProgressBar(playerData[playerid][breakin]); } DestroyProgressBar(playerData[playerid][robbery]); } }