timer bug
#1

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
Reply
#2

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

no still bug !! can some one help plssssssss
Reply
#4

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.
Reply
#5

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

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;
}

Reply
#7

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.
Reply
#8

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
Reply
#9

KillTimer();
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)