/taser
#1

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?
Reply
#2

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

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.
Reply
#4

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

I tried under OnPlayerGiveDamage and OnPlayerTakeDamage:

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

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

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

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.
Reply
#9

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;

Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)