Weapon damages (unsure of error)
#1

Hey, ever single weapon works except for shotguns(only sometimes, depends on damage) but M4's and AK's don't work at all. Here is the basic code.
PHP код:
public OnPlayerGiveDamage(playeriddamagedidFloat:amountweaponidbodypart)
{
    new 
Float:PlayerHealth;
    if(
Character[damagedid][BrutalM] == && Character[damagedid][Dead] == && playerid != INVALID_PLAYER_ID)
    {
    
GetPlayerHealth(damagedidPlayerHealth);
    if(
PlayerHealth amount 36 && Character[damagedid][BrutalM] == && !IsPlayerInAnyVehicle(damagedid)) {
    
BrutalMode(damagedid);
    return 
0;
    }
 } 
Video: https://www.youtube.com/watch?v=_rbVO6iK4BY
Reply
#2

Quote:

Keep in mind this function can be inaccurate in some cases.

https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage
(I am referring to the use of "amount")

Try to use OnPlayerTakeDamage instead.


EDIT: On the other hand, you can debug this and see what isn't returning true on the code.
Reply
#3

I see what you're trying to do.
Look, the way I fixed this in my script was to set all players team to -1 then assign unique damage values to each weapon based on bodypart. If you don't feel like doing that, you can always just make the player be assigned to the injured/dead state and TP them back to their death position and apply the animations, etc.

The reason the default damages don't work is due to the fact that SA-MP can't immediately stop damage from being given to recognize the callback in the script. GTA: San Andreas physics automatically take the damage from a player before reading that specific line to stop it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)