Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <crashdetect>
- #include <YSI\y_iterate>
- #include <YSI\y_timers>
- #include <y_foreach>
- #include <sscanf2>
- #include <zcmd>
- #include <streamer>
- #define MAX_WEEDS 1000
- #define MAX_LOOTS 1000
- new Iterator:Weeds<MAX_WEEDS>;
- new Iterator:Loots<MAX_LOOTS>;
- enum weedinfo {
- wProgress,
- wObjectID,
- Float:wLocation[3],
- Float:oPosition[3],
- Text3D:wLabel,
- Timer,
- Timer:x,
- wSeed
- }
- new WeedInfo[MAX_WEEDS][weedinfo];
- enum pinfo {
- pSelection,
- Seeds[5],
- Weed[5]
- }
- new PlayerInfo[MAX_PLAYERS][pinfo];
- enum lootinfo {
- Text3D:lLabel,
- Float:lLocation[3],
- wType,
- wGrams,
- lObjectID
- }
- new LootInfo[MAX_LOOTS][lootinfo];
- enum seedpacks {
- id,
- SeedName[36],
- SeedPrice,
- GpS,
- time
- }
- new SeedInformation[][seedpacks] =
- {
- {0, "Cannabis Indica", 500, 3, 60},
- {1, "Cannabis Sativa", 500, 1, 30}
- };
- new DrugsList[MAX_PLAYERS][5];
- new ListChoice[MAX_PLAYERS];
- new ToID[MAX_PLAYERS];
- stock PlayerName(playerid)
- {
- new ppName[24];
- GetPlayerName(playerid, ppName, 24);
- return ppName;
- }
- public OnFilterScriptInit()
- {
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- PlayerInfo[playerid][pSelection] = -1;
- for(new i = 0; i < 5; i++)
- {
- PlayerInfo[playerid][Seeds][i] = 0;
- PlayerInfo[playerid][Weed][i] = 0;
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- PlayerInfo[playerid][pSelection] = -1;
- for(new i = 0; i < 5; i++)
- {
- PlayerInfo[playerid][Seeds][i] = 0;
- PlayerInfo[playerid][Weed][i] = 0;
- }
- return 1;
- }
- CMD:pickpackup(playerid, params[])
- {
- foreach(new i : Loots)
- {
- if(IsPlayerInRangeOfPoint(playerid, 2, LootInfo[i][lLocation][0], LootInfo[i][lLocation][1], LootInfo[i][lLocation][2]))
- {
- new string[128];
- PlayerInfo[playerid][Weed][LootInfo[i][wType]] += LootInfo[i][wGrams];
- format(string, sizeof string, "* {E1E858}You have picked up a pack containing %i grams of %s.", LootInfo[i][wGrams], SeedInformation[LootInfo[i][wType]][SeedName]);
- SendClientMessage(playerid, -1, string);
- LootInfo[i][wGrams] = 0;
- LootInfo[i][wType] = -1;
- DestroyDynamic3DTextLabel(LootInfo[i][lLabel]);
- DestroyDynamicObject(LootInfo[i][lObjectID]);
- Iter_Remove(Loots, i);
- ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,0 ,0,0,0,0,1);
- break;
- }
- }
- return 1;
- }
- CMD:buyseeds(playerid, params[])
- {
- new string[1000];
- //if(!IsPlayerInRangeOfPoint(playerid, 2, 0, 0, 0)) return SendClientMessage(playerid, "{FF0000}ERROR: {FFFFFF}You must be in range of the dealer to buy seed packs.");
- for(new i; i < sizeof SeedInformation; i++)
- {
- if(i != sizeof(SeedInformation))
- format(string, sizeof string, "%s{FFFFFF}[{E1E858}ID: %i{FFFFFF}] %s\t\t{FFFFFF}%d{4BD176}$\n", string, i, SeedInformation[i][SeedName], SeedInformation[i][SeedPrice]);
- else
- format(string, sizeof string, "%s{FFFFFF}[{E1E858}ID: %i{FFFFFF}] %s\t\t{FFFFFF}%d{4BD176}$", string, SeedInformation[i][SeedName], SeedInformation[i][SeedPrice]);
- }
- PlayerInfo[playerid][pSelection] = -1;
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "{EBC11A}WEED: {FFFFFF}Seeds menu", string, "Buy", "Close");
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 1)
- {
- if(response)
- {
- PlayerInfo[playerid][pSelection] = listitem;
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{EBC11A}WEED: {FFFFFF}Seeds menu", "{FFFFFF}Select the amount of seeds you would like to buy.", "Buy", "Close");
- }
- return 1;
- }
- if(dialogid == 2)
- {
- if(response)
- {
- if(strval(inputtext) <= 0) return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}You cannot buy this amount of seeds.");
- new input = strval(inputtext), selection=PlayerInfo[playerid][pSelection];
- //if(GetPlayerMoney(playerid) < (SeedInformation[selection][SeedPrice])*input) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You do not have enough money for these seeds.");
- GivePlayerMoney(playerid, -(SeedInformation[selection][SeedPrice])*input);
- PlayerInfo[playerid][Seeds][selection] += input;
- new string[128];
- format(string, sizeof string, "* {E1E858}You have bought %i %s seeds.", input, SeedInformation[selection][SeedName]);
- SendClientMessage(playerid, -1, string);
- }
- return 1;
- }
- if(dialogid == 3)
- {
- if(response)
- {
- ListChoice[playerid] = listitem;
- ToID[playerid] = -1;
- ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "{EBC11A}WEED: {FFFFFF}Weed management", "{FFFFFF}Pack and drop\n{FFFFFF}Give to another\n{FFFFFF}Disperse", "Perform", "Close");
- }
- return 1;
- }
- if(dialogid == 4)
- {
- if(response)
- {
- if(listitem == 0) {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "{EBC11A}WEED: {FFFFFF}Weed management", "{FFFFFF}Choose the amount of drugs you would like to package and drop:", "Pack and drop", "Close");
- }
- if(listitem == 1) {
- ShowPlayerDialog(playerid, 8, DIALOG_STYLE_INPUT, "{EBC11A}WEED: {FFFFFF}Weed management", "{FFFFFF}Choose the person (ID) you would like to give drugs to:", "Give", "Close");
- if(IsPlayerConnected(strval(inputtext))) {
- SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}Player ID is invalid.");
- }
- else {
- ToID[playerid] = strval(inputtext);
- }
- }
- if(listitem == 2) {
- ShowPlayerDialog(playerid, 9, DIALOG_STYLE_INPUT, "{EBC11A}WEED: {FFFFFF}Weed management", "{FFFFFF}Choose the amount of drugs you would like to disperse:", "Disperse", "Close");
- }
- }
- return 1;
- }
- if(dialogid == 7)
- {
- if(response)
- {
- if(strval(inputtext) > PlayerInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]] || strval(inputtext) <= 0) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You do not have that amount of drugs.");
- new lootID = Iter_Free(Loots), Float:PPos[3];
- new slot = DrugsList[playerid][ListChoice[playerid]];
- GetPlayerPos(playerid, PPos[0], PPos[1], PPos[2]);
- PlayerInfo[playerid][Weed][slot] -= strval(inputtext);
- LootInfo[lootID][lLocation][0] = PPos[0];
- LootInfo[lootID][lLocation][1] = PPos[1]-0.1060;
- LootInfo[lootID][lLocation][2] = PPos[2]-0.8;
- LootInfo[lootID][lObjectID] = CreateDynamicObject(1575, PPos[0], PPos[1]-0.1060, PPos[2]-1, 0, 0, 0);
- new title[50];
- format(title, sizeof title, "{E1E858}[%i grams of %s]", strval(inputtext), SeedInformation[slot][SeedName]);
- new string[128];
- format(string, sizeof string, "* {E1E858}You have packed and dropped %i grams of %s; %i left.", strval(inputtext), SeedInformation[slot][SeedName], PlayerInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]]);
- SendClientMessage(playerid, -1, string);
- LootInfo[lootID][lLabel] = CreateDynamic3DTextLabel(title, -1, PPos[0], PPos[1]-0.1060, PPos[2]-0.8, 5);
- LootInfo[lootID][wGrams] = strval(inputtext);
- LootInfo[lootID][wType] = slot;
- Iter_Add(Loots, lootID);
- }
- return 1;
- }
- if(dialogid == 8)
- {
- if(response)
- {
- ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "{EBC11A}WEED: {FFFFFF}Weed management", "{FFFFFF}Choose the amount of drugs you would like to give this person:", "Give", "Close");
- }
- return 1;
- }
- if(dialogid == 9)
- {
- if(response)
- {
- if(strval(inputtext) > PlayerInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]] || strval(inputtext) <= 0) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You do not have that amount of drugs.");
- PlayerInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]] -= strval(inputtext);
- new string[128];
- format(string, sizeof string, "* {E1E858}You have dispersed %i grams of %s; %i left.", strval(inputtext), SeedInformation[DrugsList[playerid][ListChoice[playerid]]][SeedName], PlayerInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]]);
- SendClientMessage(playerid, -1, string);
- }
- return 1;
- }
- if(dialogid == 6)
- {
- if(response)
- {
- if(strval(inputtext) > PlayerInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]] || strval(inputtext) <= 0) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You do not have that amount of drugs.");
- PlayerInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]] -= strval(inputtext);
- PlayerInfo[ToID[playerid]][Weed][DrugsList[playerid][ListChoice[playerid]]] += strval(inputtext);
- new string[128];
- format(string, sizeof string, "* {E1E858}You have given %i grams of %s to %s; %i grams left.", strval(inputtext), SeedInformation[DrugsList[playerid][ListChoice[playerid]]][SeedName], PlayerName(ToID[playerid]), PlayerInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]]);
- SendClientMessage(playerid, -1, string);
- format(string, sizeof string, "* {E1E858}You have been given %i grams of %s from %s; you now got %i grams.", strval(inputtext), SeedInformation[DrugsList[playerid][ListChoice[playerid]]][SeedName], PlayerName(playerid), PlayerInfo[ToID[playerid]][Weed][DrugsList[playerid][ListChoice[playerid]]]);
- SendClientMessage(playerid, -1, string);
- }
- return 1;
- }
- return 0;
- }
- CMD:myseeds(playerid, params[])
- {
- new string[1000], templates[128], results = 0;
- for(new i; i < 5; i++)
- {
- if(PlayerInfo[playerid][Seeds][i] != 0) {
- format(templates, sizeof templates, "{FFFFFF}[{E1E858}Slot: %i{FFFFFF}] {FFFFFF}%i seeds of %s{FFFFFF}.\n", i, PlayerInfo[playerid][Seeds][i], SeedInformation[i][SeedName]);
- strcat(string, templates, sizeof string);
- results++;
- }
- }
- if(results == 0) return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}You do not have any seeds.");
- ShowPlayerDialog(playerid, 100, DIALOG_STYLE_MSGBOX, "{EBC11A}WEED: {FFFFFF}My seeds", string, "Okay", "");
- return 1;
- }
- CMD:mydrugs(playerid, params[])
- {
- new string[1000], templates[128], results = 0;
- for(new i; i < 5; i++)
- {
- if(PlayerInfo[playerid][Weed][i] != 0) {
- format(templates, sizeof templates, "{FFFFFF}[{E1E858}Slot: %i{FFFFFF}] %i grams of %s{FFFFFF}.\n", i, PlayerInfo[playerid][Weed][i], SeedInformation[i][SeedName]);
- strcat(string, templates, sizeof string);
- DrugsList[playerid][results] = i;
- results++;
- }
- }
- if(results == 0) return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}You do not have any drugs.");
- ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "{EBC11A}WEED: {FFFFFF}My drugs", string, "Manage", "Close");
- return 1;
- }
- CMD:plantseed(playerid, params[])
- {
- new slot;
- if(sscanf(params, "i", slot)) return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}/plantseeds [slot (/myseeds for slot]");
- foreach(new i : Weeds)
- {
- if(IsPlayerInRangeOfPoint(playerid, 5, WeedInfo[i][wLocation][0], WeedInfo[i][wLocation][1], WeedInfo[i][wLocation][2]))
- {
- return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}You cannot plant a weed plant so close to another.");
- }
- }
- if(PlayerInfo[playerid][Seeds][slot] != 0)
- {
- new weedID = Iter_Free(Weeds), Float:PPos[3];
- GetPlayerPos(playerid, PPos[0], PPos[1], PPos[2]);
- WeedInfo[weedID][wSeed] = slot;
- WeedInfo[weedID][wProgress] = 0;
- WeedInfo[weedID][wLocation][0] = PPos[0];
- WeedInfo[weedID][wLocation][1] = PPos[1];
- WeedInfo[weedID][wLocation][2] = PPos[2];
- WeedInfo[weedID][wObjectID] = CreateDynamicObject(19473, PPos[0], PPos[1], PPos[2]-2.2100, 0, 0, 0);
- WeedInfo[weedID][oPosition][0] = PPos[0];
- WeedInfo[weedID][oPosition][1] = PPos[1];
- WeedInfo[weedID][oPosition][2] = PPos[2]-2.2100;
- new title[50];
- format(title, sizeof title, "{E1E858}[%s - 0%%]", SeedInformation[slot][SeedName]);
- WeedInfo[weedID][wLabel] = CreateDynamic3DTextLabel(title, -1, PPos[0], PPos[1], PPos[2], 15.0);
- WeedInfo[weedID][x] = repeat WeedProg(weedID, slot);
- PlayerInfo[playerid][Seeds][slot] -= 1;
- Iter_Add(Weeds, weedID);
- ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,0 ,0,0,0,0,1);
- }
- else SendClientMessage(playerid, -1, "* {FF0000}Error: {FFFFFF}You do not have any seeds in that slot.");
- return 1;
- }
- timer WeedProg[1000](weedID, slot)
- {
- new title[50];
- new Float:fPercentage = (float(WeedInfo[weedID][wProgress])/float(SeedInformation[slot][time])) * 100.0;
- new percentage = floatround(fPercentage, floatround_floor);
- if(WeedInfo[weedID][Timer] == SeedInformation[slot][time]) stop WeedInfo[weedID][x];
- new Float:valIncr = (percentage*1.105)/100;
- printf("Weed ID: %i; Progress %i; valIncr %f",weedID, WeedInfo[weedID][wProgress], valIncr);
- if(WeedInfo[weedID][wProgress] < SeedInformation[slot][time])
- {
- WeedInfo[weedID][wProgress]++;
- format(title, sizeof title, "{E1E858}[%s - %i%%]", SeedInformation[slot][SeedName], percentage);
- SetDynamicObjectPos(WeedInfo[weedID][wObjectID], WeedInfo[weedID][oPosition][0], WeedInfo[weedID][oPosition][1], WeedInfo[weedID][oPosition][2]+valIncr);
- UpdateDynamic3DTextLabelText(WeedInfo[weedID][wLabel], -1, title);
- }
- else
- {
- WeedInfo[weedID][wProgress] = SeedInformation[slot][time];
- SetDynamicObjectPos(WeedInfo[weedID][wObjectID], WeedInfo[weedID][oPosition][0], WeedInfo[weedID][oPosition][1], WeedInfo[weedID][oPosition][2]+1.105);
- format(title, sizeof title, "{E1E858}[%s - completed]", SeedInformation[slot][SeedName]);
- UpdateDynamic3DTextLabelText(WeedInfo[weedID][wLabel], -1, title);
- }
- WeedInfo[weedID][Timer]++;
- return 1;
- }
- CMD:collectweed(playerid, params[])
- {
- new result = 0, prog=0, slot;
- foreach(new i : Weeds)
- {
- if(IsPlayerInRangeOfPoint(playerid, 2, WeedInfo[i][wLocation][0], WeedInfo[i][wLocation][1], WeedInfo[i][wLocation][2]))
- {
- result = 1;
- slot = WeedInfo[i][wSeed];
- if(WeedInfo[i][wProgress] == SeedInformation[slot][time])
- {
- PlayerInfo[playerid][Weed][slot] += SeedInformation[slot][GpS];
- new string[128];
- format(string, sizeof string, "* {E1E858}You have collected %s plant and earned %i grams.", SeedInformation[slot][SeedName], SeedInformation[slot][GpS]);
- SendClientMessage(playerid, -1, string);
- WeedInfo[i][wSeed] = -1;
- DestroyDynamic3DTextLabel(WeedInfo[i][wLabel]);
- DestroyDynamicObject(WeedInfo[i][wObjectID]);
- WeedInfo[i][Timer] = 0;
- ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,0 ,0,0,0,0,1);
- Iter_Remove(Weeds, i);
- prog = 1;
- break;
- }
- }
- }
- if(result == 0) return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}You are not in range of any weed plant.");
- if(prog == 0) return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}The plant is not fully grown yet and therefore cannot be collected.");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement