Advertisement
Guest User

OnPlayerDisconnect

a guest
Jan 2nd, 2013
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.40 KB | None | 0 0
  1. public OnPlayerDisconnect(playerid, reason)
  2. {
  3. new textreason[64];
  4. new plname[24];
  5. GetPlayerName(playerid, plname, sizeof(plname));
  6. new playersip[24];
  7. GetPlayerIp(playerid, playersip, sizeof(playersip));
  8. new string2[128];
  9. SetRealMoney(playerid, ScriptMoney[playerid]);
  10. if(PlayerInfo[playerid][pAdminDuty] == 1)
  11. {
  12. SafeResetPlayerWeapons(playerid);
  13. }
  14. if(IsPlayerInAnyVehicle(playerid))
  15. {
  16. new Float:health;
  17. GetVehicleHealth(GetPlayerVehicleID(playerid), health);
  18. if(health < 450)
  19. {
  20. VehicleHealth[GetPlayerVehicleID(playerid)] = 450;
  21. SetVehicleHealth(GetPlayerVehicleID(playerid), 450.0);
  22. }
  23. }
  24. if(Searching[playerid] == 1)
  25. {
  26. RemovePlayerMapIcon(playerid, 500 + playerid);
  27. Searching[playerid] = 0;
  28. }
  29. if(Ronned[playerid] >= 1)
  30. {
  31. KillTimer(RonnTimer[playerid]);
  32. }
  33.  
  34. if(playerid == beingvoted && reason != 2)
  35. {
  36. KillTimer(votetimer1);
  37. KillTimer(votetimer2);
  38. format(string2,sizeof(string2),"[Glasanje]: %s (%d) se izlogovao, glasanje je zavrseno!",plname,playerid);
  39. SendClientMessageToAll(TEAM_GROVE_COLOR,string2);
  40. votetimer1 = SetTimer("ResetVotation",300000,false);
  41. }
  42.  
  43. if(Tazer[playerid] == 1) { SafeGivePlayerWeapon(playerid, 24, PreTazerAmmo[playerid]); }
  44. Delete3DTextLabel(DutyLabel[playerid]);
  45. TextDrawHideForPlayer(playerid, DutyTD);
  46. Delete3DTextLabel(NovajlijaLabel[playerid]);
  47. Delete3DTextLabel(AfkLabel[playerid]);
  48. gActivePlayers[playerid]--;
  49. numplayers--;
  50. RemovePlayerMapIcon(playerid, 37 + playerid);
  51. TextDrawDestroy(InternetTD[playerid]);
  52. TextDrawDestroy(Textdraw1[playerid]);
  53. TextDrawDestroy(Textdraw39[playerid]);
  54. TextDrawDestroy(Textdraw40[playerid]);
  55. TextDrawDestroy(Textdraw41[playerid]);
  56. TextDrawDestroy(Textdraw42[playerid]);
  57. TextDrawDestroy(Textdraw49[playerid]);
  58. TextDrawDestroy(Textdraw51[playerid]);
  59. TextDrawDestroy(Textdraw52[playerid]);
  60. TextDrawDestroy(Textdraw53[playerid]);
  61. TextDrawDestroy(Textdraw54[playerid]);
  62. TextDrawDestroy(Textdraw64[playerid]);
  63. TextDrawDestroy(Textdraw90[playerid]);
  64. TextDrawDestroy(Textdraw91[playerid]);
  65. TextDrawDestroy(Textdraw92[playerid]);
  66. TextDrawDestroy(Textdraw93[playerid]);
  67. TextDrawDestroy(Textdraw94[playerid]);
  68. TextDrawDestroy(Textdraw95[playerid]);
  69. TextDrawDestroy(Zlato[playerid]);
  70. TextDrawDestroy(Ukupno[playerid]);
  71.  
  72. for(new td = 0; td < 17; td++)
  73. {
  74. TextDrawHideForPlayer(playerid, UvodTD[td]);
  75. }
  76. TextDrawHideForPlayer(playerid, Textdraw75);
  77. TextDrawHideForPlayer(playerid, Textdraw80);
  78. TextDrawHideForPlayer(playerid, Textdraw60);
  79. TextDrawHideForPlayer(playerid, Textdraw61);
  80. TextDrawHideForPlayer(playerid, Textdraw62);
  81. TextDrawHideForPlayer(playerid, Textdraw63);
  82. TextDrawHideForPlayer(playerid, lbt);
  83. TextDrawHideForPlayer(playerid, lbb);
  84. KillTimer(InternetTimer[playerid]);
  85. KillTimer(TrainTimer[playerid]);
  86. KillTimer(MoneyTimer[playerid]);
  87. KillTimer(ResetJumpTimer);
  88. KillTimer(ResetSpeeding[playerid]);
  89. KillTimer(stopactimer[playerid]);
  90. KillTimer(forbcartimer[playerid]);
  91. KillTimer(stopanticheat[playerid]);
  92. KillTimer(VuciTimer[playerid]);
  93. KillTimer(RobGymTimer[playerid]);
  94. KillTimer(RobBankTimer[playerid]);
  95. KillTimer(PljackaTrafikeTimer[playerid]);
  96. KillTimer(RobCityHallTimer[playerid]);
  97. KillTimer(RobDonutTimer[playerid]);
  98. KillTimer(RobAlhambraTimer[playerid]);
  99. KillTimer(RobBarTimer[playerid]);
  100. KillTimer(RobBurgerTimer[playerid]);
  101. KillTimer(RobCluckinTimer[playerid]);
  102. KillTimer(RobPizzaTimer[playerid]);
  103. if(IsPlayerInEVehicle[playerid] != 9999)
  104. {
  105. new i = IsPlayerInEVehicle[playerid];
  106. Seats[i] --;
  107. }
  108. new string[24];
  109. new d,m,y,h,mi,s;
  110. getdate(y,m,d);
  111. gettime(h,mi,s);
  112. format(string, sizeof(string), "%d/%d/%d at %d:%d:%d",d,m,y,h,mi,s);
  113. strmid(PlayerInfo[playerid][pLastSeen], string, 0, strlen(string), 255);
  114. if(reason == 0)
  115. {
  116. textreason = "Crashed";
  117. strmid(PlayerInfo[playerid][pWhyLeft], "Crashed", 0, strlen("Crashed"), 255);
  118. format(string2, sizeof(string2),"[INFO]: %s je izasao sa Servera. [%s]",plname, textreason);
  119. SendAdminMessage(COLOR_GREEN, string2);
  120. }
  121. else if(reason == 1)
  122. {
  123. textreason = "Leaving";
  124. strmid(PlayerInfo[playerid][pWhyLeft], "Leaving", 0, strlen("Leaving"), 255);
  125. format(string2, sizeof(string2),"[INFO]: %s je izasao sa Servera. [%s]",plname, textreason);
  126. SendAdminMessage(COLOR_GREEN, string2);
  127. }
  128. else if(reason == 2)
  129. {
  130. strmid(PlayerInfo[playerid][pWhyLeft], "Kickovan/Banovan", 0, strlen("Kickovan/Banovan"), 255);
  131. }
  132. SaveGuns(playerid);
  133. OnPlayerUpdateEx(playerid);
  134. if(OfficerCourseStep[playerid] != 255)
  135. {
  136. SafeGivePlayerMoney(playerid, -2500);
  137. }
  138. if(OnOfficerTest[playerid] != 0)
  139. {
  140. SafeGivePlayerMoney(playerid, -5000);
  141. }
  142. if(ServerRestarted == 0)
  143. {
  144. UpdatePlayerPosition(playerid)
  145. }
  146. KillTimer(ChangeNameTimer);
  147.  
  148. foreach(Player, i)
  149. {
  150. if(IsPlayerConnected(i))
  151. {
  152. if(TaxiAccepted[i] < 999)
  153. {
  154. if(TaxiAccepted[i] == playerid)
  155. {
  156. TaxiAccepted[i] = 999;
  157. GameTextForPlayer(i, "~w~Pozivalac Taxija~n~~r~je napustio igru", 5000, 1);
  158. TaxiCallTime[i] = 0;
  159. DisablePlayerCheckpoint(i);
  160. }
  161. }
  162. else if(BusAccepted[i] < 999)
  163. {
  164. if(BusAccepted[i] == playerid)
  165. {
  166. BusAccepted[i] = 999;
  167. GameTextForPlayer(i, "~w~Pozivalac Autobusa~n~~r~je napustio igru", 5000, 1);
  168. BusCallTime[i] = 0;
  169. DisablePlayerCheckpoint(i);
  170. }
  171. }
  172. }
  173. }
  174. if(PlayerInfo[playerid][Admin] >= 1)
  175. {
  176. admins --;
  177. if(AFK[playerid] == 1)
  178. {
  179. afkadmins --;
  180. }
  181. }
  182. KillTimer(DildoTimerReset);
  183. if(TransportCost[playerid] > 0 && TransportDriver[playerid] < 999)
  184. {
  185. if(IsPlayerConnected(TransportDriver[playerid]))
  186. {
  187. new string5[64];
  188. TransportMoney[TransportDriver[playerid]] += TransportCost[playerid];
  189. TransportTime[TransportDriver[playerid]] = 0;
  190. TransportCost[TransportDriver[playerid]] = 0;
  191. format(string5, sizeof(string5), "~w~Passenger left~n~~g~Earned $%d",TransportCost[playerid]);
  192. GameTextForPlayer(TransportDriver[playerid], string5, 5000, 1);
  193. }
  194. }
  195. if(GotHit[playerid] > 0)
  196. {
  197. if(GetChased[playerid] < 999)
  198. {
  199. if(IsPlayerConnected(GetChased[playerid]))
  200. {
  201. SCM(GetChased[playerid], COLOR_YELLOW, "Vasa meta je otisla sa servera.");
  202. GoChase[GetChased[playerid]] = 999;
  203. }
  204. }
  205. }
  206. if(PlayersChannel[playerid] < 999)
  207. {
  208. IRCInfo[PlayersChannel[playerid]][iPlayers] -= 1;
  209. }
  210. if(HireCar[playerid] != 9999)
  211. {
  212. //gLastDriver[HireCar[playerid]] = 300;
  213. //gCarLock[HireCar[playerid]] = 0;
  214. UnLockCar(HireCar[playerid]);
  215. if(reason != 0)
  216. {
  217. SetVehicleToRespawn(HireCar[playerid]);
  218. }
  219. }
  220. if(GangCar[playerid] != 512)
  221. {
  222. //gLastDriver[GangCar[playerid]] = 520;
  223. //gCarLock[GangCar[playerid]] = 0;
  224. UnLockCar(GangCar[playerid]);
  225. }
  226. if(gLastCar[playerid] > 0)
  227. {
  228. //gLastDriver[gLastCar[playerid]] = 300;
  229. if(PlayerInfo[playerid][pHouseKey] != gLastCar[playerid]-1)
  230. {
  231. //gCarLock[gLastCar[playerid]] = 0;
  232. UnLockCar(gLastCar[playerid]);
  233. }
  234. }
  235. if(PlayerBoxing[playerid] > 0)
  236. {
  237. if(Bokser1 == playerid)
  238. {
  239. if(IsPlayerConnected(Bokser2))
  240. {
  241. PlayerBoxing[Bokser2] = 0;
  242. SafeSetPlayerPos(Bokser2, 765.8433,3.2924,1000.7186);
  243. SafeSetPlayerInterior(Bokser2, 5);
  244. GameTextForPlayer(Bokser2, "~r~Mec je prekinut", 5000, 1);
  245. }
  246. }
  247. else if(Bokser2 == playerid)
  248. {
  249. if(IsPlayerConnected(Bokser1))
  250. {
  251. PlayerBoxing[Bokser1] = 0;
  252. SafeSetPlayerPos(Bokser1, 765.8433,3.2924,1000.7186);
  253. SafeSetPlayerInterior(Bokser1, 5);
  254. GameTextForPlayer(Bokser1, "~r~Mec je prekinut", 5000, 1);
  255. }
  256. }
  257. InRing = 0;
  258. RoundStarted = 0;
  259. Bokser1 = 255;
  260. Bokser2 = 255;
  261. TBokser = 255;
  262. }
  263. if(TransportDuty[playerid] == 1)
  264. {
  265. TaxiDrivers -= 1;
  266. }
  267. else if(TransportDuty[playerid] == 2)
  268. {
  269. BusDrivers -= 1;
  270. }
  271. else if(PlayerInfo[playerid][pJob] == 7)
  272. {
  273. if(JobDuty[playerid] == 1) { Mechanics -= 1; }
  274. }
  275. else if(PlayerInfo[playerid][pJob] == 17)
  276. {
  277. if(JobDuty[playerid] == 1) { PizzaBoys -= 1; }
  278. }
  279. if(PlayerInfo[playerid][pRoadblock] != 0)
  280. {
  281. RemoveRoadblock(playerid);
  282. }
  283. BusrouteEast[playerid][0] = 0;
  284. BusrouteWest[playerid][0] = 0;
  285. IsInBus[playerid] = 0;
  286. KillTimer(SacuvajNalog[playerid]);
  287. KillTimer(ACTimer[playerid]);
  288. if(IsBeingSpeced[playerid] == 1)//If the player being spectated, disconnects, then turn off the spec mode for the spectator.
  289. {
  290. TogglePlayerSpectating(spectatorid[playerid],0);// This justifies what's above, if it's not off then you'll be either spectating your connect screen, or somewhere in blueberry (I don't know why)
  291. }
  292. if(usingcarwash == playerid)
  293. {
  294. SetVehicleToRespawn(GetPlayerVehicleID(playerid));
  295. usingcarwash = -1;
  296. UpdateDynamic3DTextLabelText(entrancetext, 0x008B00FF, "Niko trenutno ne pere kola.\nCena: $150 (/carwash)");
  297. }
  298. if(IDVucenogIgraca[playerid] != 9999)
  299. {
  300. new sendername[MAX_PLAYER_NAME];
  301. GetPlayerName(playerid, sendername, sizeof(sendername));
  302. format(string2, sizeof(string2), "* %s je napustio server, pusteni ste.", sendername);
  303. SCM(IDVucenogIgraca[playerid], COLOR_WHITE, string2);
  304. TogglePlayerControllable(IDVucenogIgraca[playerid], 1);
  305. Vucen[playerid] = 9999;
  306. }
  307. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement