Advertisement
Guest User

Untitled

a guest
Dec 31st, 2013
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.14 KB | None | 0 0
  1. public OnPlayerDisconnect(playerid, reason)
  2. {
  3. UnrentVehicle(playerid);
  4.  
  5. if (RobbingHouse[playerid])
  6. {
  7. KillTimer(RobTimer[playerid]);
  8. }
  9. if (PlayerInfo[playerid][pInjured])
  10. {
  11. PlayerInfo[playerid][pHospital] = 1;
  12. }
  13. if (GetPVarInt(playerid, "Digging"))
  14. {
  15. KillTimer(GetPVarInt(playerid, "DiggingTimer"));
  16. DeletePVar(playerid, "Digging");
  17. DeletePVar(playerid, "DiggingStage");
  18. }
  19. if (PlayerWeapons[playerid][pAssembleGun] > 0)
  20. {
  21. KillTimer(PlayerWeapons[playerid][pAssembleTimer]);
  22. KillTimer(PlayerWeapons[playerid][pAssembleStage]);
  23. }
  24. PlayerTextDrawDestroy(playerid, FuelTextDraw[playerid]);
  25. for (new i = 0; i < 60; i ++)
  26. {
  27. PlayerTextDrawDestroy(playerid, StatsTextdraws[playerid][i]);
  28. }
  29. new disconnectstr[128];
  30. DeletePVar(playerid, "InShamal");
  31. KillTimer(LockPickTimer[playerid]);
  32. KillTimer(ColorTimer[playerid]);
  33. #if defined NPC_KILLABLE
  34. KillTimer(NPCKillTimer[playerid]);
  35. #endif
  36. KillTimer(RelogTimer[playerid]);
  37. KillTimer(iPodLoadTimer[playerid]);
  38. SetPlayerPos(playerid, FlightPosition[playerid][0], FlightPosition[playerid][1], FlightPosition[playerid][2]);
  39. for(new i = 1; i < MAX_POINTS; i++)
  40. {
  41. if(PointAttemptingToCapture[playerid] == i)
  42. {
  43. Capturing[playerid][i] = 0;
  44. PointAttemptingToCapture[playerid] = 0;
  45. KillTimer(pointtimer);
  46. format(disconnectstr, sizeof(disconnectstr), "The player that recently attempted to capture %s has disconnected.", PointStatistics[i][pointname]);
  47. SendFamilyMessageToAll(YELLOW, disconnectstr);
  48. capturegoingon = 0;
  49. break;
  50. }
  51. }
  52. KillTimer(LoseHealthTimer[playerid]);
  53. if(PlayerPaintballing[playerid] > 0 || IsAtEvent[playerid])
  54. {
  55. IsAtEvent[playerid] = 0;
  56. ResetPlayerAdminWeaponsEx(playerid);
  57. SetPlayerWeapons(playerid);
  58. PlayerInfo[playerid][pHealth] = HealthBeforeEnter[playerid];
  59. PlayerInfo[playerid][pArmor] = ArmorBeforeEnter[playerid];
  60. PlayerInfo[playerid][pInt] = OldInt[playerid];
  61. PlayerInfo[playerid][pSPos_x] = OldX[playerid];
  62. PlayerInfo[playerid][pSPos_y] = OldY[playerid];
  63. PlayerInfo[playerid][pSPos_z] = OldZ[playerid];
  64.  
  65. for (new i = 0; i < 13; i ++)
  66. {
  67. PlayerInfo[playerid][pGuns][i] = TempWeapons[playerid][i];
  68. PlayerInfo[playerid][pAmmo][i] = TempAmmo[playerid][i];
  69. }
  70.  
  71. SetPlayerPosEx(playerid, OldX[playerid], OldY[playerid], OldZ[playerid]);
  72. SetPlayerInterior(playerid, OldInt[playerid]);
  73. SetPlayerVirtualWorld(playerid, OldVw[playerid]);
  74. SetPlayerHealth(playerid, HealthBeforeEnter[playerid]);
  75. SetPlayerArmour(playerid, ArmorBeforeEnter[playerid]);
  76. if(PlayerPaintballing[playerid] > 0) PaintballPlayers--;
  77. }
  78. if(Relogging[playerid])
  79. {
  80. new string[128];
  81. Relogging[playerid] = 0;
  82. format(string, sizeof(string), "unbanip %s", PlayerIP[playerid]);
  83. SendRconCommand(string);
  84. SendRconCommand("reloadbans");
  85. return 1;
  86. }
  87. for(new i = 0; i < MAX_PLAYERS; i++)
  88. {
  89. if(BankAccount[i] == playerid)
  90. {
  91. ShowPlayerDialog(i, 1336, DIALOG_STYLE_MSGBOX, "Error", "(( The owner of this bank account has just signed off, you may not use it anymore. ))", "Close", "");
  92. BankAccount[i] = -1;
  93. }
  94. if(ATMAccount[i] == playerid)
  95. {
  96. ShowPlayerDialog(i, 1336, DIALOG_STYLE_MSGBOX, "Error", "(( The owner of this ATM account has just signed off, you may not use it anymore. ))", "Close", "");
  97. ATMAccount[i] = -1;
  98. }
  99. }
  100. KillTimer(dragtimer[playerid]);
  101. PlayerBeingDragged[playerid] = 0;
  102. KillTimer(PlayerInfo[playerid][pMoveTimer]);
  103. planted[playerid] = 0;
  104. bomb[playerid] = 0;
  105. bombx[playerid] = 0;
  106. bomby[playerid] = 0;
  107. bombz[playerid] = 0;
  108. DestroyDynamicObject(bombobj[playerid]);
  109. KillTimer(bombtimer[playerid]);
  110. if(godmode[playerid])
  111. {
  112. SetPlayerHealth(playerid, storehealth[playerid]);
  113. PlayerInfo[playerid][pHealth] = storehealth[playerid];
  114. }
  115. new string[128];
  116. new discstring[128];
  117. new sendername[MAX_PLAYER_NAME];
  118. new caller = Mobile[playerid];
  119. GetPlayerName(playerid, sendername, sizeof(sendername));
  120. switch(reason)
  121. {
  122. case 0: format(discstring, sizeof(discstring), "** %s has left the server. (Timeout)", sendername);
  123. case 1: format(discstring, sizeof(discstring), "** %s has left the server. (Leaving)", sendername);
  124. case 2: format(discstring, sizeof(discstring), "** %s has left the server. (Kicked)", sendername);
  125. }
  126. if (!IsPlayerNPC(playerid))
  127. {
  128. if (!restart && ConnectMessages)
  129. {
  130. SendAdminMessage(GREY, discstring);
  131. }
  132. }
  133. if(PlayerInfo[playerid][pCash] <= 500 && PlayerInfo[playerid][pBankMoney] <= 500 && PlayerInfo[playerid][pLevel] <= 2 && gPlayerLogged[playerid])
  134. {
  135. if(strlen(LastPaid[playerid]))
  136. {
  137. new ip[20];
  138. GetPlayerIp(playerid, ip, sizeof(ip));
  139. format(string, sizeof(string), "Possible Moneyfarm: %s (IP: %s) just left with $%d cash and $%d cash in bank.",PlayerName(playerid),ip, PlayerInfo[playerid][pCash], PlayerInfo[playerid][pBankMoney]);
  140. PayLog(string);
  141. ABroadCast(YELLOW,string,1);
  142. new paidto[128];
  143. format(paidto,sizeof(paidto),"- Last paid money to: %s (IP: %s)",LastPaid[playerid], ip);
  144. ABroadCast(YELLOW,paidto,1);
  145. }
  146. }
  147. if(PlayerTied[playerid] > 0 || PlayerCuffed[playerid] > 0 && PlayerInfo[playerid][pJailed] == 0)
  148. {
  149. PlayerInfo[playerid][pJailed] = 1; PlayerInfo[playerid][pJailTime] = 800;
  150. }
  151. if(GuardedBy[playerid] != 999)
  152. {
  153. SendClientMessage(GuardedBy[playerid], RED, "* Your client has disconnected from the server.");
  154. SetPlayerToTeamColor(GuardedBy[playerid]);
  155. SetPlayerToTeamColor(playerid);
  156. GuardedBy[GuardedBy[playerid]] = 999;
  157. GuardingPrice[GuardedBy[playerid]] = 0;
  158. Guarding[playerid] = 999;
  159. }
  160. if(Guarding[playerid] != 999)
  161. {
  162. SendClientMessage(Guarding[playerid], RED, "* Your bodyguard has disconnected from the server.");
  163. PlayerInfo[playerid][pBankMoney] -= (GuardingPrice[Guarding[playerid]] * 2);
  164. SetPlayerToTeamColor(Guarding[playerid]);
  165. SetPlayerToTeamColor(playerid);
  166. GuardedBy[Guarding[playerid]] = 999;
  167. GuardingPrice[Guarding[playerid]] = 0;
  168. Guarding[playerid] = 999;
  169. }
  170. new x = 0;
  171. while(x != MAX_PLAYERS)
  172. {
  173. if(IsPlayerConnected(x) && GetPlayerState(x) == PLAYER_STATE_SPECTATING && SpectatedID[x] == playerid)
  174. {
  175. SetPlayerHealth(x, PlayerInfo[x][pHealth]);
  176. SetPlayerArmour(x, PlayerInfo[x][pArmor]);
  177. SetPlayerVirtualWorld(x, PlayerInfo[x][pVirtualWorld]);
  178. SetPlayerInterior(x, PlayerInfo[x][pInt]);
  179. SetPlayerPosEx(x, PlayerInfo[x][pSPos_x], PlayerInfo[x][pSPos_y], PlayerInfo[x][pSPos_z]);
  180. SetPlayerFacingAngle(x, PlayerInfo[x][pSPos_r]);
  181. SendClientMessage(x, WHITE, "You are no longer spectating.");
  182. TogglePlayerSpectating(x, 0);
  183. SpectatedID[x] = INVALID_PLAYER_ID;
  184. SpectateType[x] = ADMIN_SPEC_TYPE_NONE;
  185. HidePM[x] = 0;
  186. PhoneOffline[x] = 0;
  187. ResetPlayerAdminWeaponsEx(x);
  188. }
  189. //everything below fixes bugs with player id 0 getting random offers accepted
  190. if(RepairOffer[x] == playerid) { RepairOffer[x] = 999; RepairPrice[x] = 0; }
  191. if(WeedOffer[x] == playerid) { WeedOffer[x] = 999; WeedPrice[x] = 0; WeedGram[x] = 0; }
  192. if(ProdOffer[x] == playerid) { ProdOffer[x] = 999; ProdPrice[x] = 0; ProdAmount[x] = 0; }
  193. if(CocaineOffer[x] == playerid) { CocaineOffer[x] = 999; CocainePrice[x] = 0; CocaineGram[x] = 0; }
  194. if(VestOffer[x] == playerid) { VestOffer[x] = 999; VestPrice[x] = 0; }
  195. if(GuardOffer[x] == playerid) { GuardOffer[x] = 999; GuardPrice[x] = 0; }
  196. if(GetPVarInt(x, "CarOfferer") == playerid) { SetPVarInt(x, "CarOfferer", -1); DeletePVar(x, "CarToBuy"); DeletePVar(x, "CarSlot"); DeletePVar(x, "CarValue"); }
  197. if(GetPVarInt(x, "OfferedVIP") == playerid) { SetPVarInt(x, "OfferedVIP", INVALID_PLAYER_ID); DeletePVar(x, "OfferedPrice"); }
  198. x++;
  199. }
  200. if(BankJobPlayer == playerid)
  201. {
  202. format(string, 256, "City Alert: The Bank Robbery attempt has failed.");
  203. StopPlayerHoldingObject(playerid);
  204. SendClientMessageToAll(LIGHTBLUE, string);
  205. BankJobPlayer = 999;
  206. TimeAfterBankJob = 0;
  207. BankJobTime = -1;
  208. BankDeliverTime = -1;
  209. }
  210. for(new i = 0; i < MAX_PLAYERS; i++)
  211. {
  212. if(IsPlayerConnected(i))
  213. {
  214. if(TaxiAccepted[i] < 999)
  215. {
  216. if(TaxiAccepted[i] == playerid) { TaxiAccepted[i] = 999; GameTextForPlayer(i, "~w~Taxi Caller~n~~r~Left the game", 5000, 1); TaxiCallTime[i] = 0; DisablePlayerCheckpoint(i); }
  217. }
  218. else if(BusAccepted[i] < 999)
  219. {
  220. if(BusAccepted[i] == playerid) { BusAccepted[i] = 999; GameTextForPlayer(i, "~w~Bus Caller~n~~r~Left the game", 5000, 1); BusCallTime[i] = 0; DisablePlayerCheckpoint(i); }
  221. }
  222. if(GoChase[i] < 999)
  223. {
  224. if(GoChase[i] == playerid) { SendClientMessage(i, YELLOW, "The target has left the server."); GoChase[i] = 999; }
  225. }
  226. }
  227. }
  228. if(TransportCost[playerid] > 0 && TransportDriver[playerid] < 999)
  229. {
  230. if(IsPlayerConnected(TransportDriver[playerid]))
  231. {
  232. TransportMoney[TransportDriver[playerid]] += TransportCost[playerid];
  233. TransportTime[TransportDriver[playerid]] = 0;
  234. TransportCost[TransportDriver[playerid]] = 0;
  235. format(string, sizeof(string), "~w~Passenger left~n~~g~Earned $%d",TransportCost[playerid]);
  236. GameTextForPlayer(TransportDriver[playerid], string, 5000, 1);
  237. }
  238. }
  239. if(BombID[playerid] != -1) TakeWeapon(playerid,40); PlayerInfo[playerid][pGuns][12] = 0; DestroyDynamicObject(BombID[playerid]);
  240. if(PlayerPaintballing[playerid] != 0) PaintballPlayers --;
  241. if(caller != 999)
  242. {
  243. SendClientMessage(caller, GREY2, "The line has been disconnected....");
  244. CellTime[caller] = 0;
  245. Mobile[caller] = 999;
  246. SetPlayerSpecialAction(caller,SPECIAL_ACTION_STOPUSECELLPHONE);
  247. }
  248. if(TransportDuty[playerid] == 1) TaxiDrivers -= 1;
  249. else if(TransportDuty[playerid] == 2) BusDrivers -= 1;
  250. if(PlayerHadDeagle[playerid] == 1) PlayerInfo[playerid][pGuns][2] = 24;
  251. if(ThiefText[playerid] != Text3D:INVALID_3DTEXT_ID) DestroyDynamic3DTextLabel(ThiefText[playerid]);
  252. if(PlayerHasTazer[playerid]) RemovePlayerAttachedObject(playerid,0);
  253. SetPVarInt(playerid, "laser", 0);
  254. RemovePlayerAttachedObject(playerid, 0);
  255. SavePlayer(playerid);
  256. return 1;
  257. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement