SA-MP Forums Archive
onplayerdeath 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)
+--- Thread: onplayerdeath bug (/showthread.php?tid=606425)



onplayerdeath bug - TheSimpleGuy - 04.05.2016

hello, if I kill my enemy, the enemy's HP will go blink and on my screen, I can see the enemy dead but on enemy's POV, he's still alive. The enemy can shoot me, and kill me too. however, he will be invisible, and I can see his bullets going after me. the enemy can only be killed by killing himself (/kill doesnt work) by jumping off a cliff or damaging himself. I have added ClearAnimations(playerid); on OnPlayerDeath.

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	new string[128];
	SendDeathMessage(killerid, playerid, reason);
	ClearAnimations(playerid);
	if(killerid != INVALID_PLAYER_ID)
	{
		switch(random(2))
		{
		    case 0: format(string, sizeof(string), "You have eliminated %s (%d).", GetName(playerid), playerid);
		    case 1: format(string, sizeof(string), "You have killed %s (%d).", GetName(playerid), playerid);
		    case 2: format(string, sizeof(string), "%s (%d) has been finished off.", GetName(playerid), playerid);
		}
		SendClientMessage(killerid, -1, ""COL_GRAY"You have also received +$50 and +1 score.");
		GivePlayerMoney(killerid, 50);
		GivePlayerScore(killerid, 1);
		GameTextForPlayerEx(killerid, string, 2500);
		switch(random(2))
		{
		    case 0: format(string, sizeof(string), "You have been eliminated by %s (%d).", GetName(killerid), killerid);
		    case 1: format(string, sizeof(string), "You have been killed by %s (%d).", GetName(killerid), killerid);
		    case 2: format(string, sizeof(string), "You have been finished off by %s (%d).", GetName(killerid), killerid);
		}
		GameTextForPlayerEx(playerid, string, 2500);
		if(pInfo[playerid][Streak] >= 3)
		{
			switch(random(2))
			{
			    case 0: format(string, sizeof(string), ""COL_SERVER"%s (%d)"COL_WHITE" has broken "COL_SERVER"%s (%d)"COL_WHITE"'s killstreak of %d!", GetName(killerid), killerid, GetName(playerid), playerid, pInfo[playerid][Streak]);
				case 1: format(string, sizeof(string), ""COL_SERVER"%s (%d)"COL_WHITE" breaks the killstreak of "COL_SERVER"%s (%d)"COL_WHITE" of %d!", GetName(killerid),killerid,GetName(playerid),playerid, pInfo[playerid][Streak]);
				case 2: format(string, sizeof(string), ""COL_SERVER"%s (%d)"COL_WHITE" has crushed "COL_SERVER"%s (%d)"COL_WHITE"'s killstreak of %d!", GetName(killerid),killerid,GetName(playerid),playerid,pInfo[playerid][Streak]);
			}
			SendClientMessageToAll(-1, string);
			pInfo[playerid][Streak] = 0;
		}
		pInfo[killerid][Streak]++;
		if(pInfo[killerid][Streak] % 3 == 0)
		{
		    switch(random(2))
		    {
				case 0: format(string, sizeof(string), ""COL_SERVER"%s (%d)"COL_WHITE" is on killing spree of %d killstreaks!",GetName(killerid),killerid,pInfo[killerid][Streak]);
				case 1: format(string, sizeof(string), ""COL_SERVER"%s (%d)"COL_WHITE" has created a killstreak of %d!", GetName(killerid), killerid, pInfo[killerid][Streak]);
				case 2: format(string, sizeof(string), ""COL_SERVER"%s (%d)"COL_WHITE" is now creating a rampage of %d killstreaks!", GetName(killerid), killerid, pInfo[killerid][Streak]);
			}
			GivePlayerMoney(killerid, 50 * pInfo[killerid][Streak]);
			GivePlayerScore(killerid, 1 * pInfo[killerid][Streak]);
		}
	}
	return 1;
}
UPDATE: Enemy's POV


Re: onplayerdeath bug - Dayrion - 04.05.2016

PHP код:
ClearAnimations(playerid); 
I don't know why you add this if the player is already dying? The problem comes from this. (My sentence means nothing?)
You have to remove this and the player will die with a normal animation.
PHP код:
 pInfo[killerid][Streak] % == 
Hmm. I think 9 % 3 = 0 so.. 6 % 3 =0 too. 9/3 = 3
PHP код:
 pInfo[killerid][Streak] % == 0  && pInfo[killerid][Streak] <= 
No?
I hope I helped you!


Re: onplayerdeath bug - TheSimpleGuy - 04.05.2016

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
PHP код:
ClearAnimations(playerid); 
I don't know why you add this if the player is already dying? The problem comes from this. (My sentence means nothing?)
You have to remove this and the player will die with a normal animation.
PHP код:
 pInfo[killerid][Streak] % == 
Hmm. I think 9 % 3 = 0 so.. 6 % 3 =0 too. 9/3 = 3
PHP код:
 pInfo[killerid][Streak] % == 0  && pInfo[killerid][Streak] <= 
No?
I hope I helped you!
I was checking if the streak is divisible by 3
And before I added ClearAnimations(playerid);, it was already bugging


Re: onplayerdeath bug - Dayrion - 04.05.2016

Oh, apologizes, then. Your bug is solved?


Re: onplayerdeath bug - TheSimpleGuy - 04.05.2016

Not yet ((


Re: onplayerdeath bug - Dayrion - 04.05.2016

Even with removing ?
PHP код:
 ClearPlayerAnimations(playerid); 



Re: onplayerdeath bug - TheSimpleGuy - 04.05.2016

Yes. Before I added that, it was already bugging.


Re: onplayerdeath bug - Dayrion - 04.05.2016

So weird.. Try to create a command which kill yourself like /suicide. To check if it's not OnPlayerDeath is bugged ^^


Re: onplayerdeath bug - TheSimpleGuy - 04.05.2016

I have created a command called /kill and when bugged, it doesnt work but when I use it normally, it works.


Re: onplayerdeath bug - Nin9r - 04.05.2016

Put : SetPlayerHealth(playerid, 0); and SpawnPlayer(playerid); in that callback.