Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD:buyproducts(playerid, params[])
- {
- new amount, price, string[128];
- new idx = PlayerInfo[playerid][pBiz];
- if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
- if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a business.");
- if(GetPlayerVirtualWorld(playerid)-100 != idx && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
- if(GetPlayerVirtualWorld(playerid)-100 != idx && PlayerInfo[playerid][pVBiz])
- {
- idx = PlayerInfo[playerid][pVBiz];
- if(GetPlayerVirtualWorld(playerid)-100 != idx) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
- }
- if(sscanf(params, "i", amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buyproducts [amount]");
- if(amount < 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid products amount.");
- if(Products < amount)
- {
- format(string, sizeof(string), "The products dropoff currently has %d products only.", Products);
- SendClientMessage(playerid, COLOR_GREY, string);
- return 1;
- }
- price = amount*20;
- if(PlayerInfo[playerid][pCash] < price)
- {
- format(string, sizeof(string), "You don't have that much money on you. ($%d)", price);
- SendClientMessage(playerid, COLOR_GREY, string);
- return 1;
- }
- if(BizInfo[idx][bProducts]+amount > 500) return SendClientMessage(playerid, COLOR_GREY, "Your business can't hold that much products.");
- GivePlayerCash(playerid, -price);
- BizInfo[idx][bProducts] += amount;
- Products -= amount;
- format(string, sizeof(string), "* %s has purchased %d products for $%d.", RPN(playerid), amount, price);
- SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
- format(string, sizeof(string), "Packages Dropoff\n{FFFF00}/deliverpackages to deliver crates\nAvailable Products: %d/20000", Products);
- UpdateDynamic3DTextLabelText(ProductsText, COLOR_RED, string);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement