Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new plantseedcount[MAX_PLAYERS];
- new plantseedtimer[MAX_PLAYERS];
- CMD:buyseeds(playerid,params[])
- {
- new formatstring[100];
- if(!IsPlayerInRangeOfPoint(playerid,3.5,1363.6545,-1718.6127,8.5180) &&
- !IsPlayerInRangeOfPoint(playerid,3.5,2783.6255,-2373.3210,13.6328) &&
- !IsPlayerInRangeOfPoint(playerid,3.5,2351.7390,-648.0338,128.0547)) return SendClientMessage(playerid,-1,"[SERVER]You are not near a drug market spot.");
- new amount;
- if(sscanf(params, "d", amount)) return SendClientMessage(playerid,-1,"[SERVER] Correct usage: /buyseeds [amount]");
- if(amount < 1 || amount > 250) return SendClientMessage(playerid,-1,"[SERVER] You are not permitted to buy seeds in bulk, you may only buy 250 seeds.");
- if(GetPlayerMoney(playerid) < (amount*100))
- {
- new str[128]; format(str, sizeof(str), "You need %s in order to buy %d seeds.", FormatNumber(amount*100), amount);
- SendClientMessage(playerid, -1, str);
- return 1;
- }
- if(GetPVarInt(playerid, "Usedbuyseeds") ==1)
- {
- format(formatstring, 100, "[SERVER]You are attracting too much heat, you will need to wait %d seconds before buying again", plantseedcount[playerid]);
- SendClientMessage(playerid,-1,formatstring);
- return true;
- }
- SetPVarInt(playerid, "Usedbuyseeds", 1);
- plantseedcount[playerid] = 50;
- plantseedtimer[playerid] = SetTimerEx("Resetbuyseeds", 1000, true, "i", playerid);
- GivePlayerMoney(playerid, -(amount*100));
- pinfo[playerid][seeds] = pinfo[playerid][seeds] + amount;
- format(formatstring, 100, "[SERVER]You bought %d seed for %s!", amount, FormatNumber((amount*100)));
- SendClientMessage(playerid, -1, formatstring);
- return 1;
- }
- stock FormatNumber(number, prefix[] = "$")
- {
- new value[32], length;
- format(value, sizeof(value), "%d", (number < 0) ? (-number) : (number));
- if((length = strlen(value)) > 3)
- {
- for(new i = length, l = 0; --i >= 0; l ++) {
- if((l > 0) && (l % 3 == 0)) strins(value, ",", i + 1);
- }
- }
- if(prefix[0] != 0) strins(value, prefix, 0);
- if(number < 0) strins(value, "-", 0);
- return value;
- }
- forward Resetbuyseeds(playerid);
- public Resetbuyseeds(playerid)
- {
- if(plantseedcount[playerid] == 0)
- {
- if(IsPlayerConnected(playerid)) DeletePVar(playerid, "Usedbuyseeds"), KillTimer(plantseedtimer[playerid]);
- }
- return plantseedcount[playerid]--;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement