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



OnPlayerTakeDamage - Type-R - 27.05.2016

Hello, so i am trying to do this thing where there is a specific zone and if a cop shoots a civilian that has not committed a crime, his HP would stay where it was. I have an issue, that the player does become unkillable to the officer, but the HP goes down, up or stays. It does all of this, but the player does not die. I have no idea why its doing this.. Heres my code:

Код:
if(IsPlayerInDynamicArea(playerid, zones[0]))
	{
	    if(darbas[issuerid] == 5) //Check for if player is cop
	    {
	        if(GetPlayerSkin(issuerid) == 280) //if he has cop skin on
	        {
	            if(NusikaltesKaime[playerid] == 0)//check that player shot, does not have committed a crime
	            {
	                new Float:h;
             		GetPlayerArmour(playerid,h);
			SetPlayerArmour(playerid,h+amount);
	                GetPlayerHealth(playerid, h);
	                SetPlayerHealth(playerid, h+amount);
	                GameTextForPlayer(issuerid,"~<~ ~r~NEZUDYKITE CIVILIU ~>~",1000,5); //message that tells, to now kill civilians
	                return 0;
				}
			}
		}
	}
Do you guys know what could be the problem??


Re: OnPlayerTakeDamage - justjamie - 27.05.2016

if you set the health to 0, it doesn't kill the person right.
add this (didnt test)
PHP код:
new Float:h2;
GetPlayerHealth(playeridh2);
{
if(
h2==0)
Kill(playerid)




Re: OnPlayerTakeDamage - Type-R - 28.05.2016

Killing a person is not my issue. My issue is that, the players HP won't stay the same, after a police officer shoots him. It wanders around and i need it to stay the same, if he is a civilian.


Re: OnPlayerTakeDamage - andrejc999 - 28.05.2016

Maybe you should make a different system with OnPlayerWeaponShot so if the officer shoots a bullet and it hits a civilian then set civilians health to the same amount as it was before...

https://sampwiki.blast.hk/wiki/OnPlayerWeaponShot


Re: OnPlayerTakeDamage - Type-R - 28.05.2016

Yeah i see that in this function i can just return 0, if it is a civilian. Thank you for helping. Also what could i do about a cop lets say hitting a civilian with a baseball bat or just with hands?


Re: OnPlayerTakeDamage - andrejc999 - 28.05.2016

Have you tried to put return 0; on onplayertakedamage? So if the issuerid == cop it returns 0?


Re: OnPlayerTakeDamage - Type-R - 28.05.2016

I will try to, when i have some time. That might actually be a good idea.


Re: OnPlayerTakeDamage - Stinged - 28.05.2016

Returning 0 on OnPlayerTakeDamage doesn't stop the damage.