Guest User

Race Boats

a guest
Dec 2nd, 2012
1,245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.18 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3.  
  4. new
  5. RBoats,
  6. SaveBoat[MAX_PLAYERS],
  7. BoatPeople = 6,
  8. TimeBoats,
  9. TimerBoat,
  10. BoatsStarted,
  11. sh3,
  12. Boat1,
  13. Boat2,
  14. Boat3,
  15. Boat4,
  16. Boat5,
  17. Boat6,
  18. SaBoat2,
  19. Float:x3, Float:y3, Float:z3,
  20. PlayerObject[9];
  21.  
  22. public OnPlayerConnect(playerid)
  23. {
  24. SaveBoat[playerid] = 0;
  25. return 1;
  26. }
  27. public OnPlayerCommandText(playerid, cmdtext[])
  28. {
  29. if(SaveBoat[playerid] == 1) return SendClientMessage(playerid, 0xff0000ff, "You cannot use the command!");
  30. return 0;
  31. }
  32. CMD:brace(playerid, params[])
  33. {
  34. #pragma unused params
  35. if(BoatPeople > 0)
  36. {
  37. if(RBoats == 1)
  38. {
  39. if(SaveBoat[playerid] == 0)
  40. {
  41. GetPlayerPos(playerid, x3, y3, z3);
  42. SendClientMessage(playerid, 0xff0000ff, "You enrolled in boat race.");
  43. SaveBoat[playerid] = 1;
  44. BoatPeople--;
  45. SaBoat2++;
  46. }
  47. else
  48. {
  49. SendClientMessage(playerid, 0xff0000ff, "Already you signed up on race");
  50. }
  51. }
  52. else
  53. {
  54. SendClientMessage(playerid, 0xff0000ff, "No ongoing subscription for race!");
  55. }
  56. }
  57. else
  58. {
  59. SendClientMessage(playerid, 0xff0000ff, "No place for race!");
  60. }
  61. return 1;
  62. }
  63. CMD:sbrace(playerid, params[])
  64. {
  65. #pragma unused params
  66. if(RBoats == 0)
  67. {
  68. if(IsPlayerAdmin(playerid))
  69. {
  70. if(BoatsStarted == 0)
  71. {
  72. RBoats = 1;
  73. TimerBoat = SetTimer("Startbrace", 1000, 1);
  74. TimeBoats = 30;
  75. BoatPeople = 6;
  76. sh3 = 0;
  77. SaBoat2 = 0;
  78. }
  79. else
  80. {
  81. SendClientMessage(playerid, 0xff0000ff, "Race on!");
  82. }
  83. }
  84. else
  85. {
  86. SendClientMessage(playerid, 0xff0000ff, "No permission");
  87. }
  88. }
  89. else
  90. {
  91. SendClientMessage(playerid, 0xff0000ff, "One race is already underway!");
  92. }
  93. return 1;
  94. }
  95.  
  96. forward Startbrace();
  97. public Startbrace()
  98. {
  99. TimeBoats--;
  100. new string[256];
  101. format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~w~Race boats!~n~To subscribe write /brace~n~~g~Free places: %d ~n~~p~Will start in %d sec.", BoatPeople, TimeBoats);
  102. GameTextForAll(string, 1000, 3);
  103. if(TimeBoats == 0)
  104. {
  105. KillTimer(TimerBoat);
  106. RBoats = 0;
  107. BoatsStarted = 1;
  108. }
  109. if(TimeBoats == 0)
  110. {
  111. if(SaBoat2 <=0)
  112. {
  113. SendClientMessageToAll(0xff0000ff, "No people in race!");
  114. BoatsStarted = 0;
  115. }
  116. }
  117. for(new i=0; i<GetMaxPlayers(); i++)
  118. {
  119. if(TimeBoats == 0)
  120. {
  121. if(SaveBoat[i] == 1)
  122. {
  123. SetPlayerCheckpoint(i, -41.8892,-598.3351,-0.1207, 15.0);
  124. sh3 = random(6);
  125. if(sh3 == 0)
  126. {
  127. Boat1 = AddStaticVehicle(493,1942.417,-251.958,1.366,349.0,-1,-1);
  128. PutPlayerInVehicle(i, Boat1, 0);
  129. }
  130. else if(sh3 == 1)
  131. {
  132. Boat2 = AddStaticVehicle(493,1951.182,-253.128,1.388,349.0,-1,-1);
  133. PutPlayerInVehicle(i, Boat2, 0);
  134. }
  135. else if(sh3 == 2)
  136. {
  137. Boat3 = AddStaticVehicle(493,1955.429,-230.359,1.426,349.0,-1,-1);
  138. PutPlayerInVehicle(i, Boat3, 0);
  139. }
  140. else if(sh3 == 3)
  141. {
  142. Boat4 = AddStaticVehicle(493,1946.536,-228.397,1.402,349.0,-1,-1);
  143. PutPlayerInVehicle(i, Boat4, 0);
  144. }
  145. else if(sh3 == 4)
  146. {
  147. Boat5 = AddStaticVehicle(493,1961.798,-254.666,1.335,349.0,-1,-1);
  148. PutPlayerInVehicle(i, Boat5, 0);
  149. }
  150. else if(sh3 == 5)
  151. {
  152. Boat6 = AddStaticVehicle(493,1964.774,-231.862,1.401,349.0,-1,-1);
  153. PutPlayerInVehicle(i, Boat6, 0);
  154. }
  155. if(PlayerOnTele(i))
  156. PlayerObject[0] = CreatePlayerObject(i,1655, 1933.348, -158.0981, 1.2938, 0, 0, 11.25);
  157. PlayerObject[1] = CreatePlayerObject(i,1655, 1941.9407, -156.4904, 1.2853, 0, 0, 11.25);
  158. PlayerObject[2] = CreatePlayerObject(i,1655, 1825.3428, -44.8284, 1.2946, 0, 0, 67.5);
  159. PlayerObject[3] = CreatePlayerObject(i,1655, 1685.3217, -16.1496, 1.285, 0, 0, 78.75);
  160. PlayerObject[4] = CreatePlayerObject(i,1655, 1603.8607, -102.9386, 1.2732, 0, 0, 180);
  161. PlayerObject[5] = CreatePlayerObject(i,1634, 1399.4585, -254.9023, 1.2896, 0, 0, 90);
  162. PlayerObject[6] = CreatePlayerObject(i,1634, 1399.4789, -250.7029, 1.3193, 0, 0, 90);
  163. PlayerObject[7] = CreatePlayerObject(i,1655, 1098.5001, -111.0342, 1.3009, 0, 0, 98.5943);
  164. PlayerObject[8] = CreatePlayerObject(i,1655, 676.477, -226.1338, 0.9883, 0, 0, 90);
  165. }
  166. }
  167. }
  168. return 1;
  169. }
  170.  
  171. public OnPlayerEnterCheckpoint(playerid)
  172. {
  173. if(BoatsStarted == 1)
  174. {
  175. if(SaveBoat[playerid] == 1)
  176. {
  177. new string[128];
  178. format(string, sizeof(string), "Player %s won the race, He receives 100000$!", Player(playerid));
  179. GivePlayerMoney(playerid, 100000);
  180. SendClientMessageToAll(0xff0000ff, string);
  181. BoatsStarted = 0;
  182. Deleteq(playerid);
  183. }
  184. for(new i=0; i<GetMaxPlayers(); i++)
  185. {
  186. SetPlayerPos(i, x3, y3, z3);
  187. SaveBoat[i] = 0;
  188. DisablePlayerCheckpoint(i);
  189. }
  190. }
  191. return 1;
  192. }
  193.  
  194.  
  195.  
  196. PlayerOnTele(PlayerId)
  197. {
  198. TogglePlayerControllable(PlayerId, 0);
  199. SetTimerEx("UnfreezePlayer", 2999, false, "d", PlayerId);
  200. return true;
  201. }
  202.  
  203.  
  204. forward UnfreezePlayer(PlayerId);
  205. public UnfreezePlayer(PlayerId)
  206. {
  207. TogglePlayerControllable(PlayerId, 1);
  208. GameTextForPlayer(PlayerId, "~r~Go~p~-Go!", 2499, 3);
  209. return 1;
  210. }
  211.  
  212. stock Deleteq(playerid)
  213. {
  214. for(new o; o != 9; o++)
  215. DestroyPlayerObject(playerid, PlayerObject[o]);
  216. }
  217.  
  218. Player(playerid)
  219. {
  220. new player[MAX_PLAYER_NAME];
  221. GetPlayerName(playerid, player, sizeof(player));
  222. return player;
  223. }
  224.  
  225. public OnPlayerStateChange(playerid, newstate, oldstate)
  226. {
  227. if(oldstate == PLAYER_STATE_DRIVER && SaveBoat[playerid] != -1)
  228. {
  229. BoatPeople--;
  230. SaveBoat[playerid] = 0;
  231. DisablePlayerCheckpoint(playerid);
  232. Deleteq(playerid);
  233. }
  234. return 1;
  235. }
Advertisement
Add Comment
Please, Sign In to add comment