Removing damages
#1

So, basically. We have a custom damage system and we use this in order to put the player into brutally wounded mode.

PHP код:
if (PlayerHealth amount 5)
if(
Character[playerid][BrutalM] == 0
So, if the players health is for example 20 and he gets shot by a deagle, he instantly dies. How can we make it to block any damages and set his health to 25 if his health is less than or equal to 5? I don't want death to exist in this situation at all.


E: I don't want code, even a summary would help. Thank you!
Reply
#2

Return 0 under https://sampwiki.blast.hk/wiki/OnPlayerWeaponShot to avoid damage to be done with weapons.
Reply
#3

Yeah, I'm already doing that but it still kills the player.

PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    new 
DeathB;
    new 
DeathS[128];
    new 
Float:PlayerHealth;
    
GetPlayerHealth(playeridPlayerHealth);
    if (
PlayerHealth amount 5)
    if(
Character[playerid][BrutalM] == 0)
        {
            
ClearPlayerWeapons(playerid);
            
GetPlayerPos(playeridBMPos[playerid][0], BMPos[playerid][1], BMPos[playerid][2]);
            
Character[playerid][BrutalM] = 1;
            
Character[playerid][CanAccept] = 0;
            
LegHit[playerid] = 0;

            
format(DTextSsizeof(DTextS), "(( %s is currently injured, type /damages %i for more info. ))"GetName(playerid), playerid);
            
label[playerid] = Create3DTextLabel(DTextSCOLOR_REDBMPos[playerid][0], BMPos[playerid][1], BMPos[playerid][2], 10.00);
            
Attach3DTextLabelToPlayer(label[playerid], playerid000.7);

            if(
Character[playerid][Level] <= 10)
            {
                 
ClearPlayerWeapons(playerid);
                
DeathB RandomEx(100500);
                
GivePlayerMoney(playerid, -DeathB);
                
format(DeathSsizeof(DeathS), "EMT: Your Medical bills are $%i."DeathB);
                
SCM(playeridCOLOR_LIGHTPINKDeathS);
                
SCM(playeridCOLOR_LIGHTRED"You were brutally wounded, now if a medic or anyone else doesn't save you, you'll die.");
                
SCM(playeridCOLOR_LIGHTRED"To accept death type /acceptdeath");
            }
            else if(
Character[playerid][Level] <= 20 && Character[playerid][Level] > 10)
            {
                
ClearPlayerWeapons(playerid);
                
DeathB RandomEx(100750);
                
GivePlayerMoney(playerid, -DeathB);
                
format(DeathSsizeof(DeathS), "EMT: Your Medical bills are $%i."DeathB);
                
SCM(playeridCOLOR_LIGHTPINKDeathS);
                
SCM(playeridCOLOR_LIGHTRED"You were brutally wounded, now if a medic or anyone else doesn't save you, you'll die.");
                
SCM(playeridCOLOR_LIGHTRED"To accept death type /acceptdeath");
            }
            else if(
Character[playerid][Level] <= 30 && Character[playerid][Level] > 20)
            {
                
ClearPlayerWeapons(playerid);
                
DeathB RandomEx(1001250);
                
GivePlayerMoney(playerid, -DeathB);
                
format(DeathSsizeof(DeathS), "EMT: Your Medical bills are $%i."DeathB);
                
SCM(playeridCOLOR_LIGHTPINKDeathS);
                
SCM(playeridCOLOR_LIGHTRED"You were brutally wounded, now if a medic or anyone else doesn't save you, you'll die.");
                
SCM(playeridCOLOR_LIGHTRED"To accept death type /acceptdeath");
            }
            else if(
Character[playerid][Level] > 30)
            {
                
ClearPlayerWeapons(playerid);
                
DeathB RandomEx(1001500);
                
GivePlayerMoney(playerid, -DeathB);
                
format(DeathSsizeof(DeathS), "EMT: Your Medical bills are $%i."DeathB);
                
SCM(playeridCOLOR_LIGHTPINKDeathS);
                
SCM(playeridCOLOR_LIGHTRED"You were brutally wounded, now if a medic or anyone else doesn't save you, you'll die.");
                
SCM(playeridCOLOR_LIGHTRED"To accept death type /acceptdeath");
                return 
0;
            }
        }

//there is more code here for the rest 
Reply
#4

https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage

Quote:

Return Values:
1 - Callback will not be called in other filterscripts.
0 - Allows this callback to be called in other filterscripts.
It is always called first in filterscripts so returning 1 there blocks other filterscripts from seeing it

You're using the wrong callback, use OnPlayerWeaponShot instead for this to work out.
Reply
#5

The BW system you're trying to replicate never really worked well with OnPlayerTakeDamage, in my experience anyway. It worked fine with OnPlayerWeaponShot which I'm using right now but, the problem still occurs with a player dying but it happens like 2 / 6 times.

BTW, you should just make a function for your death bills so your code is cleaner.
Reply
#6

Take this for reference:
https://sampforum.blast.hk/showthread.php?tid=634344
Reply
#7

So, I did as you said with OnPlayerWeaponShot and tried both return 1; and 0; but anytime the player is shot - he just gets put into BrutalM and then Dead right after.

OnPlayerWeaponShot
PHP код:
forward OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ);
public 
OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    new 
DeathB;
    new 
DeathS[128];
    new 
Float:PlayerHealth;
    
GetPlayerHealth(hitidPlayerHealth);
    if (
hitid hittype 10)
    if(
Character[hitid][BrutalM] == 0)
        {
            
ClearPlayerWeapons(hitid);
            
GetPlayerPos(hitidBMPos[hitid][0], BMPos[hitid][1], BMPos[hitid][2]);
            
Character[hitid][BrutalM] = 1;
            
Character[hitid][CanAccept] = 0;
            
LegHit[hitid] = 0;

            
format(DTextSsizeof(DTextS), "(( %s is currently injured, type /damages %i for more info. ))"GetName(hitid), hitid);
            
label[hitid] = Create3DTextLabel(DTextSCOLOR_REDBMPos[hitid][0], BMPos[hitid][1], BMPos[hitid][2], 10.00);
            
Attach3DTextLabelToPlayer(label[hitid], hitid000.7);

            if(
Character[hitid][Level] <= 10)
            {
                
SetPlayerHealth(hitid25);
                 
ClearPlayerWeapons(hitid);
                
DeathB RandomEx(100500);
                
GivePlayerMoney(hitid, -DeathB);
                
format(DeathSsizeof(DeathS), "EMT: Your Medical bills are $%i."DeathB);
                
SCM(hitidCOLOR_LIGHTPINKDeathS);
                
SCM(hitidCOLOR_LIGHTRED"You were brutally wounded, now if a medic or anyone else doesn't save you, you'll die.");
                
SCM(hitidCOLOR_LIGHTRED"To accept death type /acceptdeath");
            }
            else if(
Character[hitid][Level] <= 20 && Character[playerid][Level] > 10)
            {
                
SetPlayerHealth(hitid25);
                
ClearPlayerWeapons(hitid);
                
DeathB RandomEx(100750);
                
GivePlayerMoney(hitid, -DeathB);
                
format(DeathSsizeof(DeathS), "EMT: Your Medical bills are $%i."DeathB);
                
SCM(hitidCOLOR_LIGHTPINKDeathS);
                
SCM(hitidCOLOR_LIGHTRED"You were brutally wounded, now if a medic or anyone else doesn't save you, you'll die.");
                
SCM(hitidCOLOR_LIGHTRED"To accept death type /acceptdeath");
            }
            else if(
Character[hitid][Level] <= 30 && Character[hitid][Level] > 20)
            {
                
SetPlayerHealth(hitid25);
                
ClearPlayerWeapons(hitid);
                
DeathB RandomEx(1001250);
                
GivePlayerMoney(hitid, -DeathB);
                
format(DeathSsizeof(DeathS), "EMT: Your Medical bills are $%i."DeathB);
                
SCM(hitidCOLOR_LIGHTPINKDeathS);
                
SCM(hitidCOLOR_LIGHTRED"You were brutally wounded, now if a medic or anyone else doesn't save you, you'll die.");
                
SCM(hitidCOLOR_LIGHTRED"To accept death type /acceptdeath");
            }
            else if(
Character[hitid][Level] > 30)
            {
                
SetPlayerHealth(hitid25);
                
ClearPlayerWeapons(hitid);
                
DeathB RandomEx(1001500);
                
GivePlayerMoney(hitid, -DeathB);
                
format(DeathSsizeof(DeathS), "EMT: Your Medical bills are $%i."DeathB);
                
SCM(hitidCOLOR_LIGHTPINKDeathS);
                
SCM(hitidCOLOR_LIGHTRED"You were brutally wounded, now if a medic or anyone else doesn't save you, you'll die.");
                
SCM(hitidCOLOR_LIGHTRED"To accept death type /acceptdeath");
                return 
1;
            }
        } 
OnPlayerTakeDamage
PHP код:
if(Character[playerid][BrutalM] == 1)
        {
            
GetPlayerPos(playeridDPos2[playerid][0], DPos2[playerid][1], DPos2[playerid][2]);
            
Delete3DTextLabel(label[playerid]);
            
label2[playerid] = Create3DTextLabel("(( THIS PLAYER IS NOW DEAD ))"COLOR_REDDPos2[playerid][0], DPos2[playerid][1], DPos2[playerid][2], 10.00);
            
Attach3DTextLabelToPlayer(label2[playerid], playerid000.7);
            
Character[playerid][Dead] = 1;
            
Character[playerid][BrutalM] = 0;
            
SCM(playeridCOLOR_YELLOW">> You are now dead. You can use /respawnme after 60 seconds to respawn.");
            
Character[playerid][CanSpawn] = 0;
            
KillTimer(DeathT);
            
RespawnT 60;
            
RespawnEx SetTimer("RespawnTimer"999true);
            
RTimer SetTimerEx("RespawnTimer2"60000false"i"playerid);
        } 
Reply
#8

PHP код:
if (hitid hittype 10
What is this?

Assuming you're testing with a friend, his id would be 1, the BULLET_HIT_TYPE_PLAYER (which is what the callback will return for the hittype value) is defined as 1, 1 - 1 is zero which is less than 10, the conditional statement is true.
Reply
#9

Quote:
Originally Posted by Toroi
Посмотреть сообщение
PHP код:
if (hitid hittype 10
What is this?
Looks like you found it, that should be if (PlayerHealth - hittype < 10). Right?

Just a reminder, I'm trying to prevent all damages when when the players health is less than.
Reply
#10

I know you didn't want a code, but it's easier for me to explain you with the example code (read the // comments):

PHP код:
if (PlayerHealth 10.0// fix the conditions
//< open braces
    
if(Character[hitid][BrutalM] == 0)
        {
            
ClearPlayerWeapons(hitid);
            
GetPlayerPos(hitidBMPos[hitid][0], BMPos[hitid][1], BMPos[hitid][2]);
            
Character[hitid][BrutalM] = 1;
            
Character[hitid][CanAccept] = 0;
            
LegHit[hitid] = 0;
            
format(DTextSsizeof(DTextS), "(( %s is currently injured, type /damages %i for more info. ))"GetName(hitid), hitid);
            
label[hitid] = Create3DTextLabel(DTextSCOLOR_REDBMPos[hitid][0], BMPos[hitid][1], BMPos[hitid][2], 10.00);
            
Attach3DTextLabelToPlayer(label[hitid], hitid000.7);
            if(
Character[hitid][Level] <= 10)
            {
                
SetPlayerHealth(hitid25);
                 
ClearPlayerWeapons(hitid);
                
DeathB RandomEx(100500);
                
GivePlayerMoney(hitid, -DeathB);
                
format(DeathSsizeof(DeathS), "EMT: Your Medical bills are $%i."DeathB);
                
SCM(hitidCOLOR_LIGHTPINKDeathS);
                
SCM(hitidCOLOR_LIGHTRED"You were brutally wounded, now if a medic or anyone else doesn't save you, you'll die.");
                
SCM(hitidCOLOR_LIGHTRED"To accept death type /acceptdeath");
            }
            else if(
Character[hitid][Level] <= 20 && Character[playerid][Level] > 10)
            {
                
SetPlayerHealth(hitid25);
                
ClearPlayerWeapons(hitid);
                
DeathB RandomEx(100750);
                
GivePlayerMoney(hitid, -DeathB);
                
format(DeathSsizeof(DeathS), "EMT: Your Medical bills are $%i."DeathB);
                
SCM(hitidCOLOR_LIGHTPINKDeathS);
                
SCM(hitidCOLOR_LIGHTRED"You were brutally wounded, now if a medic or anyone else doesn't save you, you'll die.");
                
SCM(hitidCOLOR_LIGHTRED"To accept death type /acceptdeath");
            }
            else if(
Character[hitid][Level] <= 30 && Character[hitid][Level] > 20)
            {
                
SetPlayerHealth(hitid25);
                
ClearPlayerWeapons(hitid);
                
DeathB RandomEx(1001250);
                
GivePlayerMoney(hitid, -DeathB);
                
format(DeathSsizeof(DeathS), "EMT: Your Medical bills are $%i."DeathB);
                
SCM(hitidCOLOR_LIGHTPINKDeathS);
                
SCM(hitidCOLOR_LIGHTRED"You were brutally wounded, now if a medic or anyone else doesn't save you, you'll die.");
                
SCM(hitidCOLOR_LIGHTRED"To accept death type /acceptdeath");
            }
            else if(
Character[hitid][Level] > 30)
            {
                
SetPlayerHealth(hitid25);
                
ClearPlayerWeapons(hitid);
                
DeathB RandomEx(1001500);
                
GivePlayerMoney(hitid, -DeathB);
                
format(DeathSsizeof(DeathS), "EMT: Your Medical bills are $%i."DeathB);
                
SCM(hitidCOLOR_LIGHTPINKDeathS);
                
SCM(hitidCOLOR_LIGHTRED"You were brutally wounded, now if a medic or anyone else doesn't save you, you'll die.");
                
SCM(hitidCOLOR_LIGHTRED"To accept death type /acceptdeath");
            }
    return 
0// return 0; to avoid damage before closing braces
}// close brace of the conditional statement 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)