how to repeat a timer 15times -
MWhite_005 - 15.07.2011
i was wonder how to only make my settimer repeat a function only 15times..
here is the function :
-------------------------------------
forward Regernation(playerid);
public Regernation(playerid)
{
new Float:Health;
if (Health > 100)
SetPlayerHealth(playerid, 100.0);
else
GetPlayerHealth(playerid, Health);
SetPlayerHealth(playerid, Health + 2.0);
return 1;
}
------------------------------------
and the Timer is :
SetTimer("Regernation",2000,true);
Re: how to repeat a timer 15times -
Tigerkiller - 15.07.2011
PHP код:
new Count
if(count <15)
{
SetTimer("Regeneration",yourtimer,false);
count++;
}
Re: how to repeat a timer 15times -
MWhite_005 - 15.07.2011
ty but i think i put it in wrong
dcmd_td(playerid, params[])
{
#pragma unused params
new count;
if(count <15)
{
SetTimer("Regeneration",2000,false);
count++;
SendClientMessage(playerid, 0x00FF00AA, "You Are On Drugs.");
}
return 1;
Re: how to repeat a timer 15times -
Seven_of_Nine - 15.07.2011
That's incorrect.
pawn Код:
//global vars:
new count, drugtimer;
//command
drugtimer = SetTimer("Regeneration",2000,false);
And now the regeneration part:
pawn Код:
public Regeneration() {
if(count == 15) return KillTimer(drugtimer);
//whatever is in here
count++;
return 1;
}
Re: how to repeat a timer 15times -
Roko_foko - 15.07.2011
That's all right, I would suggest you also to add before SetTimer you a line "Counter=0;". If you don't that function(wich includes all 15 times) will be called ONLY once.
Also, I think, I might be wrong, that you are using SetTimer, but should SetTimerEx(this one is for specific player who teyped the command )
Re: how to repeat a timer 15times -
Jefff - 15.07.2011
In command
pawn Код:
Regernation(playerid,15);
pawn Код:
forward Regernation(playerid,times);
public Regernation(playerid,times)
{
if(times)
{
new Float:Health;
GetPlayerHealth(playerid, Health);
if(Health > 100) SetPlayerHealth(playerid, 100.0);
else SetPlayerHealth(playerid, Health + 2.0);
SetTimerEx("Regernation",2000,false,"dd",playerid,times-1);
}
return 1;
}
AW: Re: how to repeat a timer 15times -
Nero_3D - 15.07.2011
And some little corrections to Jefff's code
Also I think that the regeneration should stop at full health
pawn Код:
forward Regeneration(playerid, times);
public Regeneration(playerid, times)
{
if(0 < times)
{
new Float: Health;
if(GetPlayerHealth(playerid, Health))
{
if(100.0 < (Health += 2.0)) SetPlayerHealth(playerid, 100.0);
else
{
SetPlayerHealth(playerid, Health);
SetTimerEx("Regeneration", 2000, false, "dd", playerid, times - 1);
}
return true;
}
}
return false;
}
Re: how to repeat a timer 15times -
MWhite_005 - 15.07.2011
ty soo much guys i understand the scripts but my command is still getting errors

sigh
here is the command:
--------------------------------------------
dcmd_td(playerid, params[])
{
#pragma unused params
new Regernation;
if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount()) return SendClientMessage(playerid,0xFF0000AA,"Temporary System!You Can Only Use This Command Once Per Spawn");
SetPVarInt(playerid,"CMDABUSE",GetTickCount()+1000 00000);
Regernation(playerid,15); //Error line(9977)
SendClientMessage(playerid, 0x00FF00AA, "You Are On Drugs.");
return 1;
}
here is the function:
----------------------------------------------------------
forward Regeneration(playerid, times);
public Regeneration(playerid, times)
{
if(0 < times)
{
new Float: Health;
if(GetPlayerHealth(playerid, Health))
{
if(100.0 < (Health += 2.0)) SetPlayerHealth(playerid, 100.0);
else
{
SetPlayerHealth(playerid, Health);
SetTimerEx("Regeneration", 2000, false, "dd", playerid, times - 1);
}
return true;
}
}
return false;
}
----------------------------------------------------------------------------
And the errors :
(9977) : error 012: invalid function call, not a valid address
(9977) : warning 215: expression has no effect
(9977) : warning 215: expression has no effect
(9977) : error 001: expected token: ";", but found ")"
(9977) : error 029: invalid expression, assumed zero
(9977) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Re: how to repeat a timer 15times -
MWhite_005 - 15.07.2011
i know my function call isnt right
Regernation(playerid,15); //Error line(9977)
Re: how to repeat a timer 15times -
Adil - 15.07.2011
remove
new regernation; And change the error line to:
pawn Код:
Regeneration(playerid, 15);