Three questions regarding weapon callbacks
#1

Hey, first question is about the include OPSP (OnPlayerShootPlayer)
Is it called AFTER the player lost the armor&HP ?

Second question, can I detect HP/AP/Both lost under OnPlayerWeaponShot somehow ?

Third question, can I prevent a player losing HP using something under OnPlayerTake/GiveDamage ?
Reply
#2

About OnPlayerShootPlayer, it gets called after player loses health, but you shouldn't use it because it's old and it was created when OnPlayerTakeDamage/OnPlayerGiveDamage didn't exist.

About disabling damages: you can return 0 under OnPlayerWeaponShot to prevent gun damage, but it will totally remove the bullets, but the other way what people do (including me) is set everyone's team to 0 so all damages given from someone will be disabled so you can create your own damages.
Reply
#3

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
About OnPlayerShootPlayer, it gets called after player loses health, but you shouldn't use it because it's old and it was created when OnPlayerTakeDamage/OnPlayerGiveDamage didn't exist.

About disabling damages: you can return 0 under OnPlayerWeaponShot to prevent gun damage, but it will totally remove the bullets, but the other way what people do (including me) is set everyone's team to 0 so all damages given from someone will be disabled so you can create your own damages.
That's impossible to do since I'm creating a TDM mode ..
Reply
#4

Returning 0 under OnPlayerWeaponShot isn't impossible though.

2. https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage , health and armour lost is already calculated / combined in this callback alone. The work is done for you.

3. Under what conditions should a player not receive damage? Just apply that logic to OnPlayerWeaponShot.
Reply
#5

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Returning 0 under OnPlayerWeaponShot isn't impossible though.

2. https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage , health and armour lost is already calculated / combined in this callback alone. The work is done for you.

3. Under what conditions should a player not receive damage? Just apply that logic to OnPlayerWeaponShot.
I need a callback similar to OnPlayerGive/TakeDamage where I can return 0 and the damage won't be taken by the server.
Here is my idea:

Well think about it,
Returning 0 in OnPlayerWeaponShot
Creating two functions (SetNexHealth/Armour) which is the health/armour is reduced from both player & array
Calculate the damage and use it into two temp arrays (HP & AP)
Reduce it using the functions explained above
if HP == 0, return 1 so OnPlayerDeath will be called

I already know how to do everything I have explained, I am only missing one thing
How can I detect how many damage the player received ...
Reply
#6

No, you can do the same team thing in TDM as well. I did that in my gamemode. That's the only way I guess. As I told you, if you return 0 under OnPlayerWeaponShot players won't be even able to see that you shot them, they won't see any bullets, blood nor muzzle flash, only you will see these effects. For the same team thing all you need to do is create a variable where you store player's team, and simply don't take the custom damage from the player if the shooter's team is same as the player's, you don't need to do anything with SetPlayerTeam after setting them to the same team.
Reply
#7

I don't get it... you can use OnPlayerWeaponShot for this... If you return 0 there, there is no health or armour lost... there is no giving them back health and armour, there is no calculating damage.

Just use SetPlayerTeam and OnPlayerWeaponShot. What are you trying to achieve
Reply
#8

Quote:
Originally Posted by Threshold
Посмотреть сообщение
I don't get it... you can use OnPlayerWeaponShot for this... If you return 0 there, there is no health or armour lost... there is no giving them back health and armour, there is no calculating damage.

Just use SetPlayerTeam and OnPlayerWeaponShot. What are you trying to achieve
Lol why would you use OnPlayerWeaponShot if you can simply use OnPlayerTakeDamage/OnPlayerGiveDamage?
Reply
#9

Because he's trying to STOP the damage... why 'would' you use OnPlayerTake/GiveDamage for that? If SetPlayerTeam fails you on that occasion, then OnPlayerWeaponShot is essentially the only other option you have. Unless you want some heinously stupid code that returns their health and armour to them AFTER they've taken damage, which defeats the entire purpose.

PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    if(
hittype == BULLET_HIT_TYPE_PLAYER)
    {
        if(!
CanPlayerTakeDamage(hitid)) return 0;
    }
    return 
1;

Problem solved..
Reply
#10

You guys did not understand me, nevermind anymore I guess ..
I will explain it the best way I can
I DON'T want the Health/Armour to be reduced from their Health/Armour BAR (GetPlayerHP/AP)
I want to REDUCE it myself using a function that will reduce it from the HEALTH / ARMOUR array instantly, because the delay makes some ban glitches.
A clue ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)