24.06.2012, 15:01
pawn Код:
// simply declare a global variable
new HasToWait[MAX_PLAYERS];
/*
- if HasToWait = 0 (Default) then a player/zombie can bite.
- if HasToWait = 1 then a player/zombie can not bite.
*/
new NearestPlayer = GetClosestPlayer(playerid);
if(newkeys & KEY_WALK)
{
if(Player[playerid][Zombie] == 1)
{
if(HasToWait[playerid] != 1)
{
if(GetDistanceBetweenPlayers(NearestPlayer, playerid) < 4)
{
if(Player[NearestPlayer][Infected] == 0)
{
Player[NearestPlayer][Infected] = 1;
HasToWait[playerid] = 1; // I'm not sure if this's the right place. If this is the part which the zombie bites someone then it's ok
SetTimerEx("ResetZombieStatus", 30000, false, "d", playerid);
}
else if(Player[NearestPlayer][Infected] == 1)
{
Player[NearestPlayer][Zombie] = 1;
Player[NearestPlayer][Human] = 0;
Player[NearestPlayer][Infected] = 0;
}
}
}
else
{
GameTextForPlayer(playerid, "~r~You have to wait before another bite!", 3000, 3);
}
}
else
{
GameTextForPlayer(playerid, "~w~There is no one nearby!", 3500, 3);
}
}
forward ResetZombieStatus(playerid);
public ResetZombieStatus(playerid)
{
HasToWait[playerid] = 0; // resetting it 0 so he can bite again
return 1;
}