SA-MP Forums Archive
Player not taking damage - 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: Player not taking damage (/showthread.php?tid=663452)



Player not taking damage - TokicMajstor - 01.02.2019

Hello, I have a problem in my gamemode, simply player does not take any damage, I have a textdraw which shows how much damage do you take or give and it is showing that Iam taking or givning damage but nothing happens, health bar is still the same and armour too. I was thinking that palyer has infinite health but i treied to set my health to 50, and health bar shows 50 health normally but than somebody shoots me and I still do not take any damage (however Textdraw shows damage -9). Thank you for your help


Re: Player not taking damage - Nossa - 01.02.2019

Can You post OnPlayerTakeDamage section for us.


Re: Player not taking damage - TokicMajstor - 02.02.2019

Yes here is it (It has some parts on Serbian language because Gamemode is on that language so I translated this)


Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {

                ////// THIS IS FOR POLICE TASER (tazer = taser maybe is spelled it wrong)

		if(IgracPolicajac(issuerid))
		{
			if(GetPlayerWeapon(issuerid) == 23)
			{
				new string[128], Float:Poz[3];
				GetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
				if(IsPlayerInRangeOfPoint(issuerid, 5.0, Poz[0], Poz[1], Poz[2]))
				{
					if(PlayerInfo[playerid][pTrazeniLevel] == 0) return SCM(issuerid,-1,""PLAVA"[ERROR] "SIVA"That player does not have Wanted Level!");
					if(IgracPolicajac(playerid)) return SCM(issuerid,-1,""PLAVA"INFO | "SIVA"YOu can not do that on Police Officer!");
					if(PlayerInfo[issuerid][pRank] == 0) return SCM(issuerid,-1,""PLAVA"INFO | "SIVA"You are suspended!");
					if(AdminDuty[playerid] == 1) return SCM(issuerid,-1,""PLAVA"INFO | "SIVA"That player is Admin on duty!");
					format(string, sizeof(string), "%s shoots with tazer on %s.", GetName(issuerid) ,GetName(playerid));
					ProxDetector(20.0, issuerid, string, PROX,PROX,PROX,PROX,PROX);
					TogglePlayerControllable(playerid, 0); PlayerTazer[playerid] = 1;
					TazerTimerr[playerid] = SetTimerEx("TazerTimer", 15000, false, "i", playerid);
					OnePlayAnim(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
				}
			}
		}
	}

        /////// THIS IS DAMAGE TEXTDRAW IT SAYS LIKE [-9 Damage PlyerName]

	new s[20];
	format(s, 20, "%s (-Damage %.0f)", GetName(playerid),amount);
	TextDrawSetString(TakeDamage[playerid], s);
	TextDrawShowForPlayer(playerid, TakeDamage[playerid]);
	SetTimerEx("DestruirTextoDraw", 1000, false, "i", playerid);

        ////// This is something like for granades it is not very important

	if (weaponid == WEAPON_GRENADE || weaponid == 51)
	{
		new Float:health;
		GetPlayerHealth(playerid, health);
		SetPlayerHealth(playerid, (health - (amount * 0.3)));

		FlashbangStage[playerid] = 1;

		HandleFlashbangStage(playerid);
	}
	return 1;
}



Re: Player not taking damage - lollypap54 - 02.02.2019

It could be that OnPlayerUpdate returns 0. Can you die from falling or you only can't take damage from other players?


Re: Player not taking damage - TokicMajstor - 02.02.2019

You can die from falling but from any weapons you can't


Re: Player not taking damage - TokicMajstor - 03.02.2019

Thank you for helping that with OnPlayerUpdate helped, there was something like return true; i removed that and put return 1; at the bottom. Now it is working