Advertisement
Guest User

Untitled

a guest
Oct 26th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.17 KB | None | 0 0
  1. public OnPlayerDisconnect(playerid, reason) {
  2. /* #if defined DEBUG
  3. printf("[debug] OnPlayerDisconnect(%d, %d)", playerid, reason);
  4. #endif*/
  5.  
  6. if(RefuelingVehicle[playerid] == 2) { DestroyObject(FillGasObject[playerid]); }
  7. LuX_SpeedoMeter[playerid] = 0;
  8. FadePlayerDisconnect(playerid);
  9. //===================================================
  10. Delete3DTextLabel(injuredLabel[playerid]);
  11. TextDrawDestroy(DescriptionText[playerid]);
  12. KillTimer(playerspeedtimer[playerid]);
  13. KillTimer(CrashTimer[playerid]);
  14. IsSpeeding[playerid] = false;
  15.  
  16. //===================================================
  17.  
  18. if(playerVariables[playerid][pStatus] >= 1) {
  19. new vehicleid = GetPlayerVehicleID(playerid);
  20. if(testDrive[playerid] == vehicleid){
  21. new dID = GetPVarInt(playerid,"dID");
  22. RemovePlayerFromVehicle(playerid);
  23. SetPlayerPos(playerid, dealershipVariables[dID][dSPosX],dealershipVariables[dID][dSPosY],dealershipVariables[dID][dSPosZ]);
  24. SendClientMessageEx(playerid,COLOR_GREY,"Waktu anda waktu test drive anda sudah habis.");
  25. KillTimer(GetPVarInt(playerid, "testDrive"));
  26. DestroyVehicle(testDrive[playerid]);
  27. testDrive[playerid] = INVALID_VEHICLE_ID;
  28. }
  29. if(playerVariables[playerid][pWExists] == 1){
  30. WeedLogout(playerid);
  31. }
  32. testDrive[playerid] = INVALID_VEHICLE_ID;
  33. kabur[playerid] = 0;
  34. DMVTime[playerid] = 0;
  35. if(gBike[playerid] >= 0 && gBikeRenting[playerid] == 1){
  36. gBike[playerid] = 0;
  37. gBikeRenting[playerid] = 0;
  38. KillTimer(GetPVarInt(playerid, "RentTime"));
  39. }
  40.  
  41. GarbageTruck[playerid] = INVALID_VEHICLE_ID;
  42. jumlahSampah[playerid] = 0;
  43.  
  44. if(GetPVarInt(playerid, "Injured") == 1){
  45. playerVariables[playerid][pHospitalized] = 1;
  46. }
  47.  
  48. if (GetPVarInt(playerid, "HungerBar") == 1)
  49. {
  50. DeletePVar(playerid, "HungerBar");
  51. DeletePVar(playerid, "hTimerOn");
  52. }
  53. if (GetPVarInt(playerid, "EnergyBar") == 1)
  54. {
  55. DeletePVar(playerid, "EnergyBar");
  56. DeletePVar(playerid, "eTimerOn");
  57. }
  58. if (GetPVarInt(playerid, "BladderBar") == 1)
  59. {
  60. DeletePVar(playerid, "BladderBar");
  61. DeletePVar(playerid, "bTimerOn");
  62. }
  63. if (GetPVarInt(playerid, "ConditionBar") == 1)
  64. {
  65. DeletePVar(playerid, "ConditionBar");
  66. DeletePVar(playerid, "cTimerOn");
  67. }
  68. FirstSpawn[playerid] = 0;
  69. KillTimer(PBHTimer[playerid]);
  70. KillTimer(PBETimer[playerid]);
  71. KillTimer(PBBTimer[playerid]);
  72. KillTimer(PBCTimer[playerid]);
  73.  
  74. playerVariables[playerid][pStatus] = -1;
  75. foreach(Player, x) {
  76. if(playerVariables[x][pSpectating] == playerid) {
  77.  
  78. playerVariables[x][pSpectating] = INVALID_PLAYER_ID;
  79.  
  80. TogglePlayerSpectating(x, false);
  81. SetCameraBehindPlayer(x);
  82.  
  83. SetPlayerPos(x, playerVariables[x][pPos][0], playerVariables[x][pPos][1], playerVariables[x][pPos][2]);
  84. SetPlayerInterior(x, playerVariables[x][pInterior]);
  85. SetPlayerVirtualWorld(x, playerVariables[x][pVirtualWorld]);
  86.  
  87. TextDrawHideForPlayer(x, textdrawVariables[4]);
  88.  
  89. SendClientMessage(x, COLOR_GREY, "The player you were spectating has disconnected.");
  90. }
  91. }
  92. if(playerVariables[playerid][pAdminDuty] >= 1) {
  93. SetPlayerName(playerid, playerVariables[playerid][pNormalName]);
  94. }
  95.  
  96. if(playerVariables[playerid][pFreezeType] >= 1 && playerVariables[playerid][pFreezeType] <= 4)
  97. {
  98. playerVariables[playerid][pPrisonTime] = 900;
  99. playerVariables[playerid][pPrisonID] = 2;
  100. }
  101. if(WatchingTV[playerid] == 1)
  102. {
  103. playerVariables[playerid][pInterior] = BroadcastLastInt[playerid];
  104. playerVariables[playerid][pVirtualWorld] = BroadcastLastVW[playerid];
  105. WatchingTV[playerid] = 0;
  106. viewers--;
  107. UpdateSANewsBroadcast();
  108. }
  109.  
  110. if(playerVariables[playerid][pDrag] != -1) {
  111. SendClientMessage(playerVariables[playerid][pDrag], COLOR_WHITE, "The person you were dragging has disconnected.");
  112. playerVariables[playerVariables[playerid][pDrag]][pDrag] = -1; // Kills off any disconnections.
  113. }
  114. if(playerVariables[playerid][pPhoneCall] != -1 && playerVariables[playerid][pPhoneCall] < MAX_PLAYERS) {
  115.  
  116. SendClientMessage(playerVariables[playerid][pPhoneCall], COLOR_WHITE, "Sambungan telepon anda terputus.");
  117.  
  118. if(GetPlayerSpecialAction(playerVariables[playerid][pPhoneCall]) == SPECIAL_ACTION_USECELLPHONE) {
  119. SetPlayerSpecialAction(playerVariables[playerid][pPhoneCall], SPECIAL_ACTION_STOPUSECELLPHONE);
  120. RemovePlayerAttachedObject(playerVariables[playerid][pPhoneCall], 0);
  121. }
  122.  
  123. playerVariables[playerVariables[playerid][pPhoneCall]][pPhoneCall] = -1;
  124. }
  125. if(GetPVarInt(playerid, "HaveADO") == 1) RemovePlayerADO(playerid);
  126.  
  127. saveRentData(playerid);
  128. DestroyVehicle(PlayerRentInfo[playerid][prId]);
  129.  
  130. savePlayerData(playerid);
  131.  
  132. for(new x=0; x<MAX_PLAYER_VEHICLE; x++)
  133. {
  134. if(playerVariables[playerid][pCarID][x] >= INVALID_PLAYER_VEHICLE_ID)
  135. {
  136. for(new vt = 0; vt < MAX_OBJECTS_PER_PLAYER; vt++)
  137. {
  138. DestroyObject(PlayerVehicleInfo[playerid][x][pvToy][vt]);
  139. }
  140. KillTimer(playerVariables[playerid][pCarFlashTime][x]);
  141. RemoveVehSS(playerVariables[playerid][pCarID][x]);
  142. KillTimer(playerVariables[playerid][pCarFlashTime][x]);
  143. DestroyObject(playerVariables[playerid][pNeonObj][x]);
  144. DestroyObject(playerVariables[playerid][pNeonObj2][x]);
  145. DestroyObject(playerVariables[playerid][pNeonObj3][x]);
  146. DestroyObject(playerVariables[playerid][pNeonObj4][x]);
  147. playerVariables[playerid][pCarNeonUse][x] = 0;
  148. // DestroyObject(playerVariables[extraid][pVehicleObjectModel][0]);
  149. // DestroyObject(playerVariables[extraid][pVehicleObjectModel][1]);
  150. DestroyVehicle(playerVariables[playerid][pCarID][x]);
  151. playerVariables[playerid][pCarID][x] = INVALID_PLAYER_VEHICLE_ID;
  152. systemVariables[vehicleCounts][1]--;
  153. }
  154. }
  155.  
  156. saveVehicleData(playerid);
  157.  
  158. new
  159. string[128];
  160.  
  161. if(playerVariables[playerid][pAdminLevel] < 1) {
  162. switch(reason) {
  163. case 1: format(string, sizeof(string), "%s telah meninggalkan server (leaving).", playerVariables[playerid][pNormalName]);
  164. case 2: format(string, sizeof(string), "%s telah meninggalkan server (banned/kicked).", playerVariables[playerid][pNormalName]);
  165. default: format(string, sizeof(string), "%s telah meninggalkan server (timeout).", playerVariables[playerid][pNormalName]);
  166. }
  167. nearByMessage(playerid, COLOR_GENANNOUNCE, string);
  168. submitToAdmins(string,COLOR_LIGHTBLUE);
  169. }
  170.  
  171. if(playerVariables[playerid][pGroup] >= 1) {
  172. switch(reason) {
  173. case 0: {
  174. format(string, sizeof(string), "%s telah meninggalkan server/group (timeout).", playerVariables[playerid][pNormalName]);
  175. }
  176. case 1: {
  177. format(string, sizeof(string), "%s telah meninggalkan server/group (leaving).", playerVariables[playerid][pNormalName]);
  178. }
  179. case 2: {
  180. format(string, sizeof(string), "%s telah meninggalkan server/group (banned/kicked).", playerVariables[playerid][pNormalName]);
  181. }
  182. }
  183.  
  184. SendToGroup(playerVariables[playerid][pGroup], COLOR_GENANNOUNCE, string);
  185. }
  186.  
  187. DeletePVar(playerid,"Cash");
  188.  
  189. if(playerVariables[playerid][pEvent] >= 1) {
  190.  
  191. eventVariables[eEventCount]--;
  192. playerVariables[playerid][pEvent] = 0;
  193. ResetPlayerWeapons(playerid);
  194.  
  195. if(eventVariables[eEventCount] <= 1) {
  196.  
  197. new
  198. iCount;
  199.  
  200. foreach(Player, i) {
  201. if(playerVariables[i][pEvent] >= 1) {
  202.  
  203. TogglePlayerControllable(i, true);
  204.  
  205. ResetPlayerWeapons(i);
  206. givePlayerWeapons(i);
  207.  
  208. SetPlayerPos(i, playerVariables[i][pPos][0], playerVariables[i][pPos][1], playerVariables[i][pPos][2]);
  209. SetPlayerInterior(i, playerVariables[i][pInterior]);
  210. SetPlayerVirtualWorld(i, playerVariables[i][pVirtualWorld]);
  211. SetPlayerSkin(i, playerVariables[i][pSkin]);
  212. SetCameraBehindPlayer(i);
  213.  
  214. iCount++;
  215. GetPlayerName(i, szPlayerName, MAX_PLAYER_NAME);
  216.  
  217. SetPlayerHealth(i, playerVariables[i][pHealth]);
  218. SetPlayerArmour(i, playerVariables[i][pArmour]);
  219. playerVariables[i][pEvent] = 0;
  220.  
  221. }
  222. }
  223. if(iCount == 1) {
  224. format(string, sizeof(string), "%s has won the event by default (after %s disconnected) - congratulations!", szPlayerName, playerVariables[playerid][pNormalName]);
  225. SendClientMessageToAll(COLOR_LIGHTRED, string);
  226. }
  227. else {
  228. format(string, sizeof(string), "The event has ended (no participants left, %s disconnected).",playerVariables[playerid][pNormalName]);
  229. SendClientMessageToAll(COLOR_LIGHTRED, string);
  230. }
  231.  
  232. eventVariables[eEventStat] = 0;
  233. eventVariables[eEventCount] = 0;
  234.  
  235. eventVariables[eEventSkin] = 0;
  236. }
  237. else {
  238. switch(reason) {
  239. case 0: format(string, sizeof(string), "%s telah meninggalkan server/event (timeout). Dari %d peserta.", playerVariables[playerid][pNormalName], eventVariables[eEventCount]);
  240. case 1: format(string, sizeof(string), "%s telah meninggalkan server/event (leaving). Dari %d peserta.", playerVariables[playerid][pNormalName], eventVariables[eEventCount]);
  241. case 2: format(string, sizeof(string), "%s telah meninggalkan server/event (kicked/banned). Dari %d peserta.", playerVariables[playerid][pNormalName], eventVariables[eEventCount]);
  242. }
  243. SendToEvent(COLOR_YELLOW, string);
  244. }
  245. }
  246. }
  247. return 1;
  248. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement