SA-MP Forums Archive
kill 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: kill bug (/showthread.php?tid=217143)



kill bug - Amine_Mejrhirrou - 27.01.2011

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


Re : kill bug - Amine_Mejrhirrou - 27.01.2011

com on some one help


Re: kill bug - iMonk3y - 27.01.2011

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)



Re : kill bug - Amine_Mejrhirrou - 27.01.2011

the public OnPlayerDeath works perfectly the problem is in OnPlayerKeyStateChange


Re : kill bug - Amine_Mejrhirrou - 27.01.2011

so any 1


Re: kill bug - bboytimix - 03.02.2011

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!");
}


Re: Re : kill bug - Steven Paul - 03.02.2011

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


Re: kill bug - bboytimix - 04.02.2011

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!");
}




Re: kill bug - bboytimix - 04.02.2011

i want the bite this is dont work


Re: Re : kill bug - Mean - 04.02.2011

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