Advertisement
proSeryoga

Untitled

Feb 14th, 2013
2,848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.62 KB | None | 0 0
  1. /*
  2. MTA Derby
  3. */
  4. #include <a_samp>
  5.  
  6. #define ForEach(%0) for(new %0 = 0; %0 != GetServerVarAsInt("maxplayers"); %0++) if(IsPlayerConnected(%0) && !IsPlayerNPC(%0))
  7.  
  8. new DB_VehicleID = 415;
  9.  
  10. #define DB_DIALOG 1111
  11.  
  12. #define MAX_DERBY_SPAWN 2
  13. new Float:DB_Spawns[MAX_DERBY_SPAWN][][] =
  14. {
  15. {
  16. {2580.9543,-2922.2375,1003.8871},{2580.9353,-3040.3372,1003.8871},{2620.9497,-2980.4980,1003.8871},
  17. {2662.5625,-2922.4089,1003.8871},{2682.1228,-2959.8835,1003.8871},{2663.1399,-2999.8201,1003.8871},
  18. {2581.3845,-2962.0913,1003.8871},{2606.0146,-2995.0747,1003.8871},{2601.6973,-2941.1292,1003.8871},
  19. {2581.7783,-2959.8501,1003.8871}
  20. },
  21. {
  22. {3811.2156,-2453.5735,1002.5284},{3828.2717,-2437.7588,1002.5284},{3797.6394,-2471.6860,1002.5284},
  23. {3778.0747,-2452.8750,1002.5284},{3848.7319,-2453.9375,1002.5284},{3828.6216,-2453.9402,1015.5284},
  24. {3797.5637,-2453.8789,1015.5284},{3855.7751,-2472.6580,1015.5284},{3770.3140,-2436.6235,1015.5284},
  25. {3811.2190,-2436.3999,1015.5284}
  26. }
  27. };
  28.  
  29. forward DB_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  30.  
  31.  
  32. new DBP_Stats[MAX_PLAYERS];
  33. new DBP_Vehicle[MAX_PLAYERS];
  34.  
  35. forward DBP_Spawn(playerid);
  36. forward DBP_Exit(playerid);
  37.  
  38. forward LoadCreateObject();
  39. forward SetPlayerPosEx(playerid, Float:x, Float:y, Float:z, Float:ang, int, vw);
  40.  
  41. //DB - Derby. DBP - Derby Player
  42. //==============================================================================
  43. public OnGameModeInit()
  44. {
  45. SetTimer("ServerTimer", 1000, 1);
  46. LoadCreateObject();
  47. return 1;
  48. }
  49.  
  50. public OnPlayerConnect(playerid)
  51. {
  52. DBP_Exit(playerid);
  53. return 1;
  54. }
  55.  
  56. public OnPlayerDisconnect(playerid, reason)
  57. {
  58. DBP_Exit(playerid);
  59. return 1;
  60. }
  61.  
  62. public OnPlayerCommandText(playerid, cmdtext[])
  63. {
  64. if(!strcmp(cmdtext, "/derby", true))
  65. {
  66. if(DBP_Stats[playerid] >= 0) return ShowPlayerDialog(playerid, DB_DIALOG+1, DIALOG_STYLE_MSGBOX, "Derby", "Leave Derby area?", "Ok", "No");
  67. new string[128];
  68. for(new i; i < MAX_DERBY_SPAWN; i++)
  69. {
  70. format(string,sizeof(string),"%sDerby zone {FFCB77}№%d{FFFFFF}.\n",string,i);
  71. }
  72. ShowPlayerDialog(playerid, DB_DIALOG, DIALOG_STYLE_LIST, "Derby - Zone:", string, "Ok", "Exit");
  73. }
  74. return 1;
  75. }
  76.  
  77. public OnPlayerDeath(playerid, killerid, reason)
  78. {
  79. DBP_Exit(playerid);
  80. return 1;
  81. }
  82.  
  83. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  84. {
  85. DB_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  86. return 1;
  87. }
  88.  
  89. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  90. {
  91. switch(dialogid)
  92. {
  93. case DB_DIALOG:
  94. {
  95. if(!response) return 1;
  96. if(DBP_Stats[playerid] >= 0)
  97. {
  98. ShowPlayerDialog(playerid, 15157, DIALOG_STYLE_MSGBOX, "Derby", "You are already in Derby", " ", "");
  99. return 1;
  100. }
  101. DBP_Stats[playerid] = listitem;
  102. new RandomDerby = random(sizeof(DB_Spawns));
  103. SetPlayerPosEx(playerid, DB_Spawns[DBP_Stats[playerid]][RandomDerby][0], DB_Spawns[DBP_Stats[playerid]][RandomDerby][1], DB_Spawns[DBP_Stats[playerid]][RandomDerby][2]+2, random(360), 0, 1);
  104. DBP_Vehicle[playerid] = CreateVehicle(DB_VehicleID,DB_Spawns[DBP_Stats[playerid]][RandomDerby][0], DB_Spawns[DBP_Stats[playerid]][RandomDerby][1], DB_Spawns[DBP_Stats[playerid]][RandomDerby][2]+2,0,random(126), random(126),50000);
  105. }
  106. case DB_DIALOG+1:
  107. {
  108. if(!response) return 1;
  109. DBP_Exit(playerid);
  110. }
  111. }
  112. return 1;
  113. }
  114.  
  115. forward ServerTimer();
  116. public ServerTimer()
  117. {
  118. ForEach(playerid)
  119. {
  120. if(DBP_Stats[playerid] >= 0)
  121. {
  122. new Float: pPos[4];
  123. new Float:vehhp;
  124. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  125. {
  126. GetVehiclePos(GetPlayerVehicleID(playerid),pPos[0],pPos[1],pPos[2]);
  127. GetVehicleHealth(GetPlayerVehicleID(playerid), vehhp);
  128. }
  129. if(pPos[2] <= 990 || GetPlayerState(playerid) != PLAYER_STATE_DRIVER || vehhp < 250.0)
  130. {
  131. DBP_Spawn(playerid);
  132. }
  133. }
  134. }
  135. return 1;
  136. }
  137.  
  138. public DB_OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  139. {
  140. if(((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION)) || ((newkeys & 1024) && !(oldkeys & 1024)) )
  141. {
  142. if(DBP_Stats[playerid] == -1) return 1;
  143. ShowPlayerDialog(playerid, DB_DIALOG+1, DIALOG_STYLE_MSGBOX, "Derby", "Leave Derby area??", "Ok", "No");
  144. }
  145. return 1;
  146. }
  147.  
  148. public DBP_Spawn(playerid)
  149. {
  150. if(DBP_Stats[playerid] == -1) return 1;
  151. new RandomDerby = random(10);
  152.  
  153. SetPlayerPosEx(playerid, DB_Spawns[DBP_Stats[playerid]][RandomDerby][0], DB_Spawns[DBP_Stats[playerid]][RandomDerby][1], DB_Spawns[DBP_Stats[playerid]][RandomDerby][2]+2, random(360), 0, 1);
  154.  
  155. DestroyVehicle(DBP_Vehicle[playerid]);
  156. DBP_Vehicle[playerid] = CreateVehicle(DB_VehicleID,DB_Spawns[DBP_Stats[playerid]][RandomDerby][0], DB_Spawns[DBP_Stats[playerid]][RandomDerby][1], DB_Spawns[DBP_Stats[playerid]][RandomDerby][2]+2,0,random(126), random(126),50000);
  157.  
  158. ResetPlayerWeapons(playerid);
  159. SetVehicleVirtualWorld(DBP_Vehicle[playerid],GetPlayerVirtualWorld(playerid));
  160. LinkVehicleToInterior(DBP_Vehicle[playerid],GetPlayerInterior(playerid));
  161. PutPlayerInVehicle(playerid, DBP_Vehicle[playerid], 0);
  162. return 1;
  163. }
  164.  
  165. public DBP_Exit(playerid)
  166. {
  167. if(DBP_Stats[playerid] == -1) return 1;
  168. DestroyVehicle(DBP_Vehicle[playerid]);
  169. DBP_Stats[playerid] = -1;
  170. SpawnPlayer(playerid);
  171. return 1;
  172. }
  173.  
  174. public SetPlayerPosEx(playerid, Float:x, Float:y, Float:z, Float:ang, int, vw)
  175. {
  176. SetPlayerPos(playerid, x, y, z);
  177. SetPlayerFacingAngle(playerid, ang);
  178. SetPlayerInterior(playerid, int);
  179. SetPlayerVirtualWorld(playerid, vw);
  180. SetCameraBehindPlayer(playerid);
  181. return 1;
  182. }
  183.  
  184. public LoadCreateObject()
  185. {
  186. //Derby 1:------------------------------------------------------------------
  187. CreateObject(8558,2583.55273438,-2921.90820312,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  188. CreateObject(8558,2623.75903320,-2921.92407227,1001.35871506,0.00000000,0.00000000,0.00000000); // 2)
  189. CreateObject(8558,2663.91845703,-2921.92724609,1001.35871506,0.00000000,0.00000000,0.00000000); // 3)
  190. CreateObject(8558,2681.58496094,-2943.59521484,1001.35871506,0.00000000,0.00000000,90.00000000); // 4)
  191. CreateObject(8558,2681.58984375,-2983.88793945,1001.35871506,0.00000000,0.00000000,90.00000000); // 5)
  192. CreateObject(8558,2681.56201172,-3024.05273438,1001.35871506,0.00000000,0.00000000,90.00000000); // 6)
  193. CreateObject(8558,2658.91650391,-3041.70947266,1001.35871506,0.00000000,0.00000000,180.00000000); // 7)
  194. CreateObject(8558,2618.93896484,-3041.70922852,1001.35871506,0.00000000,0.00000000,179.99450684); // 8)
  195. CreateObject(8558,2579.22973633,-3041.67895508,1001.35871506,0.00000000,0.00000000,179.99450684); // 9)
  196. CreateObject(8558,2561.60351562,-3019.28930664,1001.35871506,0.00000000,0.00000000,90.00000000); // 10)
  197. CreateObject(8558,2561.60791016,-2979.25610352,1001.35871506,0.00000000,0.00000000,90.00000000); // 11)
  198. CreateObject(8558,2561.60058594,-2939.54589844,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  199. CreateObject(8558,2561.60351562,-3019.28906250,1001.35871506,0.00000000,0.00000000,90.00000000); // 13)
  200. CreateObject(8558,2583.98046875,-2978.90551758,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  201. CreateObject(8558,2658.91259766,-2978.71704102,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  202. CreateObject(8558,2622.16528320,-3019.43432617,1001.35871506,0.00000000,0.00000000,90.00000000); // 13)
  203. CreateObject(8558,2622.04321289,-2941.63378906,1001.35871506,0.00000000,0.00000000,90.00000000); // 13)
  204. CreateObject(1634,2621.95776367,-2959.33129883,1003.68449116,0.00000000,0.00000000,180.00000000); // 1)
  205. CreateObject(1634,2600.51269531,-2978.81298828,1003.68449116,0.00000000,0.00000000,270.00000000); // 2)
  206. CreateObject(1634,2622.16284180,-3003.88330078,1003.68449116,0.00000000,0.00000000,0.00000000); // 3)
  207. CreateObject(1634,2643.73681641,-2978.61230469,1003.68449116,0.00000000,0.00000000,90.00000000); // 4)
  208. CreateObject(8558,2581.15527344,-2958.77563477,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  209. CreateObject(8558,2581.12744141,-2942.96484375,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  210. CreateObject(8558,2583.78588867,-2960.45166016,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  211. CreateObject(8558,2582.97290039,-2940.23608398,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  212. CreateObject(8558,2601.40527344,-2942.78515625,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  213. CreateObject(8558,2613.96875000,-2972.66796875,1001.35871506,0.00000000,0.00000000,136.00000000); // 12)
  214. CreateObject(8558,2627.50952148,-2985.75268555,1001.35871506,0.00000000,0.00000000,136.00003052); // 12)
  215. CreateObject(8558,2662.98852539,-2997.44946289,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  216. CreateObject(8558,2662.98754883,-3020.35913086,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  217. CreateObject(8558,2660.61303711,-3000.07495117,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  218. CreateObject(8558,2660.71166992,-3021.18383789,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  219. CreateObject(8558,2642.74194336,-3020.76025391,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  220. CreateObject(8558,2617.92700195,-2982.91992188,1001.35871506,0.00000000,0.00000000,226.25000000); // 12)
  221. CreateObject(8558,2581.16992188,-2996.62011719,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  222. CreateObject(8558,2581.16650391,-3020.93725586,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  223. CreateObject(8558,2583.53076172,-2997.95751953,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  224. CreateObject(8558,2583.85302734,-3021.10888672,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  225. CreateObject(8558,2603.62939453,-3017.48510742,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  226. CreateObject(8558,2603.62231445,-3021.84985352,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  227. CreateObject(8558,2662.96679688,-2963.67480469,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  228. CreateObject(8558,2662.94287109,-2939.53588867,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  229. CreateObject(8558,2660.06127930,-2960.21826172,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  230. CreateObject(8558,2659.75219727,-2940.42773438,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  231. CreateObject(8558,2625.03808594,-2975.54052734,1001.35871506,0.00000000,0.00000000,226.24694824); // 12)
  232. CreateObject(8558,2639.40380859,-2941.73388672,1001.35871506,0.00000000,0.00000000,90.00000000); // 12)
  233. CreateObject(8558,2621.37939453,-2940.33618164,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  234. CreateObject(8558,2621.35986328,-3021.18725586,1001.35871506,0.00000000,0.00000000,0.00000000); // 1)
  235.  
  236. //Derby 2:------------------------------------------------------------------
  237. CreateObject(8558,3795.19995117,-2472.10009766,48.00000000+952,0.00000000,0.00000000,0.00000000); // 1)
  238. CreateObject(8558,3830.60009766,-2472.10009766,48.00000000+952,0.00000000,0.00000000,0.00000000); // 2)
  239. CreateObject(8558,3828.19995117,-2454.30004883,48.00000000+952,0.00000000,0.00000000,90.00000000); // 3)
  240. CreateObject(8558,3797.60009766,-2454.30004883,48.00000000+952,0.00000000,0.00000000,90.00000000); // 4)
  241. CreateObject(8558,3795.19995117,-2436.80004883,48.00000000+952,0.00000000,0.00000000,0.00000000); // 5)
  242. CreateObject(8558,3830.60009766,-2436.80004883,48.00000000+952,0.00000000,0.00000000,0.00000000); // 6)
  243. CreateObject(8558,3849.30004883,-2454.30004883,48.00000000+952,0.00000000,0.00000000,90.00000000); // 7)
  244. CreateObject(8558,3777.69995117,-2454.30004883,48.00000000+952,0.00000000,0.00000000,90.00000000); // 8)
  245. CreateObject(8558,3770.00000000,-2454.30004883,61.00000000+952,0.00000000,0.00000000,90.00000000); // 9)
  246. CreateObject(8558,3789.30004883,-2453.50000000,51.09999847+952,0.00000000,30.00000000,0.00000000); // 10)
  247. CreateObject(8558,3810.50000000,-2453.50000000,48.00000000+952,0.00000000,0.00000000,0.00000000); // 11)
  248. CreateObject(8558,3836.50000000,-2453.50000000,51.09999847+952,0.00000000,30.00000000,180.00000000); // 12)
  249. CreateObject(8558,3855.30004883,-2454.30004883,61.00000000+952,0.00000000,0.00000000,90.00000000); // 14)
  250. CreateObject(8558,3832.55004883,-2472.00000000,61.00000000+952,0.00000000,0.00000000,0.00000000); // 15)
  251. CreateObject(8558,3792.30004883,-2472.00000000,61.00000000+952,0.00000000,0.00000000,0.00000000); // 16)
  252. CreateObject(8558,3832.55004883,-2436.66992188,61.00000000+952,0.00000000,0.00000000,0.00000000); // 17)
  253. CreateObject(8558,3792.30004883,-2436.66992188,61.00000000+952,0.00000000,0.00000000,0.00000000); // 18)
  254. CreateObject(8558,3797.60009766,-2454.30004883,61.00000000+952,0.00000000,0.00000000,90.00000000); // 19)
  255. CreateObject(8558,3828.19995117,-2454.30004883,61.00000000+952,0.00000000,0.00000000,90.00000000); //20)
  256. return 1;
  257. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement