Guest User

HorseBets

a guest
Jul 13th, 2010
617
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. //Horse Bets
  2. //Credits to WillsuckformoneY & Jeffry
  3.  
  4. #define FILTERSCRIPT
  5.  
  6. #include <a_samp>
  7.  
  8. #if defined FILTERSCRIPT
  9.  
  10. #define COLOR_PINK 0xFF66FFAA
  11. #define COLOR_GREEN 0x18FF18FF
  12. #define COLOR_BLUE 0x0000FFFF
  13. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  14. new Horse[MAX_PLAYERS];
  15. public OnFilterScriptInit()
  16. {
  17. print("\n--------------------------------------");
  18. print(" Horse Bets by WillsuckformoneY");
  19. print("--------------------------------------\n");
  20. return 1;
  21. }
  22.  
  23. public OnFilterScriptExit()
  24. {
  25. return 1;
  26. }
  27.  
  28. #endif
  29.  
  30. public OnPlayerDisconnect(playerid, reason)
  31. {
  32. Horse[playerid]=0;
  33. return 1;
  34. }
  35.  
  36. public OnPlayerCommandText(playerid, cmdtext[])
  37. {
  38. dcmd(hbet, 4, cmdtext);
  39. return 0;
  40. }
  41.  
  42. dcmd_hbet(playerid, params[]) {
  43. new Index, tmp[256]; tmp=strtok(params, Index);
  44. if(!strlen(tmp)||strval(tmp)<1||strval(tmp)>3) return SendClientMessage(playerid,COLOR_PINK,"FAIL! Do /Bet [1 - 3]");
  45. switch(strval(tmp))
  46. {
  47. case 1:
  48. {
  49. SendClientMessage(playerid, COLOR_BLUE, "You Selected Horse 1");
  50. GivePlayerMoney(playerid, -100);
  51. SetTimerEx("BETS", 60000, 0, "d", playerid);
  52. Horse[playerid]=1;
  53. }
  54. case 2:
  55. {
  56. SendClientMessage(playerid, COLOR_BLUE, "You Selected Horse 2");
  57. GivePlayerMoney(playerid, -200);
  58. SetTimerEx("BETS", 60000, 0, "d", playerid);
  59. Horse[playerid]=2;
  60. }
  61. case 3:
  62. {
  63. SendClientMessage(playerid, COLOR_BLUE, "You Selected Horse 3");
  64. GivePlayerMoney(playerid, -300);
  65. SetTimerEx("BETS", 60000, 0, "d", playerid);
  66. Horse[playerid]=3;
  67. }
  68. }
  69. return 1;
  70. }
  71.  
  72. forward BETS(playerid);
  73. public BETS(playerid)
  74. {
  75. new Num;
  76. Num=random(3)+1;
  77. if(Num==Horse[playerid])
  78. {
  79. switch(Horse[playerid])
  80. {
  81. case 1: { GivePlayerMoney(playerid, 200); SendClientMessage(playerid, COLOR_PINK, "Congratulations, You won $200 From your Horse Bet"); }
  82. case 2: { GivePlayerMoney(playerid, 400); SendClientMessage(playerid, COLOR_PINK, "Congratulations, You won $400 From your Horse Bet"); }
  83. case 3: { GivePlayerMoney(playerid, 600); SendClientMessage(playerid, COLOR_PINK, "Congratulations, You won $600 From your Horse Bet"); }
  84. }
  85. }
  86. else
  87. {
  88. SendClientMessage(playerid, COLOR_GREEN, "Sorry! You did NOT win From your Horse Bet, Better luck next time!!");
  89. }
  90. return 1;
  91. }
  92.  
  93.  
  94. strtok(const string[], &index)
  95. {
  96. new length = strlen(string);
  97. while ((index < length) && (string[index] <= ' '))
  98. {
  99. index++;
  100. }
  101.  
  102. new offset = index;
  103. new result[20];
  104. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  105. {
  106. result[index - offset] = string[index];
  107. index++;
  108. }
  109. result[index - offset] = EOS;
  110. return result;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment