olha ai como ta OnPlayerDeath
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
// Setup local variables
new VictimName[24], KillerName[24], Msg[128];
// Clear the missiontext
TextDrawSetString(APlayerData[playerid][MissionText], " ");
// Hide the missiontext for this player (when the player is choosing a class, it's not required to show any mission-text)
TextDrawHideForPlayer(playerid, APlayerData[playerid][MissionText]);
// Stop any job that may have started
switch (APlayerData[playerid][PlayerClass])
{
case ClassTruckDriver: Trucker_EndJob(playerid);
case ClassBusDriver: BusDriver_EndJob(playerid);
case ClassPilot: Pilot_EndJob(playerid);
case ClassPolice: Police_EndJob(playerid);
case ClassMafia: Mafia_EndJob(playerid);
case ClassCourier: Courier_EndJob(playerid);
case ClassAssistance: Assistance_EndJob(playerid);
case ClassRoadWorker: Roadworker_EndJob(playerid);
case ClassLixeiro: Lixeiro_EndJob(playerid);
case ClassPizza: Pizza_EndJob(playerid);
}
// If the player is part of a convoy, kick him from it
Convoy_Leave(playerid);
// If another player kills you, he'll get an extra star of his wanted level
if (killerid != INVALID_PLAYER_ID)
{
// Increase the wanted level of the killer by one star
SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 1);
// Get the name of the killed player and the killer
GetPlayerName(playerid, VictimName, sizeof(VictimName));
GetPlayerName(killerid, KillerName, sizeof(KillerName));
// Let the killed know the police are informed about the kill
format(Msg, 128, "{FF0000}Voce Matou {FFFFFF}%s{FF0000}, Agora a Policia esta a sua Procura", VictimName);
SendClientMessage(killerid, 0xFFFFFFFF, Msg);
// Inform all police players about the kill
format(Msg, 128, "{0000FF}O Jogador {FFFFFF}%s{0000FF} Matou {FFFFFF}%s{0000FF}, Procurar e Multar", KillerName, VictimName);
Police_SendMessage(Msg);
}
if( IsPlayerConnected( killerid ) )
{
if( IsPlayerConnected( GetPVarInt( playerid, "LastKilled" ) ) && GetPVarInt( playerid, "LastKilled" ) == killerid )
{
if( ( GetPVarInt( playerid, "LastKilledTickcount" ) - GetTickCount( ) ) < 50 )
{
SetPVarInt( playerid, "LastKilledTick", GetPVarInt( playerid, "LastKilledTick" ) + 1 );
if( GetPVarInt( playerid, "LastKilledTick" ) > 1 ) Ban( playerid );
}
SetPVarInt( playerid, "LastKilledTickcount", GetTickCount( ) );
}
SetPVarInt( playerid, "LastKilled", killerid );
}
SendDeathMessage(killerid, playerid, reason);
return 1;
}
o outro OnPlayerDesconnetc
pawn Код:
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!");
}
// Send a message to all players to let them know somebody left the server
format(Msg, 128, TXT_PlayerLeftServer, 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);
case ClassLixeiro: Lixeiro_EndJob(playerid);
case ClassPizza: Pizza_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][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][WeaponLicense] = 0;
APlayerData[playerid][BusLicense] = 0;
APlayerData[playerid][PlayerClass] = 0;
APlayerData[playerid][WeaponLicense] = 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][StatsLixeiroJobs] = 0;
APlayerData[playerid][StatsPizzaJobs] = 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]);
if(APlayerData[playerid][PlayerLevel] > 0)
{
new DName[MAX_PLAYER_NAME], Coringa[80];
GetPlayerName(playerid,DName,sizeof(DName));
format(Coringa,sizeof(Coringa),"~>~ ~g~%s ~r~Off ~<~",DName);
GameTextForAll(Coringa, 2000, 0);
}
// Clear the RentedVehicleID
APlayerData[playerid][RentedVehicleID] = 0;
}
return 1;
}