SA-MP Forums Archive
/taser - 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: /taser (/showthread.php?tid=643507)



/taser - pollo97 - 21.10.2017

I'm making /taser command, but i can't figure out how to prevent taking damage for the shooted player without using OnPlayerUpdate callback.
Any suggestions?


Re: /taser - TheRohlikar - 21.10.2017

What you take, you can give it back... Isn't that enough?


Re: /taser - pollo97 - 21.10.2017

Yeah i know, but which method i should use?
For example, i tried to give back the player's damage under OnPlayerTakeDamage, but it doesn't work.


Re: /taser - TheRohlikar - 21.10.2017

Quote:
Originally Posted by pollo97
Посмотреть сообщение
Yeah i know, but which method i should use?
For example, i tried to give back the player's damage under OnPlayerTakeDamage, but it doesn't work.
I would use https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage (it should work with takedamage too)

Eventually, you can search for it and you'll find it used in the same script.


Re: /taser - pollo97 - 21.10.2017

I tried under OnPlayerGiveDamage and OnPlayerTakeDamage:

Код:
new Float:health;
GetPlayerHealth(damagedid,health);
SetPlayerHealth(damagedid,health);
But it doesn't work.


Re: /taser - GoldenLion - 21.10.2017

What you can do is return 0 at OnPlayerWeaponShot to desync the bullet so it won't take any damage or set everyone to the same team and create your own weapon damages.


Re: /taser - jlalt - 21.10.2017

PHP код:
SetPlayerHealth(damagedid,health); 
sum damage with the health
PHP код:
SetPlayerHealth(damagedid,health amount); 



Re: /taser - Abagail - 21.10.2017

Quote:
Originally Posted by jlalt
Посмотреть сообщение
PHP код:
SetPlayerHealth(damagedid,health); 
sum damage with the health
PHP код:
SetPlayerHealth(damagedid,health amount); 
This won't be accurate, amount is made up of both health & armor and plus there are other possibilites that could effect this. One solution would be checking if the conditions for it being a taser are met within OnPlayerWeaponShot and if so, setting both players to the same team. Then set a quick timer to reset the teams within OnPlayerTakeDamage, which I think should still be called. Don't quote me on this, I might be thinking of something else.


Re: /taser - CodeStyle175 - 21.10.2017

PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    if(
hittype==BULLET_HIT_TYPE_PLAYER && GetPlayerWeapon(playerid)==23){//colt
        
return 0//prevents player taking damage
    
}
    return 
1;




Re: /taser - Bruno13 - 21.10.2017

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    if(
hittype==BULLET_HIT_TYPE_PLAYER && GetPlayerWeapon(playerid)==23){//colt
        
return 0//prevents player taking damage
    
}
    return 
1;

Use this, or set the both players in the same team in OnPlayerWeaponShop and set back in OnPlayerTakeDamage.