checkout your
"public OnPlayerSpawn" callback in your gamemode... remove all "SetPlayerPos" and "SetPlayerFacingAngle" codes out of this callback edit: too late |
SetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]); |
public OnPlayerSpawn(playerid) { SetPlayerColor(playerid, WHITE); if(Player[playerid][PreLoadedAnims] == 0) { PreloadAnimLib(playerid,"BOMBER"); PreloadAnimLib(playerid,"RAPPING"); PreloadAnimLib(playerid,"SHOP"); PreloadAnimLib(playerid,"BEACH"); PreloadAnimLib(playerid,"SMOKING"); PreloadAnimLib(playerid,"FOOD"); PreloadAnimLib(playerid,"ON_LOOKERS"); PreloadAnimLib(playerid,"DEALER"); PreloadAnimLib(playerid,"CRACK"); PreloadAnimLib(playerid,"CARRY"); PreloadAnimLib(playerid,"COP_AMBIENT"); PreloadAnimLib(playerid,"PARK"); PreloadAnimLib(playerid,"INT_HOUSE"); PreloadAnimLib(playerid,"FOOD"); PreloadAnimLib(playerid,"PED"); Player[playerid][PreLoadedAnims] = 1; } SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1); SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1); SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, 999); SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, 999); SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, 999); SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1); SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, 999); SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, 999); SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, 999); SetPlayerSkillLevel(playerid, WEAPONSKILL_SNIPERRIFLE, 999); if(Player[playerid][Authenticated] == 1) { if(Player[playerid][PrisonDuration] >= 1) { Player[playerid][InGroupHQ] = 0; Player[playerid][InBusiness] = 0; Player[playerid][InHouse] = 0; if(Player[playerid][PrisonID] == 1) { SetPlayerInterior(playerid, Prison1Int); SetPlayerPos(playerid, Prison1X, Prison1Y, Prison1Z); SetPlayerVirtualWorld(playerid, Prison1World); } else if(Player[playerid][PrisonID] == 2) { SetPlayerInterior(playerid, Prison2Int); SetPlayerPos(playerid, Prison2X, Prison2Y, Prison2Z); SetPlayerVirtualWorld(playerid, Prison2World); } } else { GivePlayerSavedWeapons(playerid); SetPlayerWeather(playerid, GlobalWeather); if(Player[playerid][AdminDuty] == 1) { SetPlayerHealth(playerid, 60000); } if(Player[playerid][IsAtEvent] >= 1) { new string[128]; ResetPlayerWeapons(playerid); GivePlayerSavedWeapons(playerid); SetPlayerPos(playerid, SpawnX, SpawnY, SpawnZ); new MathsFlaw = floatround(Player[playerid][LastHealth], floatround_ceil); SetPlayerHealth(playerid, MathsFlaw); MathsFlaw = floatround(Player[playerid][LastArmour], floatround_ceil); SetPlayerArmour(playerid, MathsFlaw); SendClientMessage(playerid, WHITE, "Thanks for playing in one of our events. You have been fully refunded."); Player[playerid][Hospitalized] = 0; if(Player[playerid][LastKiller] == INVALID_PLAYER_ID) { format(string, sizeof(string), "%s is no longer in the event, reason: Death.", GetName(playerid)); MessageToEventPlayers(YELLOW, string); } else { format(string, sizeof(string), "%s is no longer in the event, reason: Death (killed by %s).", GetName(playerid), GetName(Player[playerid][LastKiller])); MessageToEventPlayers(YELLOW, string); } } if(Player[playerid][Hospitalized] >= 1 && Player[playerid][PrisonDuration] < 1) { if(Player[playerid][AdminDuty] == 1) { Player[playerid][Hospitalized] = 0; SetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]); SendClientMessage(playerid, WHITE, "As you're on admin duty, you will not be hospitalized."); } else { if(Player[playerid][PrisonDuration] < 1) { Player[playerid][LastWorld] = 0; Player[playerid][LastInterior] = 0; ResetPlayerWeaponsEx(playerid); SetPlayerHealth(playerid, 100); SetPlayerInterior(playerid, 0); SetPlayerVirtualWorld(playerid, 0); SetPlayerDrunkLevel(playerid, 50000); Player[playerid][HospitalTime] = 1; SetPlayerColor(playerid, GREY); SetPlayerVirtualWorld(playerid, playerid+59); TogglePlayerControllable(playerid, false); SetPlayerPos(playerid, SpawnX, SpawnY - 5, SpawnZ); SetPlayerCameraPos(playerid, -833.5241, -1358.8575, 86.9054); SetPlayerCameraLookAt(playerid, -830.8118, -1360.3612, 87.0289); SendClientMessage(playerid, ANNOUNCEMENT, "You have blacked out. You're currently undergoing hospital treatment."); SendClientMessage(playerid, WHITE, "You will be released when you have recovered."); } } } else if(Player[playerid][Hospitalized] == -1) { SetCameraBehindPlayer(playerid); SetPlayerInterior(playerid, Spectator[playerid][SpecPlayerInterior]); SetPlayerFacingAngle(playerid, Spectator[playerid][SpecPlayerAngle]); SetPlayerVirtualWorld(playerid, Spectator[playerid][SpecPlayerWorld]); SetPlayerPos(playerid, Spectator[playerid][SpecPlayerX], Spectator[playerid][SpecPlayerY], Spectator[playerid][SpecPlayerZ]); TogglePlayerControllable(playerid, true); Player[playerid][Hospitalized] = 0; Player[Player[playerid][LastKiller]][IsHacker] = 0; } else { if(Player[playerid][IsAtEvent] >= 1) { Player[playerid][IsAtEvent] = 0; TogglePlayerControllable(playerid, true); SetPlayerVirtualWorld(playerid, 0); SetPlayerInterior(playerid, 0); } else { TogglePlayerControllable(playerid, true); SetPlayerInterior(playerid, Player[playerid][LastInterior]); SetPlayerVirtualWorld(playerid, Player[playerid][LastWorld]); if(GetPlayerVirtualWorld(playerid) >= 45000 && GetPlayerVirtualWorld(playerid) < 55000 || GetPlayerVirtualWorld(playerid) >= 55000 && GetPlayerVirtualWorld(playerid) < 65000 || GetPlayerVirtualWorld(playerid) >= 65000 && GetPlayerVirtualWorld(playerid) < 75000) { TextDrawShowForPlayer(playerid, ExitTextdraw); } } } } } Player[playerid][ResetTimer] = 1; return 1; }
public OnPlayerDisconnect(playerid, reason) { if(IsPlayerNPC(playerid)) { NPCs--; printf("[system] NPC %s has disconnected from the server.", GetName(playerid)); } else { new string[128], Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, sizeof(Name)); PlayersOn--; if(CurGMX == 0) { if(Spectator[playerid][SpecSpectatingPlayer] == -1) { switch(reason) { case 0: { format(string, sizeof(string), "%s has timed out from the server.", Name); } case 1: { format(string, sizeof(string), "%s has left the server.", Name); } case 2: { format(string, sizeof(string), "%s has been either kicked or banned from the server.", Name); } } NearByMessage(playerid, ANNOUNCEMENT, string); } if(Player[playerid][Group] >= 1) { switch(reason) { case 0: { format(string, sizeof(string), "%s from your group has disconnected (timeout).", Name); GroupMessage(playerid, ANNOUNCEMENT, string); } case 1: { format(string, sizeof(string), "%s from your group has disconnected (quit).", Name); GroupMessage(playerid, ANNOUNCEMENT, string); } case 2: { format(string, sizeof(string), "%s from your group has disconnected (banned/kicked).", Name); GroupMessage(playerid, ANNOUNCEMENT, string); } } } if(Player[playerid][IsAtEvent] == 1) { ResetPlayerWeapons(playerid); EC--; switch(reason) { case 0: { format(string, sizeof(string), "%s is no longer in the event, reason: Disconnected (timeout).", Name); MessageToEventPlayers(YELLOW, string); } case 1: { format(string, sizeof(string), "%s is no longer in the event, reason: Disconnected (quit).", Name); MessageToEventPlayers(YELLOW, string); } case 2: { format(string, sizeof(string), "%s is no longer in the event, reason: Disconnected (banned/kicked).", Name); MessageToEventPlayers(YELLOW, string); } } } if(Player[playerid][Authenticated] == 1) { if(Player[playerid][PlayerCarModel] >= 1) { GetOwnedCarMods(playerid); GetVehiclePos(Player[playerid][CarLinkID], Player[playerid][CarX], Player[playerid][CarY], Player[playerid][CarZ]); GetVehicleZAngle(Player[playerid][CarLinkID], Player[playerid][CarZAngle]); DestroyVehicle(Player[playerid][CarLinkID]); Player[playerid][CarLinkID] = 0; OwnedCarCount--; CarCount--; } if(Player[playerid][PlayerCarModel2] >= 1) { GetVehiclePos(Player[playerid][Car2LinkID], Player[playerid][Car2X], Player[playerid][Car2Y], Player[playerid][Car2Z]); GetVehicleZAngle(Player[playerid][Car2LinkID], Player[playerid][Car2ZAngle]); DestroyVehicle(Player[playerid][Car2LinkID]); Player[playerid][Car2LinkID] = 0; OwnedCarCount--; CarCount--; } if(Player[playerid][PlayerCarModel3] >= 1) { GetVehiclePos(Player[playerid][Car3LinkID], Player[playerid][Car3X], Player[playerid][Car3Y], Player[playerid][Car3Z]); GetVehicleZAngle(Player[playerid][Car3LinkID], Player[playerid][Car3ZAngle]); DestroyVehicle(Player[playerid][Car3LinkID]); Player[playerid][Car3LinkID] = 0; OwnedCarCount--; CarCount--; } if(Player[playerid][Cuffed] >= 1 || Player[playerid][Tied] >= 1) { Player[playerid][PrisonDuration] = 720; Player[playerid][PrisonID] = 2; format(Player[playerid][Note], 128, "You have automatically been prisoned for disconnecting whilst cuffed / tied."); } for(new i = 0; i < MAX_PLAYERS; i++) { if(Player[i][PendingHandshake] == playerid) { Player[i][PendingHandshake] = -1; } if(Player[i][PendingCarReceival] == playerid) { Player[i][PendingCarReceival] = -1; } } if(Player[playerid][BeingSpyedOnBy] != -1) { format(string, sizeof(string), "The player you were spying on (%s) has disconnected", Name); SendClientMessage(Player[playerid][BeingSpyedOnBy], WHITE, string); Player[playerid][BeingSpyedOnBy] = -1; } if(Player[playerid][PendingProposal] != -1) { format(string, sizeof(string), "%s has disconnected (the person you have a pending proposal with).", Name); SendClientMessage(Player[playerid][PendingProposal], WHITE, string); Player[playerid][PendingProposal] = -1; } if(Player[playerid][AdminDuty] >= 1) { SetPlayerName(playerid, Player[playerid][NormalName]); format(string, sizeof(string), "%s is now off Admin Duty (disconnected).", Name); SendToAdmins(ADMINORANGE, string, 1); } if(Player[playerid][IsAtEvent] >= 1) { Player[playerid][LastX] = SpawnX; Player[playerid][LastY] = SpawnY; Player[playerid][LastZ] = SpawnZ; Player[playerid][LastWorld] = 0; Player[playerid][LastInterior] = 0; SavePlayerData(playerid); printf("[system] %s has disconnected during an event, so they've been warped to the newbie spawn.", Name); } else { GetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]); Player[playerid][LastWorld] = GetPlayerVirtualWorld(playerid); SavePlayerData(playerid); } } } } return 1; }
public OnPlayerSpawn(playerid) { SetPlayerColor(playerid, WHITE); if(Player[playerid][PreLoadedAnims] == 0) { PreloadAnimLib(playerid,"BOMBER"); PreloadAnimLib(playerid,"RAPPING"); PreloadAnimLib(playerid,"SHOP"); PreloadAnimLib(playerid,"BEACH"); PreloadAnimLib(playerid,"SMOKING"); PreloadAnimLib(playerid,"FOOD"); PreloadAnimLib(playerid,"ON_LOOKERS"); PreloadAnimLib(playerid,"DEALER"); PreloadAnimLib(playerid,"CRACK"); PreloadAnimLib(playerid,"CARRY"); PreloadAnimLib(playerid,"COP_AMBIENT"); PreloadAnimLib(playerid,"PARK"); PreloadAnimLib(playerid,"INT_HOUSE"); PreloadAnimLib(playerid,"FOOD"); PreloadAnimLib(playerid,"PED"); Player[playerid][PreLoadedAnims] = 1; } SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1); SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1); SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, 999); SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, 999); SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, 999); SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1); SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, 999); SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, 999); SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, 999); SetPlayerSkillLevel(playerid, WEAPONSKILL_SNIPERRIFLE, 999); if(Player[playerid][Authenticated] == 1) { if(Player[playerid][PrisonDuration] >= 1) { Player[playerid][InGroupHQ] = 0; Player[playerid][InBusiness] = 0; Player[playerid][InHouse] = 0; if(Player[playerid][PrisonID] == 1) { SetPlayerInterior(playerid, Prison1Int); SetPlayerPos(playerid, Prison1X, Prison1Y, Prison1Z); SetPlayerVirtualWorld(playerid, Prison1World); } else if(Player[playerid][PrisonID] == 2) { SetPlayerInterior(playerid, Prison2Int); SetPlayerPos(playerid, Prison2X, Prison2Y, Prison2Z); SetPlayerVirtualWorld(playerid, Prison2World); } } else { GivePlayerSavedWeapons(playerid); SetPlayerWeather(playerid, GlobalWeather); if(Player[playerid][AdminDuty] == 1) { SetPlayerHealth(playerid, 60000); } if(Player[playerid][IsAtEvent] >= 1) { new string[128]; ResetPlayerWeapons(playerid); GivePlayerSavedWeapons(playerid); new MathsFlaw = floatround(Player[playerid][LastHealth], floatround_ceil); SetPlayerHealth(playerid, MathsFlaw); MathsFlaw = floatround(Player[playerid][LastArmour], floatround_ceil); SetPlayerArmour(playerid, MathsFlaw); SendClientMessage(playerid, WHITE, "Thanks for playing in one of our events. You have been fully refunded."); Player[playerid][Hospitalized] = 0; if(Player[playerid][LastKiller] == INVALID_PLAYER_ID) { format(string, sizeof(string), "%s is no longer in the event, reason: Death.", GetName(playerid)); MessageToEventPlayers(YELLOW, string); } else { format(string, sizeof(string), "%s is no longer in the event, reason: Death (killed by %s).", GetName(playerid), GetName(Player[playerid][LastKiller])); MessageToEventPlayers(YELLOW, string); } } if(Player[playerid][Hospitalized] >= 1 && Player[playerid][PrisonDuration] < 1) { if(Player[playerid][AdminDuty] == 1) { Player[playerid][Hospitalized] = 0; SetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]); SendClientMessage(playerid, WHITE, "As you're on admin duty, you will not be hospitalized."); } else { if(Player[playerid][PrisonDuration] < 1) { Player[playerid][LastWorld] = 0; Player[playerid][LastInterior] = 0; ResetPlayerWeaponsEx(playerid); SetPlayerHealth(playerid, 100); SetPlayerInterior(playerid, 0); SetPlayerVirtualWorld(playerid, 0); SetPlayerDrunkLevel(playerid, 50000); Player[playerid][HospitalTime] = 1; SetPlayerColor(playerid, GREY); SetPlayerVirtualWorld(playerid, playerid+59); TogglePlayerControllable(playerid, false); SetPlayerPos(playerid, SpawnX, SpawnY - 5, SpawnZ); SetPlayerCameraPos(playerid, -833.5241, -1358.8575, 86.9054); SetPlayerCameraLookAt(playerid, -830.8118, -1360.3612, 87.0289); SendClientMessage(playerid, ANNOUNCEMENT, "You have blacked out. You're currently undergoing hospital treatment."); SendClientMessage(playerid, WHITE, "You will be released when you have recovered."); } } } else if(Player[playerid][Hospitalized] == -1) { SetCameraBehindPlayer(playerid); SetPlayerInterior(playerid, Spectator[playerid][SpecPlayerInterior]); SetPlayerFacingAngle(playerid, Spectator[playerid][SpecPlayerAngle]); SetPlayerVirtualWorld(playerid, Spectator[playerid][SpecPlayerWorld]); SetPlayerPos(playerid, Spectator[playerid][SpecPlayerX], Spectator[playerid][SpecPlayerY], Spectator[playerid][SpecPlayerZ]); TogglePlayerControllable(playerid, true); Player[playerid][Hospitalized] = 0; Player[Player[playerid][LastKiller]][IsHacker] = 0; } else { if(Player[playerid][IsAtEvent] >= 1) { Player[playerid][IsAtEvent] = 0; TogglePlayerControllable(playerid, true); SetPlayerVirtualWorld(playerid, 0); SetPlayerInterior(playerid, 0); } else { TogglePlayerControllable(playerid, true); SetPlayerInterior(playerid, Player[playerid][LastInterior]); SetPlayerVirtualWorld(playerid, Player[playerid][LastWorld]); if(GetPlayerVirtualWorld(playerid) >= 45000 && GetPlayerVirtualWorld(playerid) < 55000 || GetPlayerVirtualWorld(playerid) >= 55000 && GetPlayerVirtualWorld(playerid) < 65000 || GetPlayerVirtualWorld(playerid) >= 65000 && GetPlayerVirtualWorld(playerid) < 75000) { TextDrawShowForPlayer(playerid, ExitTextdraw); } } } } } Player[playerid][ResetTimer] = 1; return 1; }
public OnPlayerDisconnect(playerid, reason) { if(IsPlayerNPC(playerid)) { NPCs--; printf("[system] NPC %s has disconnected from the server.", GetName(playerid)); } else { new string[128], Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, sizeof(Name)); PlayersOn--; if(CurGMX == 0) { if(Spectator[playerid][SpecSpectatingPlayer] == -1) { switch(reason) { case 0: { format(string, sizeof(string), "%s has timed out from the server.", Name); } case 1: { format(string, sizeof(string), "%s has left the server.", Name); } case 2: { format(string, sizeof(string), "%s has been either kicked or banned from the server.", Name); } } NearByMessage(playerid, ANNOUNCEMENT, string); } if(Player[playerid][Group] >= 1) { switch(reason) { case 0: { format(string, sizeof(string), "%s from your group has disconnected (timeout).", Name); GroupMessage(playerid, ANNOUNCEMENT, string); } case 1: { format(string, sizeof(string), "%s from your group has disconnected (quit).", Name); GroupMessage(playerid, ANNOUNCEMENT, string); } case 2: { format(string, sizeof(string), "%s from your group has disconnected (banned/kicked).", Name); GroupMessage(playerid, ANNOUNCEMENT, string); } } } if(Player[playerid][IsAtEvent] == 1) { ResetPlayerWeapons(playerid); EC--; switch(reason) { case 0: { format(string, sizeof(string), "%s is no longer in the event, reason: Disconnected (timeout).", Name); MessageToEventPlayers(YELLOW, string); } case 1: { format(string, sizeof(string), "%s is no longer in the event, reason: Disconnected (quit).", Name); MessageToEventPlayers(YELLOW, string); } case 2: { format(string, sizeof(string), "%s is no longer in the event, reason: Disconnected (banned/kicked).", Name); MessageToEventPlayers(YELLOW, string); } } } if(Player[playerid][Authenticated] == 1) { if(Player[playerid][PlayerCarModel] >= 1) { GetOwnedCarMods(playerid); GetVehiclePos(Player[playerid][CarLinkID], Player[playerid][CarX], Player[playerid][CarY], Player[playerid][CarZ]); GetVehicleZAngle(Player[playerid][CarLinkID], Player[playerid][CarZAngle]); DestroyVehicle(Player[playerid][CarLinkID]); Player[playerid][CarLinkID] = 0; OwnedCarCount--; CarCount--; } if(Player[playerid][PlayerCarModel2] >= 1) { GetVehiclePos(Player[playerid][Car2LinkID], Player[playerid][Car2X], Player[playerid][Car2Y], Player[playerid][Car2Z]); GetVehicleZAngle(Player[playerid][Car2LinkID], Player[playerid][Car2ZAngle]); DestroyVehicle(Player[playerid][Car2LinkID]); Player[playerid][Car2LinkID] = 0; OwnedCarCount--; CarCount--; } if(Player[playerid][PlayerCarModel3] >= 1) { GetVehiclePos(Player[playerid][Car3LinkID], Player[playerid][Car3X], Player[playerid][Car3Y], Player[playerid][Car3Z]); GetVehicleZAngle(Player[playerid][Car3LinkID], Player[playerid][Car3ZAngle]); DestroyVehicle(Player[playerid][Car3LinkID]); Player[playerid][Car3LinkID] = 0; OwnedCarCount--; CarCount--; } if(Player[playerid][Cuffed] >= 1 || Player[playerid][Tied] >= 1) { Player[playerid][PrisonDuration] = 720; Player[playerid][PrisonID] = 2; format(Player[playerid][Note], 128, "You have automatically been prisoned for disconnecting whilst cuffed / tied."); } for(new i = 0; i < MAX_PLAYERS; i++) { if(Player[i][PendingHandshake] == playerid) { Player[i][PendingHandshake] = -1; } if(Player[i][PendingCarReceival] == playerid) { Player[i][PendingCarReceival] = -1; } } if(Player[playerid][BeingSpyedOnBy] != -1) { format(string, sizeof(string), "The player you were spying on (%s) has disconnected", Name); SendClientMessage(Player[playerid][BeingSpyedOnBy], WHITE, string); Player[playerid][BeingSpyedOnBy] = -1; } if(Player[playerid][PendingProposal] != -1) { format(string, sizeof(string), "%s has disconnected (the person you have a pending proposal with).", Name); SendClientMessage(Player[playerid][PendingProposal], WHITE, string); Player[playerid][PendingProposal] = -1; } if(Player[playerid][AdminDuty] >= 1) { SetPlayerName(playerid, Player[playerid][NormalName]); format(string, sizeof(string), "%s is now off Admin Duty (disconnected).", Name); SendToAdmins(ADMINORANGE, string, 1); } if(Player[playerid][IsAtEvent] >= 1) { Player[playerid][LastX] = SpawnX; Player[playerid][LastY] = SpawnY; Player[playerid][LastZ] = SpawnZ; Player[playerid][LastWorld] = 0; Player[playerid][LastInterior] = 0; SavePlayerData(playerid); printf("[system] %s has disconnected during an event, so they've been warped to the newbie spawn.", Name); } else { SavePlayerData(playerid); } } } } return 1; }