26.01.2016, 23:07
Ok sup guys i've had some problems with this script and now it works nice but there is still a SMALL problem I can't figure out.
Here is how the script works:
1- You use /wheat plant and it creates a dynamic object and then set a timer
heres the script
And then you use /wheat pick and if the timer is at 0, it deletes the object ( it works ) but check this out
When I /wheat plant a second plant then /wheat pick I need to go at the first /wheat plant position ( so the first mariaobject[id] = CreateDynamicObject(806,winfo[id][poswx],winfo[id][poswy],winfo[id][poswz]-1,0.0,0.0,0.0,0); ever created or else it doesnt work...
I want to edit /wheat pick so that every time I use it it deletes completely the first mariaobject
Hope you understand, here is the /wheat pick code
Thanks for ANY help comming in
Here is how the script works:
1- You use /wheat plant and it creates a dynamic object and then set a timer
heres the script
PHP код:
CMD:wheat(playerid, params[])
{
new string[128], wheat, oldj, newj;
if(PlayerInfo[playerid][pJobSkill][JOB_FARMER] < 100) wheat = 5;
else if(PlayerInfo[playerid][pJobSkill][JOB_FARMER] < 300) wheat = 10;
else if(PlayerInfo[playerid][pJobSkill][JOB_FARMER] < 700) wheat = 15;
else if(PlayerInfo[playerid][pJobSkill][JOB_FARMER] < 1200) wheat = 20;
else if(PlayerInfo[playerid][pJobSkill][JOB_FARMER] >= 1200) wheat = 25;
if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
if(PlayerInfo[playerid][pJob] != JOB_FARMER && PlayerInfo[playerid][pVIPJob] != JOB_FARMER) return SendClientMessage(playerid, COLOR_GREY, "You are not a Farmer.");
new usage[10];
if(sscanf(params, "s[10]", usage)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /wheat [plant] or [pick]");
else
{
if(strcmp(usage, "plant", true) == 0)
{
if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, COLOR_GREY, "You must be standing on the ground to use this command.");
if(PlayerInfo[playerid][pSeeds] == 0) return SendClientMessage(playerid, COLOR_GREY, "You must have seeds to plant wheat.");
{
new id = plantcount;
GetPlayerPos(playerid,winfo[id][poswx],winfo[id][poswy],winfo[id][poswz]);
mariaobject[id] = CreateDynamicObject(806,winfo[id][poswx],winfo[id][poswy],winfo[id][poswz]-1,0.0,0.0,0.0,0);
ApplyAnimation(playerid,LIBRARY,ANIMATION,4.1,false,false,false,false,3000,false);
winfo[id][labelweed] = CreateDynamic3DTextLabel("On Harvest",0xFF0000FF,winfo[id][poswx],winfo[id][poswy],winfo[id][poswz],0);
WheatTime[playerid] = 10;
WheatCooldown[playerid] = SetTimerEx("harvesttimer", 6000, true, "i", playerid);
PlayerInfo[playerid][pSeeds] = 0;
SendClientMessage(playerid,COLOR_GREEN,"You have planted your seeds, it will now grow and be ready to /wheat pick in 10 minutes.");
plantcount++;
wlimit++;
}
return 1;
}
When I /wheat plant a second plant then /wheat pick I need to go at the first /wheat plant position ( so the first mariaobject[id] = CreateDynamicObject(806,winfo[id][poswx],winfo[id][poswy],winfo[id][poswz]-1,0.0,0.0,0.0,0); ever created or else it doesnt work...
I want to edit /wheat pick so that every time I use it it deletes completely the first mariaobject
Hope you understand, here is the /wheat pick code
PHP код:
if(strcmp(usage, "pick", true) == 0)
{
{
for(new i = 0; i < MAX_WEED; i++)
{
if(IsPlayerInRangeOfPoint(playerid,2.5,winfo[i][poswx],winfo[i][poswy],winfo[i][poswz]-1))
{
if(WheatTime[playerid] > 0)
{
format(string, sizeof(string), "You need to wait %d more seconds before harvesting your wheat plantations.", WheatTime[playerid]);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
if(WheatTime[playerid] == 0)
{
if(IsPlayerInVehicle(playerid,GetPlayerVehicleID(playerid))) return SendClientMessage(playerid,-1,"You have to be standing on the ground to harvest your wheat.");
ApplyAnimation(playerid,LIBRARY,ANIMATION,4.1,false,false,false,false,3000,false);
DestroyDynamicObject(mariaobject[i]);
DestroyDynamic3DTextLabel(winfo[i][labelweed]);
wlimit--;
WheatTime[playerid] --;
format(string, sizeof(string), "* You have harvested {FF6347}%d wheat{33CCFF} on your plantations.", wheat*5);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
PlayerInfo[playerid][pWheat] += wheat*5;
oldj = strval(RPJL(playerid,JOB_FARMER));
PlayerInfo[playerid][pJobSkill][JOB_FARMER] ++;
newj = strval(RPJL(playerid,JOB_FARMER));
if(oldj < newj)
{
format(string, sizeof(string), "** Your Farmer level is now %d, you can now harvest %d more pounds of wheat. **", newj, newj*5);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
return 1;
}
}
}
}
return 1;
}
}