kill bug
#1

hi all ! i have a problem
in my GM zombie team & human team !! & some times when a zombie atack a human (unarmed) & kill the human ! they say "player" die
i know wher the bug come from but i have no idea about how to fix it
this is public OnPlayerDeath(playerid, killerid, reason)
Код:
  
        S_OnPlayerDeath(killerid);
	new killer[MAX_PLAYERS], player[MAX_PLAYERS],string[100];
	GetPlayerName(playerid, player,sizeof(player));
	GetPlayerName(killerid, killer,sizeof(killer));
	if((killerid == INVALID_PLAYER_ID) || (killerid == playerid))
	{
		format(string,sizeof(string), "%s die !.", player);
		SendClientMessageToAll(RED,string);
	}
	else if(infected[playerid] > 0 || team[killerid] == 2)
	{
	        new score = GetPlayerScore(killerid);
		GetPlayerName(playerid, player,sizeof(player));
		GetPlayerName(killerid, killer,sizeof(killer));
		format(string,sizeof(string), "%s has been turned into a zombie by %s(zombie)", player, killer);
		SendClientMessageToAll(RED,string);
		team[playerid] = 2;
		SetPlayerScore(killerid, score+1);
	}
& this is public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) tha bug

Код:
   
        if((newkeys & KEY_FIRE) && (team[playerid] == 2))
	{
	    new Float:hp, Float:a;
	    new target = GetClosestPlayer(playerid);
        if(target == INVALID_PLAYER_ID || target == playerid) return 1;
        if(team[target] == 2) return 1;
	    GetPlayerArmour(target,a);
        target = GetClosestPlayer(playerid);
		if(target == INVALID_PLAYER_ID || target == playerid) return SendClientMessage(playerid, YELLOW, "no human is near you!");
		if(GetDistanceBetweenPlayers(playerid,target) <= 2)
		{
			if(a > 0)
			{
			    SetPlayerArmour(target, a-5);
			}
			else
    		       {
    			GetPlayerHealth(target,hp);
			SetPlayerHealth(target, hp-7);
     		}
		}
		else SendClientMessage(playerid, YELLOW, "Nobody is near you!");
    }
so tha bug is that whn a zombie atack tha human ! the human heth go dawn -7hp per atack & when he's heath set to 0 he just die but not buy the zombie = just caus he loos all he's heath !
can some one heap pls
Reply
#2

com on some one help
Reply
#3

This absolutely has no effect

pawn Код:
(killerid == playerid)
I suppose you have to replace (5th) line to this one:

pawn Код:
if(killerid != INVALID_PLAYER_ID)
Reply
#4

the public OnPlayerDeath works perfectly the problem is in OnPlayerKeyStateChange
Reply
#5

so any 1
Reply
#6

amine

team 2 = team zombie ?

if((newkeys & KEY_FIRE) && (team[playerid] == 2))
{
new Float:hp, Float:a;
new target = GetClosestPlayer(playerid);
if(target == INVALID_PLAYER_ID || target == playerid) return 1;
if(team[target] == 2) return 1;
GetPlayerArmour(target,a);
target = GetClosestPlayer(playerid);
if(target == INVALID_PLAYER_ID || target == playerid) return SendClientMessage(playerid, YELLOW, "no human is near you!");
if(GetDistanceBetweenPlayers(playerid,target) <= 2)
{
if(a > 0)
{
SetPlayerArmour(target, a-5);
}
else
{
GetPlayerHealth(target,hp);
SetPlayerHealth(target, hp-7);
}
}
else SendClientMessage(playerid, YELLOW, "Nobody is near you!");
}
Reply
#7

Quote:
Originally Posted by Amine_Mejrhirrou
Посмотреть сообщение
the public OnPlayerDeath works perfectly the problem is in OnPlayerKeyStateChange
so why did you give it
Reply
#8

Quote:

if((newkeys & KEY_FIRE) && (team[playerid] == 2))
{
new Float:hp, Float:a;
new target = GetClosestPlayer(playerid);
if(target == INVALID_PLAYER_ID || target == playerid) return 1;
if(team[target] == 2) return 1;
GetPlayerArmour(target,a);
target = GetClosestPlayer(playerid);
if(target == INVALID_PLAYER_ID || target == playerid) return SendClientMessage(playerid, YELLOW, "no human is near you!");
if(GetDistanceBetweenPlayers(playerid,target) <= 2)
{
if(a > 0)
{
SetPlayerArmour(target, a-5);
}
else
{
GetPlayerHealth(target,hp);
SetPlayerHealth(target, hp-7);
}
}
else SendClientMessage(playerid, YELLOW, "Nobody is near you!");
}

this is dont work

my team is :

team 1= zombie
team 0 = survivor

this is what i did what the problem ??

Quote:

if((newkeys & KEY_FIRE) && (team[playerid] == 0))
{
new Float:hp, Float:a;
new target = GetClosestPlayer(playerid);
if(target == INVALID_PLAYER_ID || target == playerid) return 1;
if(team[target] == 2) return 1;
GetPlayerArmour(target,a);
target = GetClosestPlayer(playerid);
if(target == INVALID_PLAYER_ID || target == playerid) return SendClientMessage(playerid, COLOR_RED, "no human is near you!");
if(GetDistanceBetweenPlayers(playerid,target) <= 2)
{
if(a > 0)
{
SetPlayerArmour(target, a-5);
}
else
{
GetPlayerHealth(target,hp);
SetPlayerHealth(target, hp-7);
}
}
else SendClientMessage(playerid, COLOR_RED, "Nobody is near you!");
}

Reply
#9

i want the bite this is dont work
Reply
#10

Quote:
Originally Posted by Steven Paul
Посмотреть сообщение
so why did you give it
Off-topic: How come you are banned, and you are online ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)