Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- VERSION 2
- Please try keeping them credits cuz it's took me quite a lot of time for this.
- */
- #define FILTERSCRIPT
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xAA3333AA
- #include <a_samp>
- #include <sscanf2>
- #include <zcmd>
- #include <rInfoBox>
- #include <mapandreas>
- #include <streamer>
- #define MAX_STANDS 50
- enum hInfo
- {
- CP,
- baseprice,
- menuid,
- name[40],
- bool:exists,
- objectid,
- owner[24],
- price,
- Text3D:namelabel,
- Text3D:pricelabel,
- bool:owned,
- offeredcash,
- offerer[24]
- }
- new HotInfo[MAX_STANDS][hInfo];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Dynamic hot dog stand creator ! ");
- print(" Author: Rajat _ Pawar ");
- print(" Version: 2 ");
- print(" Hunger: 100% ");
- print(" Thanks, cheers ");
- print("--------------------------------------\n");
- MapAndreas_Init(1);
- for( new i; i < MAX_STANDS; i++)
- {
- HotInfo[i][exists] = false;
- HotInfo[i][owned] = false;
- HotInfo[i][offeredcash] = 0;
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- CMD:createfoodstall(playerid, params[])
- {
- new costbase, st[20];
- if(GetPlayerState(playerid) == 0) return SendClientMessage(playerid, COLOR_RED, "You need to be spawned.");
- if(sscanf(params, "s[20]d", st, costbase)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /createfoodstall (name of stall) (baseprice)");
- else
- {
- for( new i; i < MAX_STANDS; i++)
- {
- if( HotInfo[i][exists] == false)
- {
- new Float:x, Float:y, Float:z, Float:tz, Float:angle;
- GivePlayerMoney(playerid, -costbase);
- GetPlayerPos(playerid, x, y, z );
- MapAndreas_FindZ_For2DCoord(x, y, tz);
- GetPlayerFacingAngle(playerid, angle);
- HotInfo[i][objectid] = CreateObject(1340, x + (2.0 * floatsin(-angle - 28, degrees)), y + (2.0 * floatcos(-angle - 20, degrees)), tz + 1.3, 0, 0, angle, 100);
- HotInfo[i][CP] = CreateDynamicCP(x + 2*floatcos(90+angle, degrees), y+ 2*floatsin(90-angle, degrees), tz, 1.3, 0, 0, 0, 100);
- SendClientMessage(playerid, COLOR_GREEN, "You have created a hotdog stand! Enjoy !");
- printf("%d", HotInfo[i][CP]);
- HotInfo[i][exists] = true;
- HotInfo[i][baseprice] = costbase;
- format(HotInfo[i][name], 40, "%s", st);
- HotInfo[i][namelabel] = Create3DTextLabel(st, 0xF5BC11FF, x + 2*floatcos(90+angle, degrees), y+ 2*floatsin(90-angle, degrees), tz + 0.8, 10, GetPlayerVirtualWorld(playerid), 0);
- HotInfo[i][pricelabel] = Create3DTextLabel("Price: $50,000.", COLOR_GREEN, x + 2*floatcos(90+angle, degrees), y+ 2*floatsin(90-angle, degrees), tz + 0.6, 10, GetPlayerVirtualWorld(playerid), 0);
- new string[220], nstring[50];
- format(string, 450, "~w~1. ~y~Buy a ~r~hotdog. ~g~($%d)~n~~w~2.~y~ Buy a ~r~pork sandwich. ~g~($%d)~n~~w~3.~y~ Buy a ~r~pizza. ~g~($%d)~n~~w~4.~y~ Buy a ~r~nachos packet. ~g~($%d)", HotInfo[i][baseprice], HotInfo[i][baseprice] + 10, HotInfo[i][baseprice] + 36, HotInfo[i][baseprice] + 19);
- format(nstring, 50, "~n~~w~5.~y~ Buy a~r~ taco. ~g~($%d)", HotInfo[i][baseprice] + 11);
- strcat(string, nstring);
- HotInfo[i][menuid] = CreateTDboxForPlayer(playerid, HotInfo[i][name], COLOR_GREEN, string);
- break;
- }
- else continue;
- }
- }
- return 1;
- }
- CMD:cfs(playerid, params[])
- {
- return cmd_createfoodstall(playerid, params);
- }
- public OnPlayerEnterDynamicCP(playerid, checkpointid)
- {
- for( new i = 0; i < MAX_STANDS; i++)
- {
- if(HotInfo[i][exists] != false)
- {
- if(checkpointid == HotInfo[i][CP])
- {
- ShowTDboxToPlayer(playerid, HotInfo[i][menuid]);
- if(HotInfo[i][owned] == false) SendClientMessage(playerid, COLOR_GREEN, "This stall is for sale. Use /buystall to buy it!");
- else { new string[90]; format(string, 90, "This stall is owned by {00FF00}%s. Use /offer to offer a price for it.", HotInfo[i][owner]); SendClientMessage(playerid, COLOR_GREEN, string); }
- new names[MAX_PLAYER_NAME], string[128];
- GetPlayerName(playerid, names, 24);
- if(strcmp(names, HotInfo[i][owner], true) == 0)
- {
- if( HotInfo[i][offeredcash] > 0)
- {
- format(string, 128, "You have been offered~g~ $%d ~n~for ~w~this stall by %s.", HotInfo[i][offeredcash], HotInfo[i][offerer]);
- GameTextForPlayer(playerid, string, 10000, 5);
- return SendClientMessage(playerid, COLOR_GREEN, "Use /reply (YES/NO) to reply to the offer.");
- }
- SendClientMessage(playerid, COLOR_GREEN, "Welcome back to your stall. Use /changeprice to change the price of your stall.");
- SendClientMessage(playerid, COLOR_GREEN, "Also, you can use /changename to change the name of your stall.");
- }
- break;
- }
- }
- else continue;
- }
- return 1;
- }
- CMD:changeprice(playerid, params[])
- {
- new pricef;
- if(sscanf(params, "d", pricef)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changeprice (new price)");
- {
- for( new i = 0; i < MAX_STANDS; i++)
- {
- if(HotInfo[i][exists] != false)
- {
- if(HotInfo[i][owned] != false)
- {
- if(IsPlayerInDynamicCP(playerid, HotInfo[i][CP]))
- {
- new names[MAX_PLAYER_NAME];
- GetPlayerName(playerid, names, 24);
- if(strcmp(names, HotInfo[i][owner], true) == 0)
- {
- SendClientMessage(playerid, COLOR_GREEN, "You have successfully changed the food items' price of your stall.");
- HotInfo[i][baseprice] = pricef;
- HideTDboxForPlayer(playerid, HotInfo[i][menuid]);
- new string[220], nstring[50];
- format(string, 450, "~w~1. ~y~Buy a ~r~hotdog. ~g~($%d)~n~~w~2.~y~ Buy a ~r~pork sandwich. ~g~($%d)~n~~w~3.~y~ Buy a ~r~pizza. ~g~($%d)~n~~w~4.~y~ Buy a ~r~nachos packet. ~g~($%d)", HotInfo[i][baseprice], HotInfo[i][baseprice] + 10, HotInfo[i][baseprice] + 36, HotInfo[i][baseprice] + 19);
- format(nstring, 50, "~n~~w~5.~y~ Buy a~r~ taco. ~g~($%d)", HotInfo[i][baseprice] + 11);
- strcat(string, nstring);
- HotInfo[i][menuid] = 0;
- HotInfo[i][menuid] = CreateTDboxForPlayer(playerid, HotInfo[i][name], COLOR_GREEN, string);
- break;
- }
- }
- }
- }
- }
- }
- return 1;
- }
- CMD:changename(playerid, params[])
- {
- new namez[40];
- if(sscanf(params, "s[40]", namez)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changename (new name of stall)");
- {
- for( new i = 0; i < MAX_STANDS; i++)
- {
- if(HotInfo[i][exists] != false)
- {
- if(HotInfo[i][owned] != false)
- {
- if(IsPlayerInDynamicCP(playerid, HotInfo[i][CP]))
- {
- new names[MAX_PLAYER_NAME];
- GetPlayerName(playerid, names, 24);
- if(strcmp(names, HotInfo[i][owner], true) == 0)
- {
- SendClientMessage(playerid, COLOR_GREEN, "You have successfully changed the name of your stall.");
- HideTDboxForPlayer(playerid, HotInfo[i][menuid]);
- format(HotInfo[i][name], 40, "%s", namez);
- new string[220], nstring[50];
- format(string, 450, "~w~1. ~y~Buy a ~r~hotdog. ~g~($%d)~n~~w~2.~y~ Buy a ~r~pork sandwich. ~g~($%d)~n~~w~3.~y~ Buy a ~r~pizza. ~g~($%d)~n~~w~4.~y~ Buy a ~r~nachos packet. ~g~($%d)", HotInfo[i][baseprice], HotInfo[i][baseprice] + 10, HotInfo[i][baseprice] + 36, HotInfo[i][baseprice] + 19);
- format(nstring, 50, "~n~~w~5.~y~ Buy a~r~ taco. ~g~($%d)", HotInfo[i][baseprice] + 11);
- strcat(string, nstring);
- HotInfo[i][menuid] = 0;
- HotInfo[i][menuid] = CreateTDboxForPlayer(playerid, HotInfo[i][name], COLOR_GREEN, string);
- Update3DTextLabelText(HotInfo[i][namelabel], COLOR_GREEN, HotInfo[i][name]);
- return 1;
- }
- }
- }
- }
- }
- }
- return 1;
- }
- CMD:reply(playerid, params[])
- {
- new names[MAX_PLAYER_NAME], string[6];
- GetPlayerName(playerid, names, 24);
- if(sscanf(params, "s[6]", string)) return SendClientMessage(playerid, COLOR_GREEN, "USAGE: /reply (YES/NO)");
- for( new i = 0; i < MAX_STANDS; i++)
- {
- if(HotInfo[i][exists] != false)
- {
- if(strcmp(names, HotInfo[i][owner], true) == 0)
- {
- if(HotInfo[i][offeredcash] > HotInfo[i][price])
- {
- if(strcmp(string, "yes", true) != -1)
- {
- format(HotInfo[i][owner], 24, "%s", HotInfo[i][offerer]);
- HotInfo[i][price] += HotInfo[i][offeredcash];
- new st[80]; format(st, 80, "Owner: %s", names);
- Update3DTextLabelText(HotInfo[i][pricelabel], COLOR_RED, st);
- Update3DTextLabelText(HotInfo[i][namelabel], COLOR_GREEN, HotInfo[i][name]);
- format(HotInfo[i][offerer], 24, "%s", " ");
- format(st, 80, "You have sold %s your stall for $%d. You are no longer the owner.", names, HotInfo[i][offeredcash]);
- HotInfo[i][offeredcash] = 0;
- SendClientMessage(playerid, COLOR_GREEN, st);
- if(GetPlayerID(HotInfo[i][offerer]) != INVALID_PLAYER_ID)
- {
- SendClientMessage(GetPlayerID(HotInfo[i][offerer]), COLOR_GREEN, "You have been sold the stall for your offered cash. Good luck.");
- GivePlayerMoney(GetPlayerID(HotInfo[i][offerer]), - HotInfo[i][offeredcash]);
- }
- }
- else if(strcmp(string, "no", true) != -1)
- {
- new st[80];
- format(st, 80, "You have rejected %s's offer for your stall of $%d.", names, HotInfo[i][offeredcash]);
- SendClientMessage(playerid, COLOR_GREEN, st);
- HotInfo[i][offeredcash] = 0;
- format(HotInfo[i][offerer], 24, "%s", " ");
- if(GetPlayerID(HotInfo[i][offerer]) != INVALID_PLAYER_ID)
- {
- SendClientMessage(GetPlayerID(HotInfo[i][offerer]), COLOR_GREEN, "Your offer for the stall was rejected. Better luck next time.");
- }
- }
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerLeaveDynamicCP(playerid, checkpointid)
- {
- for( new i = 0; i < MAX_STANDS; i++)
- {
- if(HotInfo[i][exists] != false)
- {
- if(checkpointid == HotInfo[i][CP])
- {
- HideTDboxForPlayer(playerid, HotInfo[i][menuid]);
- break;
- }
- else continue;
- }
- else continue;
- }
- return 1;
- }
- CMD:buystall(playerid)
- {
- for( new i = 0; i < MAX_STANDS; i++)
- {
- if(HotInfo[i][exists] == false) continue;
- {
- if(!IsPlayerInDynamicCP(playerid, HotInfo[i][CP])) continue;
- {
- if(HotInfo[i][owned] == true) continue;
- {
- if(GetPlayerMoney(playerid) - 50000 < 0 ) return SendClientMessage(playerid, COLOR_RED, "You cannot buy this stall, you need more money!");
- else {
- GivePlayerMoney(playerid, -50000);
- SendClientMessage(playerid, COLOR_GREEN, "Congratulations, you have bought this stall.");
- GameTextForPlayer(playerid, "~g~Congratulations, you have bought ~n~this ~r~stall.", 5000, 5);
- new names[MAX_PLAYER_NAME], string[30], s[30];
- format(s, 30, "%s", HotInfo[i][name]);
- GetPlayerName(playerid, names, 24);
- format(HotInfo[i][owner], 24, "%s", names);
- format(string, 30, "Owner: %s", names);
- HotInfo[i][owned] = true;
- HotInfo[i][price] = 50000;
- Update3DTextLabelText(HotInfo[i][pricelabel], COLOR_RED, string);
- Update3DTextLabelText(HotInfo[i][namelabel], COLOR_GREEN, s);
- }
- }
- }
- }
- }
- return 1;
- }
- CMD:offer(playerid, params[])
- {
- new offeredcas; new namez[MAX_PLAYER_NAME]; GetPlayerName(playerid, namez, 24);
- for( new i = 0; i < MAX_STANDS; i++)
- {
- if(HotInfo[i][exists] == false) continue;
- {
- if(strcmp(namez, HotInfo[i][owner], true) == 0) return SendClientMessage(playerid, COLOR_RED, "You already have a stall.");
- {
- if(!IsPlayerInDynamicCP(playerid, HotInfo[i][CP])) continue;
- {
- if(HotInfo[i][owned] == false) return SendClientMessage(playerid, COLOR_RED, "This stall is for sale, just use /buystall!");
- {
- if(GetPlayerMoney(playerid) < HotInfo[i][price]) return SendClientMessage(playerid, COLOR_RED, "Get some cash first. *More than $50, 000 to offer*");
- else if(sscanf(params, "d", offeredcas)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /offer (cash) (cash should be greater than original price.");
- {
- if(offeredcas < HotInfo[i][price]) return SendClientMessage(playerid, COLOR_RED, "More than $50000.");
- new names[MAX_PLAYER_NAME], string[110];
- GetPlayerName(playerid, names, 24);
- format(HotInfo[i][offerer], 24, "%s", names);
- HotInfo[i][offeredcash] = offeredcas;
- format(string, 110, "You (%s) have offered %s $%d for his stall. Wait to see if he replies.", HotInfo[i][offerer], HotInfo[i][owner], offeredcas);
- SendClientMessage(playerid, COLOR_GREEN, string);
- return 1;
- }
- }
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(text[0] == '1' || text[0] == '2' || text[0] == '3' || text[0] == '4' || text[0] == '5')
- {
- for( new i = 0; i < MAX_STANDS; i++)
- {
- if(HotInfo[i][exists] == false) continue;
- {
- if(!IsPlayerInDynamicCP(playerid, HotInfo[i][CP])) continue;
- {
- new s = strval(text[0]);
- switch(s)
- {
- case 1:
- {
- if(GetPlayerMoney(playerid) - HotInfo[i][baseprice] > 0)
- {
- GivePlayerMoney(playerid, - HotInfo[i][baseprice]); new st[70];
- format(st, 70, "You have bought a hot dog for $%d.", HotInfo[i][baseprice]);
- SendClientMessage(playerid, COLOR_GREEN, st);
- ApplyAnimation(playerid,"FOOD","EAT_Burger", 3, 0, 1, 1, 1, 1, 1);
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "You don't have enough money to buy a hot dog.");
- ApplyAnimation(playerid,"ped","fucku", 3, 0, 1, 1, 1, 1, 1);
- return 0;
- }
- }
- case 2:
- {
- if(GetPlayerMoney(playerid) - (HotInfo[i][baseprice] + 10) > 0)
- {
- GivePlayerMoney(playerid, - (HotInfo[i][baseprice] + 10)); new st[70];
- format(st, 70, "You have bought a pork sandwich for $%d.", HotInfo[i][baseprice] + 10);
- SendClientMessage(playerid, COLOR_GREEN, st);
- ApplyAnimation(playerid,"FOOD","EAT_Burger", 3, 0, 1, 1, 1, 1, 1);
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "You don't have enough money to buy a pork sandwich.");
- ApplyAnimation(playerid,"ped","fucku", 3, 0, 1, 1, 1, 1, 1);
- return 0;
- }
- }
- case 3:
- {
- if(GetPlayerMoney(playerid) - (HotInfo[i][baseprice] + 36) > 0)
- {
- GivePlayerMoney(playerid, - (HotInfo[i][baseprice] + 36)); new st[70];
- format(st, 70, "You have bought a pizza for $%d.", HotInfo[i][baseprice] + 36);
- SendClientMessage(playerid, COLOR_GREEN, st);
- ApplyAnimation(playerid,"FOOD","EAT_Burger", 3, 0, 1, 1, 1, 1, 1);
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "You don't have enough money to buy a pizza.");
- ApplyAnimation(playerid,"ped","fucku", 3, 0, 1, 1, 1, 1, 1);
- return 0;
- }
- }
- case 4:
- {
- if(GetPlayerMoney(playerid) - (HotInfo[i][baseprice] + 19) > 0)
- {
- GivePlayerMoney(playerid, - (HotInfo[i][baseprice] + 19)); new st[70];
- format(st, 70, "You have bought a nachos packet for $%d.", HotInfo[i][baseprice] + 19);
- SendClientMessage(playerid, COLOR_GREEN, st);
- ApplyAnimation(playerid,"FOOD","EAT_Burger", 3, 0, 1, 1, 1, 1, 1);
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "You don't have enough money to buy a packet of nachos.");
- ApplyAnimation(playerid,"ped","fucku", 3, 0, 1, 1, 1, 1, 1);
- return 0;
- }
- }
- case 5:
- {
- if(GetPlayerMoney(playerid) - (HotInfo[i][baseprice] + 11) > 0)
- {
- GivePlayerMoney(playerid, - (HotInfo[i][baseprice] + 11)); new st[70];
- format(st, 70, "You have bought a taco for $%d.", HotInfo[i][baseprice] + 11);
- SendClientMessage(playerid, COLOR_GREEN, st);
- ApplyAnimation(playerid,"FOOD","EAT_Burger", 3, 0, 1, 1, 1, 1, 1);
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "You don't have enough money to buy a taco.");
- ApplyAnimation(playerid,"ped","fucku", 3, 0, 1, 1, 1, 1, 1);
- return 0;
- }
- }
- }
- }
- }
- return 0;
- }
- }
- return 1;
- }
- CMD:money(playerid)
- {
- GivePlayerMoney(playerid, 125112);
- return 1;
- }
- stock GetPlayerID(playername[])
- {
- for(new i = 0; i <= MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- new playername2[MAX_PLAYER_NAME];
- GetPlayerName(i, playername2, sizeof(playername2));
- if(strcmp(playername2, playername, true, strlen(playername)) == 0)
- {
- return i;
- }
- }
- }
- return INVALID_PLAYER_ID;
- }
Advertisement
Add Comment
Please, Sign In to add comment