SA-MP Forums Archive
timer bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: timer bug (/showthread.php?tid=211274)



timer bug - Amine_Mejrhirrou - 14.01.2011

i have a timer bug guys pls hlp me to fix it
Код:
new infect_timer[MAX_PLAYERS];
  
if((newkeys & KEY_FIRE) && (team[playerid] == 6))
	{
	    new Float:hp, Float:a;
      	new target = GetClosestPlayer(playerid);
      	if(GetDistanceBetweenPlayers(playerid,target) <= 1)
		{
		    infect_timer[playerid] = SetTimerEx("infectedtimer", 5000, true, "d", target);
		    SetPlayerDrunkLevel (target, 10000);
		    ApplyAnimation(target,"ped","KO_shot_face",1.1,0,1,1,0,0);
		    GameTextForPlayer(target,"~r~ Tyrant Hit you !!",3000,1);
		}
    	return 1;
	}

public OnPlayerPickUpPickup(playerid, pickupid)
    if(pickupid == anti)
	{
		new Float:health;
    	GetPlayerHealth(playerid,health);
    	KillTimer(infect_timer[playerid]);
    	if (health < 100)
    	{
    	    SetPlayerTeam(playerid, 2);
    	    SetPlayerDrunkLevel (playerid, 0);
        	SetPlayerHealth(playerid, 100.0);
        	GameTextForPlayer(playerid, "~w~you inject the antidote", 3000, 4);
    	}
    	return 1;
	}

forward infectedtimer(playerid);
public infectedtimer(playerid)
{
    new Float:hp;
    GetPlayerHealth(playerid,hp);
   	SetPlayerHealth(playerid, hp-5);
    if(IsPlayerInRangeOfPoint(playerd, 2, 358.2446,206.3789,1008.3828))
            {
				KillTimer(infect_timer[playerid]);
            }
    return 1;
}
BUG : 1 some players spawn infected!!
2 whene a zombie atack you !! the infection never stop even if you take the anti pls hlp
thanks for that


Re: timer bug - Franck_ - 14.01.2011

Try this when someone infects somebody else:
pawn Код:
infect_timer[target] = SetTimerEx("infectedtimer", 5000, true, "d", target);



Re : timer bug - Amine_Mejrhirrou - 15.01.2011

no still bug !! can some one help plssssssss


Re: timer bug - Kapil - 15.01.2011

well you arent checking if you are injecting a person, who is already injected, i.e creating a timer for a person who already has a timer. You will have to kill the time if it exist first, and then create a timer for him.
like i have done in this..
http://notesbin.com/1195081941

this should be the solution for your problems, but also makesure you are killing the timer onplayerdisconnect.


Re : timer bug - Amine_Mejrhirrou - 15.01.2011

ok Kapil thanks for your help gonna try it now & tell you if it works
thanks again


Re : timer bug - Amine_Mejrhirrou - 15.01.2011

OMG part of tha bug is fixed !! (now only the infected player loos heath ) but killtimer don't work !!
when a plyaer take an anti-virus the player still infected pls help
ohh & when i leave tha game & respawn i still infected
Quote:
new infect_timer[MAX_PLAYERS];
public OnPlayerDisconnect(playerid, reason)
{
S_OnPlayerDisconnect(playerid);
KillTimer(infect_timer[playerid]);
}
if ((newkeys & KEY_FIRE) && (team[playerid] == 6))
{
new Float: hp,
Float: a;
new target = GetClosestPlayer(playerid);
if (GetDistanceBetweenPlayers(playerid, target) <= 1)
{
KillTimer(infect_timer[playerid]); // this one
infect_timer[playerid] = SetTimerEx("infectedtimer", 5000, true, "d", target);
SetPlayerDrunkLevel(target, 10000);
ApplyAnimation(target, "ped", "KO_shot_face", 1.1, 0, 1, 1, 0, 0);
GameTextForPlayer(target, "~r~ Tyrant Hit you !!", 3000, 1);
}
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
if (pickupid == anti)
{
new Float: health;
GetPlayerHealth(playerid, health);
KillTimer(infect_timer[playerid]);
if (health < 100)
{
SetPlayerDrunkLevel(playerid, 0);
SetPlayerHealth(playerid, 100.0);
GameTextForPlayer(playerid, "~w~you inject the antidote", 3000, 4);
}
return 1;
}

forward infectedtimer(playerid);
public infectedtimer(playerid)
{
new Float: hp;
GetPlayerHealth(playerid, hp);
SetPlayerHealth(playerid, hp - 5);
if (IsPlayerInRangeOfPoint(playerd, 2, 358.2446, 206.3789, 1008.382)
{
KillTimer(infect_timer[playerid]);
}
return 1;
}




Re: timer bug - DeadAhead - 15.01.2011

well. You can use Add Statements in your public infectedtimer(playerid) e.g.:

Код:
if (PlayerHasPills(playerid)) return 1;
or something like OnPlayerSpawn:

Код:
healthy[playerid] = 1;
These codes are examples and wont work. But i hope you understand what im trying to tell you.


Re : timer bug - Amine_Mejrhirrou - 15.01.2011

ahh i didn't understand what you say & that's not the solution to fix tha bug! i'm juste asking for a way to make the killtimer works that's all


Re: timer bug - [UG]Scripter - 15.01.2011

KillTimer();


Re : Re: timer bug - Amine_Mejrhirrou - 15.01.2011

Quote:
Originally Posted by [UG]Scripter
Посмотреть сообщение
KillTimer();
... that's tha problem ... KillTimer() wont work ...