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



Bug OnPlayerTakeDamage - Dima_Tkach - 31.12.2011

PHP код:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponid)
{
    if(
issuerid != INVALID_PLAYER_ID)
    {
        new 
rand 10 random(10);
         new 
Float:health;
          
GetPlayerHealth(playeridhealth);
        if(
weaponid == 24SetPlayerHealth(playerid,health-rand);
        if(
weaponid == 22SetPlayerHealth(playerid,health-rand);
    }
    return 
1;

That is done like this, but the effect is not so, it takes hp, but then adds back.
What is wrong?


Re: Bug OnPlayerTakeDamage - coole210 - 31.12.2011

This script does:

if the player takes damage from a real person, and weapon is ID 24/22, Set their health to CURRENT HEALTH-(Random(0-9)+10)

Let's say random becomes 8, the player will lose 18 health. Possible outcomes of random: 0-9 (maximum value is never counted)

I have no clue what you needed help with, I just responded by telling you what the script you have provided actually does.


Re: Bug OnPlayerTakeDamage - Dima_Tkach - 31.12.2011

Checked on an AK-47 and M4 - works.
Okey.Topic - closed.