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



OnPlayerTakeDamage - CROSS_Hunter - 21.03.2013

Well, This is my code and the weapons dont hit the exact values that i want it hits the normal values

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    new Float:HP;
    GetPlayerHealth(playerid, HP);
    if(issuerid != INVALID_PLAYER_ID && weaponid  == 30)
    {
         new x = 1 + random(2200);
         SetPlayerHealth(playerid, HP-x);

    }
        if(issuerid != INVALID_PLAYER_ID && weaponid  == 31)
    {
        new x = 1 + random(2600);
         SetPlayerHealth(playerid, HP-x);
    }
        if(issuerid != INVALID_PLAYER_ID && weaponid  == 24)
    {
        new x = 1 + random(1600);
         SetPlayerHealth(playerid, HP-x);
    }
        if(issuerid != INVALID_PLAYER_ID && weaponid  == 22)
    {

        new x = 1 + random(1200);
         SetPlayerHealth(playerid, HP-x);
    }
        if(issuerid != INVALID_PLAYER_ID && weaponid  == 4)
    {

        new x = 4000 + random(10000);
         SetPlayerHealth(playerid, HP-x);

    }
        if(issuerid != INVALID_PLAYER_ID && weaponid  == 8)
    {

        new x = 5000 + random(12000);
         SetPlayerHealth(playerid, HP-x);

    }
        if(issuerid != INVALID_PLAYER_ID && weaponid  == 27)
    {

        new x = 1 + random(5000);
         SetPlayerHealth(playerid, HP-x);

    }
        if(issuerid != INVALID_PLAYER_ID && weaponid  == 35)
    {

        new x = 5000 + random(6000);
         SetPlayerHealth(playerid, HP-x);

    }
        if(issuerid != INVALID_PLAYER_ID && weaponid  == 38)
    {

        new x = 4000 + random(5000);
         SetPlayerHealth(playerid, HP-x);

    }

   
    return 1;
}
The max hp is 30000 for people who might get confused...


Re: OnPlayerTakeDamage - Denying - 21.03.2013

What's the problem? I don't understand you.
Example: If I take a weapon whose ID is 31, you want the player to lose EXACTLY 2601 HP?


Re: OnPlayerTakeDamage - CROSS_Hunter - 21.03.2013

Quote:
Originally Posted by Denying
Посмотреть сообщение
What's the problem? I don't understand you.
Example: If I take a weapon whose ID is 31, you want the player to lose EXACTLY 2601 HP?
No i need him to lose a random loss from 0-2600 HP

Btw you dont know what random is cuz 1 + Random(2600) doesnt mean 2601

Random usually generates the number before the max by one for example "Random(2600) its generated maximum as 2599 so i add 1+ that number to make it 2600 if it reached the max value it has to generate a number each bullet thrown to make you lose hp depending on that number generated..


Re: OnPlayerTakeDamage - CROSS_Hunter - 22.03.2013

any help?