Advertisement
Hiddos

Shit-Yourself-Rich v1.01

Feb 25th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.42 KB | None | 0 0
  1. #include <a_samp>
  2. #define BETTING_ENTRANCE_TIME 180 // seconds after first bet before the 'race' actually starts
  3. #define DIALOG_INDEX 1543
  4. #define SC_INTERVAL 5000
  5. new secfence;
  6. new Float:field[2][2] = {{-1122.3,-1290.1}, {-1065.4104,-1255.9333}};
  7. new info_pickup;
  8.  
  9. new shouldcall[MAX_PLAYERS];
  10.  
  11. new bool:firstvisit[MAX_PLAYERS] = {true, true, ...};
  12. enum pBet {
  13.     bool:hasbet,
  14.     sumbet,
  15.     Float:betPos[3],
  16.     bool:isbetting,
  17. //  betflag,
  18.     Text3D:bettext,
  19. }
  20. new Bets[MAX_PLAYERS][pBet];
  21. new betvehicles[MAX_PLAYERS];
  22.  
  23. new cur_bets = 0;
  24. new timer;
  25. new cow;
  26. new cstate = 0;
  27. new ccd = 0;
  28. // 0 = nothing
  29. // 1 = timer running
  30. // 2 = cow raising
  31. // 3 = cow raving
  32. // 4 = cow shitting/win
  33.  
  34. public OnFilterScriptInit()
  35. {
  36.     secfence = CreateObject(3276, -1093.8, -1255.3, 129.1, 0.0, 0.0, 0.0);
  37.     info_pickup = CreatePickup(1239, 1, -1078.2122,-1247.8104,129.2188);
  38.     print("Shit-Yourself-Rich! has been loaded. Many credit to Hiddos");
  39.     return 1;
  40. }
  41.  
  42. public OnFilterScriptExit()
  43. {
  44.     if(cstate != 0 ) KillTimer(timer);
  45.     DestroyObject(secfence);
  46.     DestroyPickup(info_pickup);
  47.     for(new i; i != MAX_PLAYERS; i++)
  48.     {
  49.         if(Bets[i][hasbet] == true)
  50.         {
  51.             Delete3DTextLabel(Bets[i][bettext]);
  52.             GivePlayerMoney(i, Bets[i][sumbet]);
  53.         }
  54.         else if(Bets[i][isbetting] == true)
  55.         {
  56.             SetPlayerPos(i, -1078.2122,-1245.8104,129.2188);
  57.             DestroyVehicle(betvehicles[i]);
  58.             GivePlayerMoney(i, Bets[i][sumbet]);
  59.         }
  60.     }
  61.     if(cstate >= 2)
  62.     {
  63.         DestroyObject(cow);
  64.     }
  65.     return 1;
  66. }
  67.  
  68. public OnPlayerConnect(playerid)
  69. {
  70.     firstvisit[playerid] = true;
  71.     shouldcall[playerid] = 0;
  72.     return 1;
  73. }
  74.  
  75. public OnPlayerDisconnect(playerid, reason)
  76. {
  77.     if(Bets[playerid][hasbet] == true)
  78.     {
  79.         Delete3DTextLabel(Bets[playerid][bettext]);
  80.         Bets[playerid][hasbet] = false;
  81.     }
  82.     else if(Bets[playerid][isbetting] == true)
  83.     {
  84.         DestroyVehicle(betvehicles[playerid]);
  85.         Bets[playerid][isbetting] = false;     
  86.     }
  87.     return 1;
  88. }
  89.  
  90. public OnPlayerPickUpPickup(playerid, pickupid)
  91. {
  92.     if(shouldcall[playerid] == -1 || GetTickCount() < shouldcall[playerid] || IsPlayerInAnyVehicle(playerid)) return 1;
  93.     if(pickupid == info_pickup)
  94.     {
  95.         if(firstvisit[playerid] == true)
  96.         {
  97.             new str[420];
  98.             strins(str, "{FFFFFF}Welcome to '{1874CD}Shit Yourself Rich{FFFFFF}'!\n\nIn this fun little minigame, you get to plant a {00FF00}marker{FFFFFF} somewhere in this field.\nA {FF0000}cow{FFFFFF} will then be let loose on the field.\nAfter a quick while, the cow will take a poop. If the {FF0000}cow{FFFFFF} poops\nclose enough to your {00FF00}marker{FFFFFF}, you'll receive price money!\n\nTake a chance, and Shit Yourself Rich!", 0);
  99.  
  100.             ShowPlayerDialog(playerid, DIALOG_INDEX + 1, DIALOG_STYLE_MSGBOX, "Shit Yourself Rich!",str, "Ok", "");
  101.         }
  102.         else
  103.         {
  104.             if(Bets[playerid][hasbet] == false) { ShowPlayerDialog(playerid, DIALOG_INDEX + 0, DIALOG_STYLE_LIST, "Shit Yourself Rich!", "Welcome\nPlace Bet\nLeave", "Choose", ""); }
  105.             else { ShowPlayerDialog(playerid, DIALOG_INDEX + 0, DIALOG_STYLE_LIST, "Shit Yourself Rich!", "Welcome\nReview Bet\nLeave", "Choose", ""); }
  106.         }
  107.     }
  108.     shouldcall[playerid] = -1;
  109.     return 1;
  110. }
  111.  
  112. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  113. {
  114.     switch(dialogid)
  115.     {
  116.         case DIALOG_INDEX + 0: // the menu
  117.         {
  118.             if(response == 0)
  119.             {
  120.                 shouldcall[playerid] = GetTickCount() + SC_INTERVAL;
  121.                 return 1;
  122.             }
  123.             switch(listitem)
  124.             {
  125.                 case 0: //Welcome
  126.                 {
  127.                     new str[420];
  128.                     strins(str, "{FFFFFF}Welcome to '{1874CD}Shit Yourself Rich{FFFFFF}'!\n\nIn this fun little minigame, you get to plant a {00FF00}marker{FFFFFF} somewhere in this field.\nA {FF0000}cow{FFFFFF} will then be let loose on the field.\nAfter a quick while, the cow will take a poop. If the {FF0000}cow{FFFFFF} poops\nclose enough to your {00FF00}marker{FFFFFF}, you'll receive price money!\n\nTake a chance, and Shit Yourself Rich!", 0);
  129.                     ShowPlayerDialog(playerid, DIALOG_INDEX + 1, DIALOG_STYLE_MSGBOX, "Shit Yourself Rich!",str, "Ok", "");
  130.                     return 1;
  131.                 }
  132.                 case 1: //review/place bet
  133.                 {
  134.                     if(cstate >= 2)
  135.                     {
  136.                         ShowPlayerDialog(playerid, DIALOG_INDEX + 3, DIALOG_STYLE_MSGBOX, "Shit Yourself Rich!", "Sorry, you're too late! The game has already begun! Come back later!", "Ok", "");
  137.                     }
  138.                     if(Bets[playerid][hasbet] == true)  //  review bet
  139.                     {
  140.                         new str[128];
  141.                         format(str, sizeof str, "You've placed a bet of {FF5721}$%i{FFFFFF}! There's no backing out now anymore!", Bets[playerid][sumbet]);
  142.                         ShowPlayerDialog(playerid, DIALOG_INDEX + 3, DIALOG_STYLE_MSGBOX, "Shit Yourself Rich!", str, "Ok", "");
  143.                     }
  144.                     else ShowPlayerDialog(playerid, DIALOG_INDEX + 2, DIALOG_STYLE_INPUT, "Shit Yourself Rich!", "Please enter the amount of money you'd like to bet:", "Bet", "Cancel");
  145.                     return 1;
  146.                 }
  147.                 case 2:
  148.                 {
  149.                     shouldcall[playerid] = GetTickCount() + SC_INTERVAL;
  150.                     return 1; //Leave
  151.                 }
  152.             }
  153.         }
  154.         case DIALOG_INDEX + 1:
  155.         {
  156.             if(response == 0 && firstvisit[playerid] == true)
  157.             {
  158.                 firstvisit[playerid] = false;
  159.                 shouldcall[playerid] = GetTickCount() + SC_INTERVAL;
  160.                 return 1;
  161.             }
  162.             firstvisit[playerid] = false;
  163.             if(Bets[playerid][hasbet] == false) { ShowPlayerDialog(playerid, DIALOG_INDEX + 0, DIALOG_STYLE_LIST, "Shit Yourself Rich!", "Welcome\nPlace Bet\nLeave", "Choose", ""); }
  164.             else { ShowPlayerDialog(playerid, DIALOG_INDEX + 0, DIALOG_STYLE_LIST, "Shit Yourself Rich!", "Welcome\nReview Bet\nLeave", "Choose", ""); }
  165.             return 1;
  166.         }
  167.         case DIALOG_INDEX + 2:
  168.         {
  169.             if(cstate >= 2) return ShowPlayerDialog(playerid, DIALOG_INDEX + 3, DIALOG_STYLE_MSGBOX, "Shit Yourself Rich!", "Sorry, you're too late! The game has already begun! Come back later!", "Ok", ""), 0;
  170.             if(response == 0) return ShowPlayerDialog(playerid, DIALOG_INDEX + 0, DIALOG_STYLE_LIST, "Shit Yourself Rich!", "Welcome\nPlace Bet\nLeave", "Choose", ""), 1;
  171.             new bet = strval(inputtext);
  172.             if(bet <= 0) return ShowPlayerDialog(playerid, DIALOG_INDEX + 2, DIALOG_STYLE_INPUT, "Shit Yourself Rich!", "{FF2222}Please bet a minimum of at least $1!\n\n{FFFFFF}Please enter the amount of money you'd like to bet:", "Bet", "Cancel"), 1;
  173.             else if(bet > GetPlayerMoney(playerid)) return ShowPlayerDialog(playerid, DIALOG_INDEX + 2, DIALOG_STYLE_INPUT, "Shit Yourself Rich!", "{FF2222}You don't have that much money!\n\n{FFFFFF}Please enter the amount of money you'd like to bet:", "Bet", "Cancel"), 1;
  174.             Bets[playerid][isbetting] = true;
  175.             Bets[playerid][sumbet] = bet;
  176.             betvehicles[playerid] = CreateVehicle(594, -1100.0, -1270.0, 129.1, 0.0, -1, -1, 0);
  177.             PutPlayerInVehicle(playerid, betvehicles[playerid], 0);
  178.             ShowPlayerDialog(playerid, DIALOG_INDEX + 4, DIALOG_STYLE_MSGBOX, "Shit Yourself Rich!", "{FF0000}Thank you for placing a bet! {FFFFFF}You must now drive around the flower\npot to your desired {00FF00}marker location{FFFFFF}.\nYou must then exit the vehicle to register your bet!", "Ok", "");
  179.             shouldcall[playerid] = 0;
  180.         }
  181.         case DIALOG_INDEX + 3: return ShowPlayerDialog(playerid, DIALOG_INDEX + 0, DIALOG_STYLE_LIST, "Shit Yourself Rich!", "Welcome\nReview Bet\nLeave", "Choose", "") , 1; // review bet
  182.         case DIALOG_INDEX + 4: return 1; // Bet Confirm
  183.     }
  184.     return 1;
  185. }
  186.  
  187. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  188. {
  189.     if(Bets[playerid][isbetting] == true && (newkeys & KEY_HANDBRAKE || newkeys & KEY_SECONDARY_ATTACK))
  190.     {
  191.         GetVehiclePos(betvehicles[playerid], Bets[playerid][betPos][0], Bets[playerid][betPos][1], Bets[playerid][betPos][2]);
  192.         SetPlayerPos(playerid, -1078.2122,-1245.8104,129.2188);
  193.         Bets[playerid][isbetting] = false;
  194.         Bets[playerid][hasbet] = true;
  195.         GivePlayerMoney(playerid, -Bets[playerid][sumbet]);
  196.         new str[MAX_PLAYER_NAME];
  197.         GetPlayerName(playerid, str, MAX_PLAYER_NAME);
  198.         Bets[playerid][bettext] = Create3DTextLabel(str, 0x00FF00FF, Bets[playerid][betPos][0], Bets[playerid][betPos][1], Bets[playerid][betPos][2] + 3.4, 180.0, 0);
  199.         DestroyVehicle(betvehicles[playerid]);
  200.         cur_bets++;
  201.         if(cur_bets == 1)
  202.         {
  203.             new str2[148];
  204.             format(str2, sizeof str2, "{00FF00}%s{FFFFFF} has initiated the 'Shit-Yourself-Rich!' minigame! You have {FF0000}3{FFFFFF} minutes until the cow is let loose!", str);
  205.             SendClientMessageToAll(-1, str2);
  206.             timer = SetTimer("cowRaise", 3 * 60 * 1000, false);
  207.             cstate = 1;
  208.         }
  209.     }
  210.     return 1;
  211. }
  212.  
  213. forward cowRaise();
  214. public cowRaise()
  215. {
  216.  
  217.     for(new i; i != MAX_PLAYERS; i++)
  218.     {
  219.         if(Bets[i][isbetting] == true)
  220.         {
  221.             Bets[i][isbetting] = false;
  222.             DestroyVehicle(betvehicles[i]);
  223.             SetPlayerPos(i, -1078.2122,-1245.8104,129.2188);
  224.             SendClientMessage(i, -1, "Sorry, you're too late. The game has already started!");
  225.         }
  226.     }
  227.  
  228.     cstate = 2;
  229.     new Float:fieldX = field[0][0] + random(floatround(field[1][0]-field[0][0]));
  230.     new Float:fieldY = field[0][1] + random(floatround(field[1][1]-field[0][1]));
  231.     cow = CreateObject(16442, fieldX, fieldY, 129.2188 - 1.0, 0.0, 0.0, random(360));
  232.     MoveObject(cow, fieldX, fieldY, 129.2188 + 0.8, 1.0);
  233. }
  234.  
  235. public OnObjectMoved(objectid)
  236. {
  237.     if(objectid == cow)
  238.     {
  239.         switch(cstate)
  240.         {
  241.             case 0..1: return 1;
  242.             case 2:
  243.             {
  244.                 cstate = 3;
  245.                 timer = SetTimer("MoveCowToRandomLoc", random(3000), false);
  246.                 return 1;
  247.             }
  248.             case 3:
  249.             {
  250.                 new yn = random(8);
  251.                 if(yn == 0)
  252.                 {
  253.                     cstate = 4;
  254.                     ccd = 12;
  255.                     timer = SetTimer("CowPoop", random(4000), false);
  256.                 }
  257.                 else
  258.                 {
  259.                     timer = SetTimer("MoveCowToRandomLoc", random(3000), false);
  260.                 }
  261.                 return 1;
  262.             }
  263.         }
  264.     }
  265.     return 1;
  266. }
  267.  
  268. forward MoveCowToRandomLoc();
  269. public MoveCowToRandomLoc()
  270. {
  271.  
  272.     new Float:x, Float:y, Float:oldpos[3];
  273.     GetObjectPos(cow, oldpos[0], oldpos[1], oldpos[2]);
  274.     x = field[0][0] + random(floatround(field[1][0] - field[0][0]));
  275.     y = field[0][1] + random(floatround(field[1][1] - field[0][1]));
  276.    
  277.     oldpos[2] = atan((y - oldpos[1]) / (x - oldpos[0]));
  278.     if(x < oldpos[0]) oldpos[2] += -180.0;
  279.     oldpos[2] -= 2.0;
  280.  
  281.     SetObjectRot(cow, 0.0, 0.0, oldpos[2]);
  282.     MoveObject(cow, x, y, 129.2188 + 0.8, 3.8);
  283. }
  284.  
  285. forward CowPoop();
  286. public CowPoop()
  287. {
  288.     ccd--;
  289.     if(ccd == 0)
  290.     {
  291.         new Float:loc[3];
  292.         GetObjectPos(cow, loc[0], loc[1], loc[2]);
  293.         CreateExplosion(loc[0], loc[1], loc[2], 1, 0.2);
  294.         for(new i; i != MAX_PLAYERS; i++)
  295.         {
  296.             if(Bets[i][hasbet] == true)
  297.             {
  298.                 new Float:range = 16.0 - floatsqroot((floatpower(loc[0] - Bets[i][betPos][0], 2) + floatpower(loc[1] - Bets[i][betPos][1], 2)));
  299.                 if(range <= 0.0)
  300.                 {
  301.                     SendClientMessage(i, -1, "Sorry, you didn't win anything this round!");
  302.                     continue;
  303.                 }
  304.                 new str[128];
  305.                 new win = floatround(range * float(Bets[i][sumbet]));
  306.                 GivePlayerMoney(i, win);
  307.                 format(str, sizeof str, "Congratulations! The Cow took a dump {00FF00}%.2f{FFFFFF} m away from your marker! You've won ${FFFF00}%i{FFFFFF}!", 16.0 - range - 1.0, win);
  308.                 SendClientMessage(i, -1, str);
  309.             }
  310.         }
  311.         SetTimer("CleanThisShitUp", 30 * 1000, false);
  312.     }
  313.     else
  314.     {
  315.         new Float:rot[3];
  316.         GetObjectRot(cow, rot[0], rot[1], rot[2]);
  317.         SetObjectRot(cow, float(random(20)) - 10.0, float(random(20)) - 10.0, rot[2]);
  318.         GetObjectPos(cow, rot[0], rot[1], rot[1]);
  319.         CreateExplosion(rot[0] - 1.2 + (float(random(24))/10.0), rot[1] - 1.2 + (float(random(24))/10.0), rot[1] - 0.60, 12, 0.1);
  320.         timer = SetTimer("CowPoop", 170, false);
  321.     }
  322. }
  323.  
  324. forward CleanThisShitUp();
  325. public CleanThisShitUp()
  326. {
  327.     DestroyObject(cow);
  328.     for(new i; i != MAX_PLAYERS; i++)
  329.     {
  330.         if(Bets[i][hasbet] == true)
  331.         {
  332.             Bets[i][hasbet] = false;
  333.             Delete3DTextLabel(Bets[i][bettext]);
  334.         }
  335.     }
  336.     cstate = 0;
  337.     cur_bets = 0;
  338. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement