17.11.2015, 15:52
Hi, is it possible to make that if the weed time goes over 70 minutes, it will destroy the weed plant? 

pawn Код:
public Plantation()
{
for(new b = 0; b < sizeof(WeedInfo); b++)
{
if(WeedInfo[b][WeedTime] > 0 && WeedInfo[b][WeedPlanted] == 1)
{
WeedInfo[b][WeedTime] -= 1;
}
}
return 1;
}
pawn Код:
if(strcmp(cmd, "/plantweed", true) == 0 || strcmp(cmd, "/plantseed", true) == 0)
{
for(new weed = 0; weed < sizeof(WeedInfo); weed++)
{
if(WeedInfo[weed][WeedPlanted] == 0 && WeedInfo[weed][WeedTime] == 0)
{
if (PlayerInfo[playerid][pJob] != 6) return SendClientMessage(playerid, COLOR_GREY, " You are not a Drugs Dealer !");
if (!PlayerInfo[playerid][pWSeeds]) return SendClientMessage(playerid, COLOR_GREY," You don't have any Seeds with you.");
if (GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, COLOR_GREY, "You must be on foot to plant your seeds.");
if (GetPlayerInterior(playerid) != 0) return SendClientMessage(playerid, COLOR_GREY, "You must be outside to plant your seeds.");
if(PlayerInfo[playerid][pWeedTime] > 0 && PlayerInfo[playerid][pDonatorLevel] != 3)
{
format(string,sizeof(string),"Please wait %d minutes before planting weed again.", SecondsToMinutes(PlayerInfo[playerid][pWeedTime]));
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}
if(PlayerInfo[playerid][pWeedTime] > 60 && PlayerInfo[playerid][pDonatorLevel] != 3) // check if it's above 1 minute.
{
format(string, sizeof(string), "Please wait %d minutes before planting weed again.", SecondsToMinutes(PlayerInfo[playerid][pWeedTime]));
SendClientMessage(playerid, COLOR_GREY, string);
}
else if(PlayerInfo[playerid][pWeedTime] < 60 && PlayerInfo[playerid][pWeedTime] > 0) // checks if it's below 1 minute but above 0 seconds.
{
format(string, sizeof(string), "Please wait %d seconds before planting weed again.", PlayerInfo[playerid][pWeedTime]);
SendClientMessage(playerid, COLOR_GREY, string);
}
else // it can only be 0.
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerName(playerid, playername, 24);
ApplyAnimation(playerid, "BOMBER","BOM_Plant_In",4.0,0,0,0,0,0);
//weedObject[weed] = CreateObject(3409, X, Y, Z-2, 0, 0, 0, 50000.0);
weedObject[weed] = CreateObject(3409, X, Y, Z-1.6, 0, 0, 0, 50000.0);
PlayerInfo[playerid][pWeedTime] = 1200;
WeedInfo[weed][WeedX] = X;
WeedInfo[weed][WeedY] = Y;
WeedInfo[weed][WeedZ] = Z;
WeedInfo[weed][WeedTime] = 45;
WeedInfo[weed][WeedPlanted] = 1;
strmid(WeedInfo[weed][WeedPlanter], playername, 0, strlen(playername), 50);
format(string, sizeof(string), "* %s plants some seeds.", RemoveUnderScore(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SendClientMessage(playerid,COLOR_GREEN,"You have planted your seeds, it will take about 45 minutes, for your crops to grow fully mature.");
//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,"Remember to /harvest, before someone else takes your weed.");
PlayerInfo[playerid][pWSeeds]--;
return 1;
}
}
}
}
pawn Код:
if(strcmp(cmd, "/harvest", true) == 0 || strcmp(cmd, "/pickweed", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new count = 0;
if(GetPlayerState(playerid) != 1) return SendClientMessage(playerid, COLOR_GREY, "You must be on foot to harvest a weed plant.");
for(new i = 0; i < sizeof(WeedInfo); i++)
{
if (PlayerToPoint(3.0,playerid,WeedInfo[i][WeedX],WeedInfo[i][WeedY],WeedInfo[i][WeedZ]))
{
if(WeedInfo[i][WeedTime] > 0)
{
format(string, sizeof(string), "This plant is not ready yet. %d Minutes Remaining.", WeedInfo[i][WeedTime]);
SendClientMessage(playerid,COLOR_GREEN,string);
return 1;
}
format(string, sizeof(string), "* %s begins picking a weed plant.", RemoveUnderScore(playerid));
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);
return 1;
}
}
if(count == 0) SendClientMessage(playerid, COLOR_GREY, " You are not near any plants !");
}
return 1;
}
pawn Код:
forward WeedPickup(playerid);
public WeedPickup(playerid)
{
for(new i = 0; i < sizeof(WeedInfo); i++)
{
if (PlayerToPoint(3.0,playerid,WeedInfo[i][WeedX],WeedInfo[i][WeedY],WeedInfo[i][WeedZ]))
{
new string[256];
new Float: X, Float: Y, Float: Z;
GetPlayerPos(playerid, X, Y, Z);
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.");
if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
{
SendClientMessage(playerid, COLOR_GREY, " You must be crouched to pick weed.");
WeedIsPicked[playerid] = 0;
return 1;
}
new randgrams = 40 + random(30);
if(IsPlayerInAnyVehicle(playerid)){ SendClientMessage(playerid, COLOR_GRAD1, "You must be on foot to harvest a weed plant.");return 1;}
format(string, sizeof(string), "%s begins picking a weed plant..", RemoveUnderScore(playerid));
ProxDetector(25.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
format(string, sizeof(string), "You have harvested a weed plant, and received %d grams of pot.", randgrams);
SendClientMessage(playerid, COLOR_GREEN, string);
PlayerInfo[playerid][pPot] += randgrams;
DestroyObject(weedObject[i]);
WeedInfo[i][WeedX] = 0.0;
WeedInfo[i][WeedY] = 0.0;
WeedInfo[i][WeedZ] = 0.0;
WeedInfo[i][WeedPlanted] = 0;
strmid(WeedInfo[i][WeedPlanter], "[NONE]", 0, strlen("[NONE]"), 128);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREEN, " You have moved from your weed picking position, picking failed!");
}
WeedIsPicked[playerid] = 0;
}
}
return 0;
}

