OnPlayerTakeDamage
#1

Hello, I'm making a Taser system and I have some questions.

How I can make that the Taser Weapon (currently silenced pistol) don't take health to player?
I don't want to add the amount to his health because when a player has, for example, 10hp he'll die inmediately and will be a little buggy. Here's my actual code:

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(PlayerInfo[issuerid][pFaction] == 1 && PD_Taser[issuerid] == 1 && weaponid == 23)
	{
		if(Paralized[playerid] == 0)
		{
 			new Float:health;
        	GetPlayerHealth(playerid, health);
        	SetPlayerHealth(playerid, health+amount);
            ApplyAnimation(playerid, "SWEET", "LaFin_Sweet", 4.1, 0, 1, 1, 1, 0);
            TogglePlayerControllable(playerid, 0);
            Paralized[playerid] = 1;
            SetTimerEx("Tazz", 10000, false, "i", playerid);
       }
	}
 	return 1;
}
Reply
#2

You can do all of that stuff under OnPlayerWeaponShot and return 0 to desync the bullet so it won't take any damage.
Like this:
Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
        if (hittype == BULLET_HIT_TYPE_PLAYER)
	{
		if(PlayerInfo[playerid][pFaction] == 1 && PD_Taser[playerid] == 1 && weaponid == 23)
		{
			if(Paralized[hitid] == 0)
			{
				new Float:health;
				GetPlayerHealth(hitid, health);
				SetPlayerHealth(hitid, health+amount);
				ApplyAnimation(hitid, "SWEET", "LaFin_Sweet", 4.1, 0, 1, 1, 1, 0);
				TogglePlayerControllable(hitid, 0);
				Paralized[hitid] = 1;
				SetTimerEx("Tazz", 10000, false, "i", hitid);
		        }
		        return 0;
		}
	}
        return 1;
}
Or you can set everyone to the same team and create your own damages and if you shoot someone with a tazer then just don't take damage.
Reply
#3

So, then
Код:
new Float:health;
GetPlayerHealth(hitid, health);
SetPlayerHealth(hitid, health+amount);
These lines can be removed?
Reply
#4

Quote:
Originally Posted by HidroDF
Посмотреть сообщение
So, then
Код:
new Float:health;
GetPlayerHealth(hitid, health);
SetPlayerHealth(hitid, health+amount);
These lines can be removed?
Yeah. I didn't even notice these.
Reply
#5

I suggest putting your damage script inside of OnPlayerTake and disable all default damages and then choose when to give damage

Example:
Код:
	if(somethinghere)
	{
		new Float:x, Float:y, Float:z;

		switch(weaponid)
		{
			case 0: damage = 3; //Your weapon's damages
                        //Heres a code for shotgun damage and no damage for beanbag.
			case 25:
    		        {
	    		        if(!IsBBActive{issuerid})
				{
					if(!Beanbagged{playerid})
					{
                                              //Beanbag code here
					}
					else
					{
						//Else code here, aka a warning indicating you've shot him already
					}
				}
				else
				{
                                      // Your shotgun's weapon damage here
				}
    		}
Reply
#6

Quote:
Originally Posted by Clora
Посмотреть сообщение
I suggest putting your damage script inside of OnPlayerTake and disable all default damages and then choose when to give damage

Example:
Код:
	if(somethinghere)
	{
		new Float:x, Float:y, Float:z;

		switch(weaponid)
		{
			case 0: damage = 3; //Your weapon's damages
                        //Heres a code for shotgun damage and no damage for beanbag.
			case 25:
    		        {
	    		        if(!IsBBActive{issuerid})
				{
					if(!Beanbagged{playerid})
					{
                                              //Beanbag code here
					}
					else
					{
						//Else code here, aka a warning indicating you've shot him already
					}
				}
				else
				{
                                      // Your shotgun's weapon damage here
				}
    		}
That's what I said. But he needs to set everyone to the same team for that. In my opinion that OnPlayerWeaponShot thing is OK if he doesn't need any custom damages.
Reply
#7

Thanks Clora and GoldenLion, I'll use OnPlayerWeaponShot, it's more easy for me.

Thanks all!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)