Guest User

Race Boats v1.1

a guest
Dec 2nd, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.43 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 joined in RaceBoat");
  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:resrace(playerid, params[])
  64. {
  65. #pragma unused params
  66. if(BoatPeople > 0){
  67. SaveBoat[playerid] = 0;
  68. BoatsStarted = 0;
  69. Deleteq(playerid);
  70. KillTimer(TimerBoat);
  71. SendClientMessage(playerid, 0xff0000ff, "Race has been reset!");}
  72. return 1;}
  73.  
  74. CMD:sbrace(playerid, params[])
  75. {
  76. #pragma unused params
  77. if(RBoats == 0)
  78. {
  79. if(IsPlayerAdmin(playerid))
  80. {
  81. if(BoatsStarted == 0)
  82. {
  83. RBoats = 1;
  84. TimerBoat = SetTimer("Startbrace", 1000, 1);
  85. TimeBoats = 30;
  86. BoatPeople = 6;
  87. sh3 = 0;
  88. SaBoat2 = 0;
  89. }
  90. else
  91. {
  92. SendClientMessage(playerid, 0xff0000ff, "Race on!");
  93. }
  94. }
  95. else
  96. {
  97. SendClientMessage(playerid, 0xff0000ff, "No permission");
  98. }
  99. }
  100. else
  101. {
  102. SendClientMessage(playerid, 0xff0000ff, "One race is already underway!");
  103. }
  104. return 1;}
  105.  
  106. forward Startbrace();
  107. public Startbrace()
  108. {
  109. TimeBoats--;
  110. new string[256];
  111. 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);
  112. GameTextForAll(string, 1000, 3);
  113. if(TimeBoats == 0)
  114. {
  115. KillTimer(TimerBoat);
  116. RBoats = 0;
  117. BoatsStarted = 1;
  118. }
  119. if(TimeBoats == 0)
  120. {
  121. if(SaBoat2 <=0)
  122. {
  123. SendClientMessageToAll(0xff0000ff, "No people in race!");
  124. BoatsStarted = 0;
  125. }
  126. }
  127. for(new i=0; i<GetMaxPlayers(); i++)
  128. {
  129. if(TimeBoats == 0)
  130. {
  131. if(SaveBoat[i] == 1)
  132. {
  133. SetPlayerCheckpoint(i, -41.8892,-598.3351,-0.1207, 15.0);
  134. sh3 = random(6);
  135. if(sh3 == 0)
  136. {
  137. Boat1 = AddStaticVehicle(493,1942.417,-251.958,1.366,349.0,-1,-1);
  138. PutPlayerInVehicle(i, Boat1, 0);
  139. }
  140. else if(sh3 == 1)
  141. {
  142. Boat2 = AddStaticVehicle(493,1951.182,-253.128,1.388,349.0,-1,-1);
  143. PutPlayerInVehicle(i, Boat2, 0);
  144. }
  145. else if(sh3 == 2)
  146. {
  147. Boat3 = AddStaticVehicle(493,1955.429,-230.359,1.426,349.0,-1,-1);
  148. PutPlayerInVehicle(i, Boat3, 0);
  149. }
  150. else if(sh3 == 3)
  151. {
  152. Boat4 = AddStaticVehicle(493,1946.536,-228.397,1.402,349.0,-1,-1);
  153. PutPlayerInVehicle(i, Boat4, 0);
  154. }
  155. else if(sh3 == 4)
  156. {
  157. Boat5 = AddStaticVehicle(493,1961.798,-254.666,1.335,349.0,-1,-1);
  158. PutPlayerInVehicle(i, Boat5, 0);
  159. }
  160. else if(sh3 == 5)
  161. {
  162. Boat6 = AddStaticVehicle(493,1964.774,-231.862,1.401,349.0,-1,-1);
  163. PutPlayerInVehicle(i, Boat6, 0);
  164. }
  165. if(PlayerOnTele(i))
  166. PlayerObject[0] = CreatePlayerObject(i,1655, 1933.348, -158.0981, 1.2938, 0, 0, 11.25);
  167. PlayerObject[1] = CreatePlayerObject(i,1655, 1941.9407, -156.4904, 1.2853, 0, 0, 11.25);
  168. PlayerObject[2] = CreatePlayerObject(i,1655, 1825.3428, -44.8284, 1.2946, 0, 0, 67.5);
  169. PlayerObject[3] = CreatePlayerObject(i,1655, 1685.3217, -16.1496, 1.285, 0, 0, 78.75);
  170. PlayerObject[4] = CreatePlayerObject(i,1655, 1603.8607, -102.9386, 1.2732, 0, 0, 180);
  171. PlayerObject[5] = CreatePlayerObject(i,1634, 1399.4585, -254.9023, 1.2896, 0, 0, 90);
  172. PlayerObject[6] = CreatePlayerObject(i,1634, 1399.4789, -250.7029, 1.3193, 0, 0, 90);
  173. PlayerObject[7] = CreatePlayerObject(i,1655, 1098.5001, -111.0342, 1.3009, 0, 0, 98.5943);
  174. PlayerObject[8] = CreatePlayerObject(i,1655, 676.477, -226.1338, 0.9883, 0, 0, 90);
  175. }
  176. }
  177. }
  178. return 1;}
  179.  
  180. public OnPlayerEnterCheckpoint(playerid)
  181. {
  182. if(BoatsStarted == 1)
  183. {
  184. if(SaveBoat[playerid] == 1)
  185. {
  186. new string[128];
  187. format(string, sizeof(string), "Player %s won the race, He receives 100000$!", Player(playerid));
  188. GivePlayerMoney(playerid, 100000);
  189. SendClientMessageToAll(0xff0000ff, string);
  190. BoatsStarted = 0;
  191. Deleteq(playerid);
  192. }
  193. for(new i=0; i<GetMaxPlayers(); i++)
  194. {
  195. SetPlayerPos(i, x3, y3, z3);
  196. SaveBoat[i] = 0;
  197. DisablePlayerCheckpoint(i);
  198. }
  199. }
  200. return 1;}
  201.  
  202. PlayerOnTele(PlayerId)
  203. {
  204. TogglePlayerControllable(PlayerId, 0);
  205. SetTimerEx("UnfreezePlayer", 2999, false, "d", PlayerId);
  206. return true;}
  207.  
  208.  
  209. forward UnfreezePlayer(PlayerId);
  210. public UnfreezePlayer(PlayerId)
  211. {
  212. TogglePlayerControllable(PlayerId, 1);
  213. GameTextForPlayer(PlayerId, "~r~Go~p~-Go!", 2499, 3);
  214. return 1;}
  215.  
  216. stock Deleteq(playerid)
  217. {
  218. for(new o; o != 9; o++)
  219. DestroyPlayerObject(playerid, PlayerObject[o]);}
  220.  
  221. Player(playerid)
  222. {
  223. new player[MAX_PLAYER_NAME];
  224. GetPlayerName(playerid, player, sizeof(player));
  225. return player;}
  226.  
  227. public OnPlayerStateChange(playerid, newstate, oldstate)
  228. {
  229. if(oldstate == PLAYER_STATE_DRIVER && SaveBoat[playerid] != -1)
  230. {
  231. BoatPeople--;
  232. SaveBoat[playerid] = 0;
  233. DisablePlayerCheckpoint(playerid);
  234. Deleteq(playerid);
  235. }
  236. return 1;}
Advertisement
Add Comment
Please, Sign In to add comment