pawn Код:
// Always allow NPC's to login without password or account
if (IsPlayerNPC(playerid))
return 1;
// Setup local variables
new Name[MAX_PLAYER_NAME], NewPlayerMsg[128], HouseID;
// Setup a PVar to allow cross-script money-transfers (only from filterscript to this mainscript) and scorepoints
SetPVarInt(playerid, "PVarMoney", 0);
SetPVarInt(playerid, "PVarScore", 0);
// Get the playername
GetPlayerName(playerid, Name, sizeof(Name));
// Also store this name for the player
GetPlayerName(playerid, APlayerData[playerid][PlayerName], 24);
//format(NewPlayerMsg, 256, TXT_PlayerJoinedServer, Name, playerid, IP);
//SendClientMessageToAll(0xFFFFFFFF, NewPlayerMsg);
// Try to load the player's datafile ("PlayerFile_Load" returns "1" is the file has been read, "0" when the file cannot be read)
if (PlayerFile_Load(playerid) == 1)
{
// Check if the player is still banned
if (APlayerData[playerid][BanTime] < gettime()) // Player ban-time is passed
ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_PASSWORD, TXT_DialogLoginTitle, TXT_DialogLoginMsg, TXT_DialogLoginButton1, TXT_DialogButtonCancel);
else // Player is still banned
{
ShowRemainingBanTime(playerid); // Show the remaining ban-time to the player is days, hours, minutes, seconds
Kick(playerid); // Kick the player
}
}
else
ShowPlayerDialog(playerid, DialogRegister, DIALOG_STYLE_PASSWORD, TXT_DialogRegisterTitle, TXT_DialogRegisterMsg, TXT_DialogRegisterButton1, TXT_DialogButtonCancel);
// The houses have been loaded but not the cars, so load all vehicles assigned to the player's houses
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)
HouseFile_Load(HouseID, true); // Load the cars of the house
}
// Speedometer setup
Speedometer_Setup(playerid);
// MissionText TextDraw setup
APlayerData[playerid][MissionText] = TextDrawCreate(310.000000, 433.000000, " "); // Setup the missiontext at the bottom of the screen
TextDrawBackgroundColor(APlayerData[playerid][MissionText], 255);
TextDrawAlignment(APlayerData[playerid][MissionText], 2);
TextDrawFont(APlayerData[playerid][MissionText], 3);
TextDrawLetterSize(APlayerData[playerid][MissionText], 0.200000, 0.999999);
TextDrawColor(APlayerData[playerid][MissionText], -1);
TextDrawSetOutline(APlayerData[playerid][MissionText], 0);
TextDrawSetProportional(APlayerData[playerid][MissionText], 1);
TextDrawSetShadow(APlayerData[playerid][MissionText], 1);
TextDrawUseBox(APlayerData[playerid][MissionText], 1);
TextDrawBoxColor(APlayerData[playerid][MissionText], 0x00000076);
if(APlayerData[playerid][PlayerLevel] > 1)
{
new DName[MAX_PLAYER_NAME], Don[50];
GetPlayerName(playerid,DName,sizeof(DName));
format(Don,sizeof(Don),"~y~%s ~r~ON",DName);
SendClientMessage(playerid, Cinza, "- {a9c4e4}Administrador: {FF0000}Sim");
}else{
SendClientMessage(playerid, Cinza, "- {a9c4e4}Administrador: {FF0000}Nгo");
}
// Display a message if the player hasn't accepted the rules yet
if (APlayerData[playerid][RulesRead] == false)
SendClientMessage(playerid, 0xFFFFFFFF, "{D7D7D7}Confira as Regras do Life Of Trucker's Brasil em {FFFFFF}/regras{D7D7D7} e Aceite-as!");
return 1;
}
pawn Код:
// This callback gets called when a player disconnects from the server
public OnPlayerDisconnect(playerid, reason)
{
TextDrawShowForPlayer(playerid, ImagemEntrada);
// Always allow NPC's to logout without password or account
if (IsPlayerNPC(playerid))
return 1;
// Setup local variables
new Name[24], Msg[128], HouseID;
// Get the playername
GetPlayerName(playerid, Name, sizeof(Name));
// 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;
SendClientMessage(i, 0xFFFFFFFF, "{808080}O Jogador nгo Estб Online. Fechando o Modo Espiar!");
}
if(APlayerData[playerid][PlayerLevel] <= 0){
format(Msg, 256, TXT_PlayerLeftServer, Name, playerid);
SendClientMessageToAll(0xFFFFFFFF, Msg);
}else{
format(Msg, 256, TXT_AdminLeftServer, Name, playerid);
SendClientMessageToAll(0xFFFFFFFF, Msg);
}
// If the player entered a proper password (the player has an account)
if (strlen(APlayerData[playerid][PlayerPassword]) != 0)
{
// Save the player data and his houses
PlayerFile_Save(playerid);
}
// Stop any job that may have started (this also clears all mission data)
switch (APlayerData[playerid][PlayerClass])
{
case ClassTruckDriver: Trucker_EndJob(playerid); // Stop any trucker job
case ClassBusDriver: BusDriver_EndJob(playerid); // Stop any busdriver job
case ClassPilot: Pilot_EndJob(playerid); // Stop any pilot job
case ClassPolice: Police_EndJob(playerid); // Stop any police job
case ClassMafia: Mafia_EndJob(playerid); // Stop any mafia job
case ClassAssistance: Assistance_EndJob(playerid);
case ClassRoadWorker: Roadworker_EndJob(playerid);
}
// If the player is part of a convoy, kick him from it
Convoy_Leave(playerid);
// 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;
}
}
// 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][AssistanceNeeded] = 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][RulesRead] = false;
APlayerData[playerid][AutoReportTime] = 0;
APlayerData[playerid][TruckerLicense] = 0;
APlayerData[playerid][BusLicense] = 0;
APlayerData[playerid][WeaponLicense] = 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][StatsAssistance] = 0;
APlayerData[playerid][StatsMetersDriven] = 0.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]);
// Destroy the speedometer TextDraw for this player and the timer, also set the speed to 0
Speedometer_Cleanup(playerid);
// Also destroy the missiontext TextDraw for this player
TextDrawDestroy(APlayerData[playerid][MissionText]);
// 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;
}
return 1;
}