22.04.2014, 17:57
Hay, i have doing this script for a weed system but i have a problem with a timer and don't know the solution:
this is a timer function:
The problem occurred when i send a command /plantseed... for each command the timer have to restart, but it applies to only once, so when i send the command and when i resend the command after 10 seconds, when the first timer finish the second finish together with the first. what i wrong ??
pawn Код:
CMD:plantseed(playerid,params[])
{
if(pinfo[playerid][seeds] < 5) return SendClientMessage(playerid,-1,"[SERVER] You haven't enought seeds");
if(IsPlayerInVehicle(playerid,GetPlayerVehicleID(playerid))) return SendClientMessage(playerid,-1,"[SERVER] You can't do it in a vehicle");
if(limite == MAX_WEED_PER_PLAYER) return SendClientMessage(playerid,-1,"[SERVER] You can't plant more of 3 seeds");
new id = plantcount;
GetPlayerPos(playerid,winfo[id][poswx],winfo[id][poswy],winfo[id][poswz]);
mariaobject[id] = CreateDynamicObject(3409,winfo[id][poswx],winfo[id][poswy],winfo[id][poswz]-1,0.0,0.0,0.0,-1,-1,-1,100.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],100.0);
pinfo[playerid][seeds] = pinfo[playerid][seeds] - 5;
plantcount++;
limit++;
SetTimer("harvesttimer",30000,false);
return 1;
}
pawn Код:
forward harvesttimer();
public harvesttimer()
{
for(new i = 0; i < MAX_WEED; i++)
{
winfo[i][finita] = 1;
UpdateDynamic3DTextLabelText(winfo[i][labelweed],0xFF0000FF,"Harvest");
}
return 1;
}