Adding health under onplayertakedamage?
#1

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{

GivePlayerHealth(playerid, amount);

return 1;
}

stock GivePlayerHealth(playerid, Float:health)
{
    new Float:loc_health;
    GetPlayerHealth(playerid, loc_health);
    return SetPlayerHealth(playerid, loc_health + health);
}
This script supposed to keep player health at the certain level. But for some reason, when player takes damage, it adds more health than it should
Reply
#2

You should have a read over this topic - https://sampforum.blast.hk/showthread.php?pid=876854#pid876854
Reply
#3

Damn it ^^
Reply
#4

OnPlayerTakeDamage is called after a player takes damage, you'll have to prevent the normal damage.
Reply
#5

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
so should I add health with timer?
Reply
#6

Quote:
Originally Posted by ax1
Посмотреть сообщение
so should I add health with timer?
Use a variable and reduce only when you would like damage to be accepted. Keep setting the player's health to that otherwise.

Note that a minigun for example will always kill the player.
Reply
#7

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Use a variable and reduce only when you would like damage to be accepted. Keep setting the player's health to that otherwise.

Note that a minigun for example will always kill the player.
What if I want to give player only half a damage OnPlayerTakeDamage?
Reply
#8

OnPlayerTakeDamage is called after player takes the damage. So even if you add half of the health so it looks like player receives only half the damage, there are still chances where the player dies and then SetPlayerHealth is called. It's better to create a custom server sided health system which can then allow you to code such features.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)