Guest User

Untitled

a guest
Dec 1st, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.49 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp> //You need the a_samp include in almost every script.
  6. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 //DCMD
  7. #define LOTTO_JACKPOT 10000 //How much it goes up every 30 seconds or whenever someone buys a ticket
  8. #define LOTTO_START 200000 //How much the lotto starts off at every draw
  9. #define LOTTO_DRAW 10 //How many minutes between each lotto draw
  10. #define TICKET_COST 1000 //How much a ticket will cost
  11. new Jackpot = LOTTO_START; //Jackpot amount
  12. new Numbers[100]; //So 2 people don't get the same #
  13.  
  14. #if defined FILTERSCRIPT
  15.  
  16. public OnFilterScriptInit()
  17. {
  18. SetTimer("UpdateJP", 30000, true); //Updates the jackpot
  19. SetTimer("Draw", LOTTO_DRAW*1000*60, true); //Updates the jackpot
  20. forward UpdateJP(); //Always forward a timer
  21.  
  22. print("\n--------------------------------------");
  23. print(" Lottery FS by Goldkiller");
  24. print("--------------------------------------\n");
  25. return 1;
  26. }
  27.  
  28. public OnFilterScriptExit()
  29. {
  30. return 1;
  31. }
  32.  
  33. #else
  34.  
  35. main()
  36. {
  37. print("\n----------------------------------");
  38. print(" Lottery FS exit by Goldkiller");
  39. print("----------------------------------\n");
  40. }
  41.  
  42. #endif
  43.  
  44. public OnPlayerRequestClass(playerid, classid)
  45. {
  46. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  47. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  48. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  49. return 1;
  50. }
  51.  
  52. public OnPlayerConnect(playerid)
  53. {
  54. return 1;
  55. }
  56.  
  57. public OnPlayerDisconnect(playerid, reason)
  58. {
  59. return 1;
  60. }
  61.  
  62. public OnPlayerSpawn(playerid)
  63. {
  64. return 1;
  65. }
  66.  
  67. public OnPlayerDeath(playerid, killerid, reason)
  68. {
  69. return 1;
  70. }
  71.  
  72. public OnVehicleSpawn(vehicleid)
  73. {
  74. return 1;
  75. }
  76.  
  77. public OnVehicleDeath(vehicleid, killerid)
  78. {
  79. return 1;
  80. }
  81.  
  82. public OnPlayerText(playerid, text[])
  83. {
  84. return 1;
  85. }
  86.  
  87. public OnPlayerCommandText(playerid, cmdtext[])
  88. {
  89. dcmd(lotto, 5, cmdtext);
  90. return 0;
  91. }
  92.  
  93. dcmd_lotto(playerid, params[])
  94. {
  95. if(!strlen(params)) //If the player doesn't put a nubmer
  96. {
  97. SendClientMessage(playerid, 0x62FF32FF, "***Lotto information***"); //Lotto info
  98. SendClientMessage(playerid, 0x62FF32FF, "Pick a number between 1 and 100 with /lotto [1-100]"); //Lotto info
  99. new str[75]; //Creates the string
  100. format(str, sizeof(str), "Current Jackpot is $%d!!!!", Jackpot); //Formats the jackpot string
  101. SendClientMessage(playerid, 0x62FF32FF, str); //Shows the current jackpot
  102. }
  103. new Num = strval(params); //Makes the param that the player entered into a intiger
  104. if(Numbers[Num] == 1) //If the number is used
  105. {
  106. new str[75]; //Makes a variable
  107. format(str, sizeof(str), "Lotto number %d is already taken!", Num); //Formats a str
  108. SendClientMessage(playerid, 0xE21F1FFF, str); //Sends the message
  109. return 1;
  110. }
  111. if(GetPVarInt(playerid, "LottoNumber") != 0) return SendClientMessage(playerid, 0xE21F1FFF, "You have already got a lotto number");
  112. SetPVarInt(playerid, "LottoNumber", Num); //Sets the players number
  113. Numbers[Num] = 1; //Number is used
  114. GivePlayerMoney(playerid, -TICKET_COST); //Takes away the ticket cost.
  115. new str[75];
  116. format(str, sizeof(str), " Lotto ticket brought! You now have number %d for the next draw", Num);
  117. SendClientMessage(playerid, 0x62FF32FF, str); //Lotto info
  118. format(str, sizeof(str), " Draws are held every %d minutes and the winners are announced. Current jackpot is $%d", LOTTO_DRAW, Jackpot);
  119. Jackpot = Jackpot + LOTTO_JACKPOT; //Ads to the lotto jackpot
  120. SendClientMessage(playerid, 0x62FF32FF, str); //Lotto info
  121. return 1;
  122. }
  123.  
  124. forward Draw();
  125. public Draw()
  126. {
  127. new Lnum = random(100) + 1; //Picks a random number
  128. new winner = -1; //Winners ID variable
  129. for(new i; i<MAX_PLAYERS; i++) //checks through all players
  130. {
  131. if(!IsPlayerConnected(i)) continue; //Players not connected
  132. if(GetPVarInt(i, "LottoNumber") == Lnum) winner = i; //If the players number is the winning number
  133. SetPVarInt(i, "LottoNumber", 0); //Resets the number
  134. }
  135. if(winner != -1) //If there was a winner
  136. {
  137. new Pname[24];
  138. GetPlayerName(winner, Pname, 24);
  139. new str[100];
  140. SendClientMessageToAll(0x62FF32FF, "****LOTTO INFORMATION****"); //Lotto info
  141. format(str, sizeof(str), "WE HAVE A WINNER! %s(%d) won $%d!!!!", Pname, winner, Jackpot);
  142. SendClientMessageToAll(0x62FF32FF, str); //Lotto info
  143. SendClientMessageToAll(0x62FF32FF, "Make sure you get a ticket for next draw /lotto [1-100]!!"); //Lotto info
  144. GivePlayerMoney(winner, Jackpot); //Gives the winner the cash
  145. Jackpot = LOTTO_START; //Resets the jackpot
  146. }
  147. if(winner == -1) //No winner
  148. {
  149. new str[100];
  150. SendClientMessageToAll(0x62FF32FF, "****LOTTO INFORMATION****"); //Lotto info
  151. format(str, sizeof(str), "There was no lotto winner for this draw. The jackpot will go up to $%d!", Jackpot);
  152. SendClientMessageToAll(0x62FF32FF, str); //Lotto info
  153. SendClientMessageToAll(0x62FF32FF, "Make sure you get a ticket for next draw /lotto [1-100]!!");
  154. }
  155. for(new s; s<100; s++)
  156. {
  157. Numbers[s] = 0; //Resets all numbers so they are usable.
  158. }
  159. return 1;
  160. }
  161. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  162. {
  163. return 1;
  164. }
  165.  
  166. public OnPlayerExitVehicle(playerid, vehicleid)
  167. {
  168. return 1;
  169. }
  170.  
  171. public OnPlayerStateChange(playerid, newstate, oldstate)
  172. {
  173. return 1;
  174. }
  175.  
  176. public OnPlayerEnterCheckpoint(playerid)
  177. {
  178. return 1;
  179. }
  180.  
  181. public OnPlayerLeaveCheckpoint(playerid)
  182. {
  183. return 1;
  184. }
  185.  
  186. public OnPlayerEnterRaceCheckpoint(playerid)
  187. {
  188. return 1;
  189. }
  190.  
  191. public OnPlayerLeaveRaceCheckpoint(playerid)
  192. {
  193. return 1;
  194. }
  195.  
  196. public OnRconCommand(cmd[])
  197. {
  198. return 1;
  199. }
  200.  
  201. public OnPlayerRequestSpawn(playerid)
  202. {
  203. return 1;
  204. }
  205.  
  206. public OnObjectMoved(objectid)
  207. {
  208. return 1;
  209. }
  210.  
  211. public OnPlayerObjectMoved(playerid, objectid)
  212. {
  213. return 1;
  214. }
  215.  
  216. public OnPlayerPickUpPickup(playerid, pickupid)
  217. {
  218. return 1;
  219. }
  220.  
  221. public OnVehicleMod(playerid, vehicleid, componentid)
  222. {
  223. return 1;
  224. }
  225.  
  226. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  227. {
  228. return 1;
  229. }
  230.  
  231. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  232. {
  233. return 1;
  234. }
  235.  
  236. public OnPlayerSelectedMenuRow(playerid, row)
  237. {
  238. return 1;
  239. }
  240.  
  241. public OnPlayerExitedMenu(playerid)
  242. {
  243. return 1;
  244. }
  245.  
  246. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  247. {
  248. return 1;
  249. }
  250.  
  251. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  252. {
  253. return 1;
  254. }
  255.  
  256. public OnRconLoginAttempt(ip[], password[], success)
  257. {
  258. return 1;
  259. }
  260.  
  261. public OnPlayerUpdate(playerid)
  262. {
  263. return 1;
  264. }
  265.  
  266. public OnPlayerStreamIn(playerid, forplayerid)
  267. {
  268. return 1;
  269. }
  270.  
  271. public OnPlayerStreamOut(playerid, forplayerid)
  272. {
  273. return 1;
  274. }
  275.  
  276. public OnVehicleStreamIn(vehicleid, forplayerid)
  277. {
  278. return 1;
  279. }
  280.  
  281. public OnVehicleStreamOut(vehicleid, forplayerid)
  282. {
  283. return 1;
  284. }
  285.  
  286. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  287. {
  288. return 1;
  289. }
  290.  
  291. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  292. {
  293. return 1;
  294. }
  295.  
  296. public UpdateJP()
  297. {
  298. Jackpot = Jackpot + LOTTO_JACKPOT; //Ads to the lotto jackpot
  299. return 1;
  300. }
Advertisement
Add Comment
Please, Sign In to add comment