OnPlayerTakeDamage
#1

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??
Reply
#2

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)

Reply
#3

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.
Reply
#4

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
Reply
#5

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?
Reply
#6

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

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

Returning 0 on OnPlayerTakeDamage doesn't stop the damage.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)