AOD - No damage
#1

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;
}
Reply
#2

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 );
Reply
#3

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

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

Just return 0; in OnPlayerWeaponShot() of course.
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)