SA-MP Forums Archive
AOD - No 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: AOD - No damage (/showthread.php?tid=599158)



AOD - No damage - yvoms - 21.01.2016

Im trying to set it so if an admin is on duty, and shoots a player, the player will not be inflicted.
I figured i would do this by getting the Damage and giving it back however i can't find out what i am doing wrong.

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
	if(aod[playerid] != Text3D:INVALID_3DTEXT_ID)
	{
		SendClientMessage(playerid, COLOR_WHITE, "{ff0000}[Error]:{ffffff} You are On-Duty please refrain from damaging players.");
		amount = GetPlayerHealth(damagedid);
		SetPlayerHealth(damagedid, +amount);
	}
	return 1;
}



Re: AOD - No damage - Smileys - 21.01.2016

You must first get the player's health, store it in a variable and then add the lost amount to it that.

pawn Код:
new Float:health = GetPlayerHealth(damagedid); // health might be given as parameter instead of doing it like this, forgot the syntax. Typing this from phone.
SetPlayerHealth(damagedid, health + amount );



Re: AOD - No damage - yvoms - 21.01.2016

Wouldn't it be
Код:
		new Float:health = GetPlayerHealth(damagedid, health);
		SetPlayerHealth(damagedid, health + amount);
Since GetPlayerHealth already uses that syntax?


Re: AOD - No damage - Lucky13 - 21.01.2016

Smileys is right. You should also use it at OnPlayerTakeDamage, as it works more accurate in my opinion

On‌PlayerGiveDamage = When you give
On‌PlayerTakeDamage = When you take


Re: AOD - No damage - Pottus - 21.01.2016

Just return 0; in OnPlayerWeaponShot() of course.


Re: AOD - No damage - yvoms - 22.01.2016

Thank you pottus, i've managed to fix this,

Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{	
	if(aod[playerid] != Text3D:INVALID_3DTEXT_ID)
	{
		return 0;
	}
	return 1;
}
Checking if the player is on duty and if the player is, do not inflict damage.
and at OnPlayerGiveDamage im checking if the admin on duty is shooting a player, if he is.
Sending him a message not to do so.
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
	if(aod[playerid] != Text3D:INVALID_3DTEXT_ID)
	{
		SendClientMessage(playerid, COLOR_WHITE, "{ff0000}[Error]:{ffffff} You are On-Duty please refrain from damaging players.");
	}
	return 1;
}
Thanks you helped me out alot <3