04.06.2015, 17:48
Hi, i'am using PPC script and i have a problem again, when the player disconnect it should reset all his stats but it dosen't, this is my OnPlayerDisconnect callback :
Thank's for advance.
PHP код:
public OnPlayerDisconnect(playerid, reason)
{
ShowDisConnectTextDrawForAll(playerid, reason);
// ATTENTION : JAMAIS METTRE SA EN BAS //
if(APlayerData[playerid][LoggedIn] == true)
{
PlayerFile_Save(playerid);
AntiBoutiqueBug_OFF(playerid);
return 1;
}
// ---------------------------------- //
// Always allow NPC's to logout without password or account
if (IsPlayerNPC(playerid))
return 1;
// Setup local variables
new HouseID;
// Get the playername
// Stop spectate mode for all players who are spectating this player
for (new i; i < MAX_PLAYERS; i++)
if (IsPlayerConnected(i)) // Check if the player is connected
if (GetPlayerState(i) == PLAYER_STATE_SPECTATING) // Check if this player is spectating somebody
if (APlayerData[i][SpectateID] == playerid) // Check if this player is spectating me
{
TogglePlayerSpectating(i, 0); // Turn off spectate-mode
APlayerData[i][SpectateID] = INVALID_PLAYER_ID;
APlayerData[i][SpectateType] = ADMIN_SPEC_TYPE_NONE;
Server(i, "Le joueur s'est dйconnectй, fin du mode spectateur");
}
// Unload all the player's house-vehicles to make room for other player's vehicles
for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
{
// Get the HouseID from this slot
HouseID = APlayerData[playerid][Houses][HouseSlot];
// Check if there is a house in this slot
if (HouseID != 0)
{
// Unload the cars of the house
House_RemoveVehicles(HouseID);
// Set the house so it cannot be entered by anyone (close the house)
AHouseData[HouseID][HouseOpened] = false;
}
}
SetTimerEx("ResetPlayer", 1000, false, "i", playerid);
return 1;
}
PHP код:
forward ResetPlayer(playerid);
public ResetPlayer(playerid)
{
disableGPS(playerid);
destroyCar(playerid);
Speedometer_Cleanup(playerid);
InDM[playerid] = 0;
DestroyVehicle(EventVehicle[playerid]);
DestroyObject(FirstPersonObject[playerid]);
DestroyObject(BucheronAttachVehicle[playerid]);
// Clear the data in the APlayerData array to make sure the next player with the same id doesn't hold wrong data
APlayerData[playerid][SpectateID] = -1;
APlayerData[playerid][SpectateVehicle] = -1;
APlayerData[playerid][SpectateType] = ADMIN_SPEC_TYPE_NONE;
APlayerData[playerid][LoggedIn] = false;
APlayerData[playerid][PlayerJailed] = 0;
APlayerData[playerid][PlayerFrozen] = 0; // Clearing this variable automatically kills the frozentimer
APlayerData[playerid][AutoReportTime] = 0;
APlayerData[playerid][PlayerClass] = 0;
APlayerData[playerid][Warnings] = 0;
APlayerData[playerid][PlayerInEvent] = 0;
// Clear police warnings
APlayerData[playerid][PoliceCanJailMe] = false;
APlayerData[playerid][PoliceWarnedMe] = false;
APlayerData[playerid][Value_PoliceCanJailMe] = 0;
APlayerData[playerid][JobStarted] = false;
// Destroy a rented vehicle is the player had any
if (APlayerData[playerid][RentedVehicleID] != 0)
{
// Clear the data for the already rented vehicle
AVehicleData[APlayerData[playerid][RentedVehicleID]][Model] = 0;
AVehicleData[APlayerData[playerid][RentedVehicleID]][Fuel] = 0;
AVehicleData[APlayerData[playerid][RentedVehicleID]][Owned] = false;
AVehicleData[APlayerData[playerid][RentedVehicleID]][Owner] = 0;
AVehicleData[APlayerData[playerid][RentedVehicleID]][PaintJob] = 0;
for (new j; j < 14; j++)
{
AVehicleData[APlayerData[playerid][RentedVehicleID]][Components][j] = 0;
}
// Destroy the vehicle
DestroyVehicle(APlayerData[playerid][RentedVehicleID]);
// Clear the RentedVehicleID
APlayerData[playerid][RentedVehicleID] = 0;
}
// Make sure the jailtimer has been destroyed
KillTimer(APlayerData[playerid][PlayerJailedTimer]);
KillTimer(APlayerData[playerid][Timer_PoliceCanJailMe]);
// If the player is part of a convoy, kick him from it
Convoy_Leave(playerid);
// Clear the data in the APlayerData array to make sure the next player with the same id doesn't hold wrong data
APlayerData[playerid][SpectateID] = -1;
APlayerData[playerid][SpectateVehicle] = -1;
APlayerData[playerid][SpectateType] = ADMIN_SPEC_TYPE_NONE;
APlayerData[playerid][LoggedIn] = false;
APlayerData[playerid][PlayerPassword] = 0;
APlayerData[playerid][PlayerLevel] = 0;
APlayerData[playerid][VIPLevel] = 0;
APlayerData[playerid][PlayerJailed] = 0;
APlayerData[playerid][PlayerFrozen] = 0; // Clearing this variable automatically kills the frozentimer
APlayerData[playerid][Bans] = 0;
APlayerData[playerid][BanTime] = 0;
APlayerData[playerid][Muted] = false;
APlayerData[playerid][AssistanceNeeded] = false;
APlayerData[playerid][RulesRead] = false;
APlayerData[playerid][AutoReportTime] = 0;
APlayerData[playerid][TruckerLicense] = 0;
APlayerData[playerid][BusLicense] = 0;
APlayerData[playerid][PilotLicense] = 0;
APlayerData[playerid][MafiaLicense] = 0;
APlayerData[playerid][PlayerClass] = 0;
APlayerData[playerid][Warnings] = 0;
APlayerData[playerid][PlayerMoney] = 0;
APlayerData[playerid][PlayerScore] = 0;
for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
APlayerData[playerid][Houses][HouseSlot] = 0;
for (new BusSlot; BusSlot < MAX_BUSINESSPERPLAYER; BusSlot++)
APlayerData[playerid][Business][BusSlot] = 0;
APlayerData[playerid][CurrentHouse] = 0;
// Clear bank account info
APlayerData[playerid][BankPassword] = 0;
APlayerData[playerid][BankLoggedIn] = false;
APlayerData[playerid][BankMoney] = 0;
// Clear stats
APlayerData[playerid][StatsTruckerJobs] = 0;
APlayerData[playerid][StatsConvoyJobs] = 0;
APlayerData[playerid][StatsBusDriverJobs] = 0;
APlayerData[playerid][StatsPilotJobs] = 0;
APlayerData[playerid][StatsMafiaJobs] = 0;
APlayerData[playerid][StatsMafiaStolen] = 0;
APlayerData[playerid][StatsPoliceFined] = 0;
APlayerData[playerid][StatsPoliceJailed] = 0;
APlayerData[playerid][StatsCourierJobs] = 0;
APlayerData[playerid][StatsRoadworkerJobs] = 0;
APlayerData[playerid][StatsMetersDriven] = 0.0;
APlayerData[playerid][StatsAssistance] = 0;
// Clear police warnings
APlayerData[playerid][PoliceCanJailMe] = false;
APlayerData[playerid][PoliceWarnedMe] = false;
APlayerData[playerid][Value_PoliceCanJailMe] = 0;
// Make sure the jailtimer has been destroyed
KillTimer(APlayerData[playerid][PlayerJailedTimer]);
KillTimer(APlayerData[playerid][Timer_PoliceCanJailMe]);
return 1;
}