Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=================================================================
- // Forwards
- forward WeedTimer();
- //Global Variables
- new Weed[MAX_PLAYERS];
- new Float: Weed_x[MAX_PLAYERS], Float: Weed_y[MAX_PLAYERS], Float: Weed_z[MAX_PLAYERS];
- new HasPlantWeed[MAX_PLAYERS];
- new WeedGrams[MAX_PLAYERS];
- new WeedForPlayer[MAX_PLAYERS];
- new WeedTime[MAX_PLAYERS];
- new WeedMin[MAX_PLAYERS];
- new WeedIsPicked[MAX_PLAYERS];
- new Float:WeedStopPos[MAX_PLAYERS][3];
- // OnGameModeInit
- SetTimer("WeedTimer", 1000, 1);
- //Custom Function
- public WeedTimer()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(HasPlantWeed[i] != 0)
- {
- WeedTime[i] ++;
- if(WeedTime[i] == 60)
- {
- WeedGrams[i] ++;
- WeedTime[i] = 0;
- WeedMin[i] ++;
- }
- if(WeedMin[i] == 70)
- {
- DestroyObject(Weed[i]);
- HasPlantWeed[i] = 0;
- WeedGrams[i] = 0;
- WeedTime[i] = 0;
- }
- }
- }
- return 1;
- }
- // at the pinfo enum:
- pSeeds
- // at OnPlayerConnectFunction
- WeedIsPicked[playerid] = 0;
- WeedTime[playerid] = 0;
- WeedMin[playerid] = 0;
- WeedTime[playerid] = 0;
- WeedGrams[playerid] = 0;
- WeedForPlayer[playerid] = 999;
- WeedIsPicked[playerid] = 0;
- HasPlantWeed[playerid] = 0;
- PlayerInfo[playerid][pSeeds] = 0;
- // OnPlayerDisconnect
- if(HasPlantWeed[playerid] != 0) DestroyObject(Weed[playerid]);
- // Make it savable (OnPlayerRegister, OnPlayerLogin and your custom save function SavePlayer or whatever you use)
- // Also change the /getcrate /getpot (to /getseeds) and the other cmds in order to replace pot with seeds
- // The commands
- if(strcmp(cmd,"/plantweed",true)==0)
- {
- if(IsPlayerConnected(playerid))
- {
- if (PlayerInfo[playerid][pJob] != 4)
- {
- SendClientMessage(playerid,COLOR_GREY, "You are not a Drug Dealer !");
- return 1;
- }
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- if(GetPlayerState(playerid) != 1) return SendClientMessage(playerid, COLOR_GREY, " You must be on foot !");
- if(GetPlayerInterior(playerid) > 0) return SendClientMessage(playerid, COLOR_GREY, " You must be outside to plant your seeds.");
- if(PlayerInfo[playerid][pSeeds] == 0) return SendClientMessage(playerid, COLOR_GREY, " You don't have any Seeds!");
- if(PlayerInfo[playerid][pSeeds] < 10) return SendClientMessage(playerid, COLOR_GREY, " You don't have enough Seeds!");
- if(HasPlantWeed[playerid] == 1) return SendClientMessage(playerid, COLOR_GRAD2, "* You have already planted a weed !");
- new Float:X, Float:Y, Float:Z;
- ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
- GetPlayerPos(playerid, X, Y, Z);
- Weed_x[playerid] = X;
- Weed_y[playerid] = Y;
- Weed_z[playerid] = Z;
- Weed[playerid] = CreateObject(3409, X, Y, Z-1.8, 0, 0, 0);
- HasPlantWeed[playerid] = 1;
- PlayerInfo[playerid][pSeeds] -= 10;
- format(string, sizeof(string), "* %s plants some seeds.", name);
- ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
- SendClientMessage(playerid, COLOR_GREEN, "You have planted your seeds! Every minute, your plant will make one gram of weed.");
- SendClientMessage(playerid, COLOR_GREEN, "If your plant won't picked within 70 minutes, it will rot and you will lose it.");
- SendClientMessage(playerid, COLOR_GREEN, "Also remember that anyone can /pickweed if they find your plant, so be careful.");
- }
- return 1;
- }
- //==============================================================================
- if(strcmp(cmd,"/checkweed",true)==0)
- {
- if(IsPlayerConnected(playerid))
- {
- new count = 0;
- if(GetPlayerState(playerid) != 1) return SendClientMessage(playerid, COLOR_GREY, " You must be on foot !");
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 3.0, Weed_x[i], Weed_y[i], Weed_z[i]))
- {
- WeedForPlayer[playerid] = i;
- ApplyAnimation(playerid, "BOMBER", "BOM_Plant_2Idle", 4.0, 0, 0, 0, 0, 0);
- format(string, sizeof(string), "* %s inspects the weed plant.", name);
- ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
- format(string, sizeof(string), "This plant has %d weed grams.", WeedGrams[i]);
- SendClientMessage(playerid, COLOR_GREEN, string);
- WeedForPlayer[playerid] = 999;
- count ++;
- return 1;
- }
- }
- if(count == 0) SendClientMessage(playerid, COLOR_GREY, " You are not near any plants !");
- }
- return 1;
- }
- //==============================================================================
- if(strcmp(cmd,"/pickweed",true)==0)
- {
- if(IsPlayerConnected(playerid))
- {
- new count = 0;
- new Error = 0;
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- if(GetPlayerState(playerid) != 1) return SendClientMessage(playerid, COLOR_GREY, " You must be on foot !");
- if(WeedIsPicked[playerid] > 0) return SendClientMessage(playerid, COLOR_GREY, " You have already started to picking a weed !");
- if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) return SendClientMessage(playerid, COLOR_GREY, " You must be crouched to pick weed.");
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 3.0, Weed_x[i], Weed_y[i], Weed_z[i]))
- {
- WeedForPlayer[playerid] = i;
- if(WeedGrams[i] < 1) { SendClientMessage(playerid, COLOR_GREY, " This plant is not ready to be picked, please wait at least 2 minutes for it to grow."); Error = 1; }
- if(Error == 0)
- {
- format(string, sizeof(string), "* %s begins picking a weed plant.", name);
- ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
- GetPlayerPos(playerid, WeedStopPos[playerid][0], WeedStopPos[playerid][1], WeedStopPos[playerid][2]);
- WeedIsPicked[playerid] = 1;
- SetTimerEx("WeedPickup", 5000, false, "i", playerid);
- }
- count ++;
- return 1;
- }
- }
- if(count == 0) SendClientMessage(playerid, COLOR_GREY, " You are not near any plants !");
- }
- return 1;
- }
- // Custom Function
- forward WeedPickup(playerid);
- public WeedPickup(playerid)
- {
- new string[256];
- new Float: X, Float: Y, Float: Z;
- GetPlayerPos(playerid, X, Y, Z);
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- if(X == WeedStopPos[playerid][0] && Y == WeedStopPos[playerid][1] && Z == WeedStopPos[playerid][2])
- {
- if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) return SendClientMessage(playerid, COLOR_GREY, " You must be crouched to pick weed.");
- format(string, sizeof(string), "* %s picks a weed plant.", name);
- ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
- PlayerInfo[playerid][pPot] += WeedGrams[WeedForPlayer[playerid]];
- format(string, sizeof(string), "~w~FOUND %d GRAMS OF POT", WeedGrams[WeedForPlayer[playerid]]);
- GameTextForPlayer(playerid, string, 3000, 3);
- DestroyObject(Weed[WeedForPlayer[playerid]]);
- WeedGrams[WeedForPlayer[playerid]] = 0;
- WeedTime[WeedForPlayer[playerid]] = 0;
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREEN, " You have moved from your weed picking position, picking failed!");
- }
- HasPlantWeed[WeedForPlayer[playerid]] = 0;
- WeedForPlayer[playerid] = 999;
- WeedIsPicked[playerid] = 0;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement