Weapon damages (unsure of error) - 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: Weapon damages (unsure of error) (
/showthread.php?tid=637220)
Weapon damages (unsure of error) -
aoky - 11.07.2017
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(playerid, damagedid, Float:amount, weaponid, bodypart)
{
new Float:PlayerHealth;
if(Character[damagedid][BrutalM] == 0 && Character[damagedid][Dead] == 0 && playerid != INVALID_PLAYER_ID)
{
GetPlayerHealth(damagedid, PlayerHealth);
if(PlayerHealth - amount < 36 && Character[damagedid][BrutalM] == 0 && !IsPlayerInAnyVehicle(damagedid)) {
BrutalMode(damagedid);
return 0;
}
}
Video:
https://www.youtube.com/watch?v=_rbVO6iK4BY
Re: Weapon damages (unsure of error) -
Kaperstone - 11.07.2017
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.
Re: Weapon damages (unsure of error) -
oSAINTo - 11.07.2017
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.