Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define BETTING_ENTRANCE_TIME 180 // seconds after first bet before the 'race' actually starts
- #define DIALOG_INDEX 1543
- #define SC_INTERVAL 5000
- new secfence;
- new Float:field[2][2] = {{-1122.3,-1290.1}, {-1065.4104,-1255.9333}};
- new info_pickup;
- new shouldcall[MAX_PLAYERS];
- new bool:firstvisit[MAX_PLAYERS] = {true, true, ...};
- enum pBet {
- bool:hasbet,
- sumbet,
- Float:betPos[3],
- bool:isbetting,
- // betflag,
- Text3D:bettext,
- }
- new Bets[MAX_PLAYERS][pBet];
- new betvehicles[MAX_PLAYERS];
- new cur_bets = 0;
- new timer;
- new cow;
- new cstate = 0;
- new ccd = 0;
- // 0 = nothing
- // 1 = timer running
- // 2 = cow raising
- // 3 = cow raving
- // 4 = cow shitting/win
- public OnFilterScriptInit()
- {
- secfence = CreateObject(3276, -1093.8, -1255.3, 129.1, 0.0, 0.0, 0.0);
- info_pickup = CreatePickup(1239, 1, -1078.2122,-1247.8104,129.2188);
- print("Shit-Yourself-Rich! has been loaded. Many credit to Hiddos");
- return 1;
- }
- public OnFilterScriptExit()
- {
- if(cstate != 0 ) KillTimer(timer);
- DestroyObject(secfence);
- DestroyPickup(info_pickup);
- for(new i; i != MAX_PLAYERS; i++)
- {
- if(Bets[i][hasbet] == true)
- {
- Delete3DTextLabel(Bets[i][bettext]);
- GivePlayerMoney(i, Bets[i][sumbet]);
- }
- else if(Bets[i][isbetting] == true)
- {
- SetPlayerPos(i, -1078.2122,-1245.8104,129.2188);
- DestroyVehicle(betvehicles[i]);
- GivePlayerMoney(i, Bets[i][sumbet]);
- }
- }
- if(cstate >= 2)
- {
- DestroyObject(cow);
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- firstvisit[playerid] = true;
- shouldcall[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(Bets[playerid][hasbet] == true)
- {
- Delete3DTextLabel(Bets[playerid][bettext]);
- Bets[playerid][hasbet] = false;
- }
- else if(Bets[playerid][isbetting] == true)
- {
- DestroyVehicle(betvehicles[playerid]);
- Bets[playerid][isbetting] = false;
- }
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- if(shouldcall[playerid] == -1 || GetTickCount() < shouldcall[playerid] || IsPlayerInAnyVehicle(playerid)) return 1;
- if(pickupid == info_pickup)
- {
- if(firstvisit[playerid] == true)
- {
- new str[420];
- 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);
- ShowPlayerDialog(playerid, DIALOG_INDEX + 1, DIALOG_STYLE_MSGBOX, "Shit Yourself Rich!",str, "Ok", "");
- }
- else
- {
- if(Bets[playerid][hasbet] == false) { ShowPlayerDialog(playerid, DIALOG_INDEX + 0, DIALOG_STYLE_LIST, "Shit Yourself Rich!", "Welcome\nPlace Bet\nLeave", "Choose", ""); }
- else { ShowPlayerDialog(playerid, DIALOG_INDEX + 0, DIALOG_STYLE_LIST, "Shit Yourself Rich!", "Welcome\nReview Bet\nLeave", "Choose", ""); }
- }
- }
- shouldcall[playerid] = -1;
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_INDEX + 0: // the menu
- {
- if(response == 0)
- {
- shouldcall[playerid] = GetTickCount() + SC_INTERVAL;
- return 1;
- }
- switch(listitem)
- {
- case 0: //Welcome
- {
- new str[420];
- 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);
- ShowPlayerDialog(playerid, DIALOG_INDEX + 1, DIALOG_STYLE_MSGBOX, "Shit Yourself Rich!",str, "Ok", "");
- return 1;
- }
- case 1: //review/place bet
- {
- if(cstate >= 2)
- {
- 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", "");
- }
- if(Bets[playerid][hasbet] == true) // review bet
- {
- new str[128];
- format(str, sizeof str, "You've placed a bet of {FF5721}$%i{FFFFFF}! There's no backing out now anymore!", Bets[playerid][sumbet]);
- ShowPlayerDialog(playerid, DIALOG_INDEX + 3, DIALOG_STYLE_MSGBOX, "Shit Yourself Rich!", str, "Ok", "");
- }
- 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");
- return 1;
- }
- case 2:
- {
- shouldcall[playerid] = GetTickCount() + SC_INTERVAL;
- return 1; //Leave
- }
- }
- }
- case DIALOG_INDEX + 1:
- {
- if(response == 0 && firstvisit[playerid] == true)
- {
- firstvisit[playerid] = false;
- shouldcall[playerid] = GetTickCount() + SC_INTERVAL;
- return 1;
- }
- firstvisit[playerid] = false;
- if(Bets[playerid][hasbet] == false) { ShowPlayerDialog(playerid, DIALOG_INDEX + 0, DIALOG_STYLE_LIST, "Shit Yourself Rich!", "Welcome\nPlace Bet\nLeave", "Choose", ""); }
- else { ShowPlayerDialog(playerid, DIALOG_INDEX + 0, DIALOG_STYLE_LIST, "Shit Yourself Rich!", "Welcome\nReview Bet\nLeave", "Choose", ""); }
- return 1;
- }
- case DIALOG_INDEX + 2:
- {
- 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;
- if(response == 0) return ShowPlayerDialog(playerid, DIALOG_INDEX + 0, DIALOG_STYLE_LIST, "Shit Yourself Rich!", "Welcome\nPlace Bet\nLeave", "Choose", ""), 1;
- new bet = strval(inputtext);
- 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;
- 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;
- Bets[playerid][isbetting] = true;
- Bets[playerid][sumbet] = bet;
- betvehicles[playerid] = CreateVehicle(594, -1100.0, -1270.0, 129.1, 0.0, -1, -1, 0);
- PutPlayerInVehicle(playerid, betvehicles[playerid], 0);
- 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", "");
- shouldcall[playerid] = 0;
- }
- case DIALOG_INDEX + 3: return ShowPlayerDialog(playerid, DIALOG_INDEX + 0, DIALOG_STYLE_LIST, "Shit Yourself Rich!", "Welcome\nReview Bet\nLeave", "Choose", "") , 1; // review bet
- case DIALOG_INDEX + 4: return 1; // Bet Confirm
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(Bets[playerid][isbetting] == true && (newkeys & KEY_HANDBRAKE || newkeys & KEY_SECONDARY_ATTACK))
- {
- GetVehiclePos(betvehicles[playerid], Bets[playerid][betPos][0], Bets[playerid][betPos][1], Bets[playerid][betPos][2]);
- SetPlayerPos(playerid, -1078.2122,-1245.8104,129.2188);
- Bets[playerid][isbetting] = false;
- Bets[playerid][hasbet] = true;
- GivePlayerMoney(playerid, -Bets[playerid][sumbet]);
- new str[MAX_PLAYER_NAME];
- GetPlayerName(playerid, str, MAX_PLAYER_NAME);
- Bets[playerid][bettext] = Create3DTextLabel(str, 0x00FF00FF, Bets[playerid][betPos][0], Bets[playerid][betPos][1], Bets[playerid][betPos][2] + 3.4, 180.0, 0);
- DestroyVehicle(betvehicles[playerid]);
- cur_bets++;
- if(cur_bets == 1)
- {
- new str2[148];
- 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);
- SendClientMessageToAll(-1, str2);
- timer = SetTimer("cowRaise", 3 * 60 * 1000, false);
- cstate = 1;
- }
- }
- return 1;
- }
- forward cowRaise();
- public cowRaise()
- {
- for(new i; i != MAX_PLAYERS; i++)
- {
- if(Bets[i][isbetting] == true)
- {
- Bets[i][isbetting] = false;
- DestroyVehicle(betvehicles[i]);
- SetPlayerPos(i, -1078.2122,-1245.8104,129.2188);
- SendClientMessage(i, -1, "Sorry, you're too late. The game has already started!");
- }
- }
- cstate = 2;
- new Float:fieldX = field[0][0] + random(floatround(field[1][0]-field[0][0]));
- new Float:fieldY = field[0][1] + random(floatround(field[1][1]-field[0][1]));
- cow = CreateObject(16442, fieldX, fieldY, 129.2188 - 1.0, 0.0, 0.0, random(360));
- MoveObject(cow, fieldX, fieldY, 129.2188 + 0.8, 1.0);
- }
- public OnObjectMoved(objectid)
- {
- if(objectid == cow)
- {
- switch(cstate)
- {
- case 0..1: return 1;
- case 2:
- {
- cstate = 3;
- timer = SetTimer("MoveCowToRandomLoc", random(3000), false);
- return 1;
- }
- case 3:
- {
- new yn = random(8);
- if(yn == 0)
- {
- cstate = 4;
- ccd = 12;
- timer = SetTimer("CowPoop", random(4000), false);
- }
- else
- {
- timer = SetTimer("MoveCowToRandomLoc", random(3000), false);
- }
- return 1;
- }
- }
- }
- return 1;
- }
- forward MoveCowToRandomLoc();
- public MoveCowToRandomLoc()
- {
- new Float:x, Float:y, Float:oldpos[3];
- GetObjectPos(cow, oldpos[0], oldpos[1], oldpos[2]);
- x = field[0][0] + random(floatround(field[1][0] - field[0][0]));
- y = field[0][1] + random(floatround(field[1][1] - field[0][1]));
- oldpos[2] = atan((y - oldpos[1]) / (x - oldpos[0]));
- if(x < oldpos[0]) oldpos[2] += -180.0;
- oldpos[2] -= 2.0;
- SetObjectRot(cow, 0.0, 0.0, oldpos[2]);
- MoveObject(cow, x, y, 129.2188 + 0.8, 3.8);
- }
- forward CowPoop();
- public CowPoop()
- {
- ccd--;
- if(ccd == 0)
- {
- new Float:loc[3];
- GetObjectPos(cow, loc[0], loc[1], loc[2]);
- CreateExplosion(loc[0], loc[1], loc[2], 1, 0.2);
- for(new i; i != MAX_PLAYERS; i++)
- {
- if(Bets[i][hasbet] == true)
- {
- new Float:range = 16.0 - floatsqroot((floatpower(loc[0] - Bets[i][betPos][0], 2) + floatpower(loc[1] - Bets[i][betPos][1], 2)));
- if(range <= 0.0)
- {
- SendClientMessage(i, -1, "Sorry, you didn't win anything this round!");
- continue;
- }
- new str[128];
- new win = floatround(range * float(Bets[i][sumbet]));
- GivePlayerMoney(i, win);
- 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);
- SendClientMessage(i, -1, str);
- }
- }
- SetTimer("CleanThisShitUp", 30 * 1000, false);
- }
- else
- {
- new Float:rot[3];
- GetObjectRot(cow, rot[0], rot[1], rot[2]);
- SetObjectRot(cow, float(random(20)) - 10.0, float(random(20)) - 10.0, rot[2]);
- GetObjectPos(cow, rot[0], rot[1], rot[1]);
- 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);
- timer = SetTimer("CowPoop", 170, false);
- }
- }
- forward CleanThisShitUp();
- public CleanThisShitUp()
- {
- DestroyObject(cow);
- for(new i; i != MAX_PLAYERS; i++)
- {
- if(Bets[i][hasbet] == true)
- {
- Bets[i][hasbet] = false;
- Delete3DTextLabel(Bets[i][bettext]);
- }
- }
- cstate = 0;
- cur_bets = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement