Advertisement
Guest User

race

a guest
Nov 1st, 2011
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.91 KB | None | 0 0
  1. new Ccp[MAX_PLAYERS];
  2.  
  3. COMMAND:work(playerid, cmdtext)
  4. {
  5. ShowPlayerDialog(playerid, 50, DIALOG_STYLE_LIST, "Choose any of those locations", "SF Race 1 /*(listitem 0)*/ \nFrom --- to --- /*(listitem 1)*/ \nFrom --- to ---/*(listitem 2)*/", "Ok", "Cancel");
  6. /*
  7. As you can see, im using "\n" to make a new line. In a messagebox it is just a new line, but with DIALOG_STYLE_LIST, it is a new listitem.
  8. Please NOTE: Anything always start couting from 0, not from 1.
  9. You can change the dialogid to anything, and an usefull thing to do, is to give the dialog an name.
  10. Example:
  11. #define MISSIONDIALOG 50
  12. ShowPlayerDialog(playerid, MISSIONDIALOG, DIALOG_STYLE_LIST, "Choose any of those locations", "From --- to --- \nFrom --- to --- \nFrom --- to ---", "Ok", "Cancel");
  13. So if you need to change the dialogs, because you're already using the dialogid, you just need to change 1 number, instead of the whole dialogid's
  14. */
  15. return 1;
  16. }
  17.  
  18.  
  19.  
  20. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  21. {
  22. if(dialogid == 50 || dialogid == MISSIONDIALOG) // This checks if the dialog equals to 50, OR ( || = or , && = and ) MISSIONDIALOG. Just change it to what ever you use. You can use a switch aswell, but i just prefer just to see the whole line
  23. {
  24. if(!response) return 0; // If you press the second button (cancel), the dialog dissapears and nothing happens
  25. if(resposne) // if there is a response (first button( ok )) it continues
  26. {
  27. if(listitem == 0) // If you choose the first listitem, this happens
  28. {
  29. Ccp[playerid] = 1; // This will change the variable, so we can use it later on with OnPlayerEnterCheckpoint
  30. SetPlayerCheckpoint(playerid, -1795.0421,1103.3732,45.0752, 3.0); // SFRaceC This creates a checkpoint at the coördinates: "-269.1287,2610.6057,63.2069"
  31. SendClientMessage(playerid, 0xFFFFFFFF, "You started a Race. Follow the checkpoints as fast as you can.");
  32. return 1;
  33. }
  34. if(listitem == 1) // If you choose the second listitem
  35. {
  36. Ccp[playerid] = 13; // Why do we make this one 3, and not just 1? That is because 1 is already in use. If you look at your current OnPlayerEnterCheckpoint, you see that there already is a "if(Ccp[playerid] == 1)"
  37. SetPlayerCheckpoint(playerid, -1051.4005,-655.8729,31.7361, 3.0); // This creates a checkpoint at the coördinates: "-1051.4005,-655.8729,31.7361"
  38. SendClientMessage(playerid, 0xFFFFFFFF, "You started a Race. Follow the checkpoints as fast as you can.");
  39. return 1;
  40. }
  41. if(listitem == 2) // If you choose the third listitem
  42. {
  43. Ccp[playerid] = 5; // Same for this, 1, 2, 3 and 4 are already in use, so thats why we use 5
  44. SetPlayerCheckpoint(playerid, -2286.7529,2282.9390,5.9015, 3.0); // This creates a checkpoint at the coördinates: "-2286.7529,2282.9390,5.9015"
  45. SendClientMessage(playerid, 0xFFFFFFFF, "You started a Race. Follow the checkpoints as fast as you can.");
  46. return 1;
  47. }
  48. }
  49. }
  50. return 1; // If you're using this in your GM, then return to 1. If you're using a FS, return to 0 PLEASE NOTE: Take a good look at this, if you're returning to 1 in a FS, it will NOT work
  51. }
  52.  
  53.  
  54.  
  55. public OnPlayerEnterCheckpoint(playerid)
  56. {
  57. if(Ccp[playerid] == 1) // This checks if our variable equals to 1, if so: it continues
  58. {
  59. DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
  60. Ccp[playerid] = 2; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
  61. SetPlayerCheckpoint(playerid, -1930.9707,1076.5671,50.9935, 3.0); // Creates a new checkpoint at a different position
  62. return 1;
  63. }
  64. if(Ccp[playerid] == 2) // This checks if our variable equals to 2, if so: it continues
  65. {
  66. DisablePlayerCheckpoint(playerid); // This will destroy the checkpoint, so you only get your reward once
  67. Ccp[playerid] = 3; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
  68. SetPlayerCheckpoint(playerid, -2230.1987,1076.0427,55.3577, 3.0); // Creates a new checkpoint at a different position
  69. return 1;
  70. }
  71. if(Ccp[playerid] == 3) // This checks if our variable equals to 2, if so: it continues
  72. {
  73. DisablePlayerCheckpoint(playerid); // This will destroy the checkpoint, so you only get your reward once
  74. Ccp[playerid] = 4; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
  75. SetPlayerCheckpoint(playerid, -2590.9111,1094.3782,56.4249, 3.0); // Creates a new checkpoint at a different position
  76. return 1;
  77. }
  78. if(Ccp[playerid] == 4) // This checks if our variable equals to 2, if so: it continues
  79. {
  80. DisablePlayerCheckpoint(playerid); // This will destroy the checkpoint, so you only get your reward once
  81. Ccp[playerid] = 5; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
  82. SetPlayerCheckpoint(playerid, -2606.9106,794.0964,48.8295, 3.0); // Creates a new checkpoint at a different position
  83. return 1;
  84. }
  85. if(Ccp[playerid] == 5) // This checks if our variable equals to 2, if so: it continues
  86. {
  87. DisablePlayerCheckpoint(playerid); // This will destroy the checkpoint, so you only get your reward once
  88. Ccp[playerid] = 6; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
  89. SetPlayerCheckpoint(playerid, -2592.1206,468.0095,14.2402, 3.0); // Creates a new checkpoint at a different position
  90. return 1;
  91. }
  92. if(Ccp[playerid] == 6) // This checks if our variable equals to 2, if so: it continues
  93. {
  94. DisablePlayerCheckpoint(playerid); // This will destroy the checkpoint, so you only get your reward once
  95. Ccp[playerid] = 7; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
  96. SetPlayerCheckpoint(playerid, -2509.6260,565.3315,14.2450, 3.0); // Creates a new checkpoint at a different position
  97. return 1;
  98. }
  99. if(Ccp[playerid] == 7) // This checks if our variable equals to 2, if so: it continues
  100. {
  101. DisablePlayerCheckpoint(playerid); // This will destroy the checkpoint, so you only get your reward once
  102. Ccp[playerid] = 8; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
  103. SetPlayerCheckpoint(playerid, -2284.7966,565.8425,34.7950, 3.0); // Creates a new checkpoint at a different position
  104. return 1;
  105. }
  106. if(Ccp[playerid] == 8) // This checks if our variable equals to 2, if so: it continues
  107. {
  108. DisablePlayerCheckpoint(playerid); // This will destroy the checkpoint, so you only get your reward once
  109. Ccp[playerid] = 9; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
  110. SetPlayerCheckpoint(playerid, -2004.1255,554.2927,34.7953, 3.0); // Creates a new checkpoint at a different position
  111. return 1;
  112. }
  113. if(Ccp[playerid] == 9) // This checks if our variable equals to 2, if so: it continues
  114. {
  115. DisablePlayerCheckpoint(playerid); // This will destroy the checkpoint, so you only get your reward once
  116. Ccp[playerid] = 10; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
  117. SetPlayerCheckpoint(playerid, -1964.4161,346.3401,33.8492, 3.0); // Creates a new checkpoint at a different position
  118. return 1;
  119. }
  120. if(Ccp[playerid] == 10) // This checks if our variable equals to 2, if so: it continues
  121. {
  122. DisablePlayerCheckpoint(playerid); // This will destroy the checkpoint, so you only get your reward once
  123. Ccp[playerid] = 11; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
  124. SetPlayerCheckpoint(playerid, -1849.9379,409.4500,16.7912, 3.0); // Creates a new checkpoint at a different position
  125. return 1;
  126. }
  127. if(Ccp[playerid] == 11) // This checks if our variable equals to 2, if so: it continues
  128. {
  129. DisablePlayerCheckpoint(playerid); // This will destroy the checkpoint, so you only get your reward once
  130. Ccp[playerid] = 12; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
  131. SetPlayerCheckpoint(playerid, -1756.7081,317.2934,6.8105, 3.0); // Creates a new checkpoint at a different position
  132. return 1;
  133. }
  134. if(Ccp[playerid] == 12) // This checks if our variable equals to 4, if so: it continues
  135. {
  136. new Moneys = 1000 + random( 7000 ),
  137. Score = 30 + random( 10 ),
  138. Cookies = 10 + random( 20 ),
  139. String[ 256 ];
  140.  
  141. foreach(Player, i)
  142. {
  143. if ( i != playerid )
  144. {
  145. FormMessage( i, -1, ""COL_OGREEN"%s{FFFFFF} has finished a The SF race, and won a prize!", PlayerName2( playerid ) );
  146. }
  147. }
  148. format( String, sizeof String, " ~g~ FINISHED~n~~n~~w~You finished The SF Race!~n~~n~~g~ REWARD!~n~~W~Cash:~g~~h~$%d~n~~w~Score: ~g~~h~%d~n~~w~Cookies: ~g~~h~%d",Moneys, Score, Cookies );
  149. Info( playerid, String,12000);
  150. P_DATA[ playerid ][ P_WTF_Race ] = false;
  151. P_DATA[ playerid ][ P_Cookies ] += Cookies;
  152. SetPlayerScore( playerid, GetPlayerScore( playerid ) + Score );
  153. GivePlayerMoney( playerid, Moneys );
  154. DisablePlayerCheckpoint(playerid);
  155. }
  156. return 1;
  157. }
  158. if(Ccp[playerid] == 13) // This checks if our variable equals to 3, if so: it continues
  159. {
  160. // This is the same as "if(Ccp[playerid] == 1)", didn't understand something from this? Please look back
  161. DisablePlayerCheckpoint(playerid);
  162. Ccp[playerid] = 14;
  163. SetPlayerCheckpoint(playerid, 2791.8650,1231.7740,10.7663, 3.0);
  164. SendClientMessage(playerid, 0xFFFFFFFF, "You loaded your goods, go to the next checkpoint to continue.");
  165. return 1;
  166. }
  167. if(Ccp[playerid] == 4) // This checks if our variable equals to 4, if so: it continues
  168. {
  169. // This is all the same as with "if(Ccp[playerid] == 2)", so if you still didn't understand anything from it, please, look back at the Ccp[playerid] == 2
  170. new reward, string[128];
  171. DisablePlayerCheckpoint(playerid);
  172. Ccp[playerid] = 0;// This resets the variable, so if you enter a checkpoint right now, nothing will happen
  173. reward = GivePlayerMoney(playerid, GetPlayerMoney(playerid) + random(5000) + 1000);
  174. format(string, sizeof(string), "You entered the last checkpoint. Reward: $%i", reward);
  175. SendClientMessage(playerid, 0xFFFFFFFF, string);
  176. return 1;
  177. }
  178. if(Ccp[playerid] == 5) // This checks if our variable equals to 5, if so: it continues
  179. {
  180. // This is the same as "if(Ccp[playerid] == 1 || Ccp[playeird] == 3)", didn't understand something from this? Please look back
  181. DisablePlayerCheckpoint(playerid);
  182. Ccp[playerid] = 6;
  183. SetPlayerCheckpoint(playerid, -1573.3285,-2730.4099,49.2886, 3.0);
  184. SendClientMessage(playerid, 0xFFFFFFFF, "You loaded your goods, go to the next checkpoint to continue.");
  185. return 1;
  186. }
  187. if(Ccp[playerid] == 6) // This checks if our variable equals to 6, if so: it continues
  188. {
  189. // This is all the same as with "if(Ccp[playerid] == 2 || Ccp[playerid] == 4)", so if you still didn't understand anything from it, please, look back at the Ccp[playerid] == 2 || Ccp[playerid] == 4
  190. new reward, string[128];
  191. DisablePlayerCheckpoint(playerid);
  192. Ccp[playerid] = 0;
  193. reward = GivePlayerMoney(playerid, GetPlayerMoney(playerid) + random(5000) + 1000);
  194. format(string, sizeof(string), "You entered the last checkpoint. Reward: $%i", reward);
  195. SendClientMessage(playerid, 0xFFFFFFFF, string);
  196. return 1;
  197. }
  198. return 1;
  199. }
  200.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement