SA-MP Forums Archive
Damage system help! - 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: Damage system help! (/showthread.php?tid=531820)



Damage system help! - TheSnicky - 14.08.2014

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
{
new
weaponName[24],
victimName[MAX_PLAYER_NAME],
attackerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, victimName, sizeof (victimName));
GetPlayerName(issuerid, attackerName, sizeof (attackerName));
GetWeaponName(weaponid, weaponName, sizeof (weaponName));
if (IsHurt[playerid] == 0)
{
new string[64];
format(string,sizeof(string),"(( Has been injured %f , Weapon: %s ))", amount, weaponName);
new Text3D:wounded;
wounded = Create3DTextLabel(string, 0xAA3333AA, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(wounded, playerid, 0.0, 0.0, 0.7);
Update3DTextLabelText(wounded, 0xAA3333AA, string);
}
}
return 1;
}

It compiles without any erros or anything. But when I shot him once, it says " (( Has been injured 46.0000 times )) " But I want when I shoot him once, to says " (( Has been injured 1 time )). Please help!


Re: Damage system help! - Faisal_khan - 14.08.2014

Float: amount is not the no. of times the player has been shot, but it is the health which has been reduced.


Re: Damage system help! - TheSnicky - 14.08.2014

How do I make it like I want it ?


Respuesta: Damage system help! - Cepillado - 14.08.2014

Maybe you could make something like

Код:
new Injuries[MAX_PLAYERS];
and then

Код:
if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
{
Injuries[playerid] ++;



Re: Damage system help! - Faisal_khan - 14.08.2014

Untested:
pawn Код:
new shot[MAX_PLAYERS];
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
    {
        new
            weaponName[24],
            victimName[MAX_PLAYER_NAME],
            attackerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, victimName, sizeof (victimName));
        GetPlayerName(issuerid, attackerName, sizeof (attackerName));
        GetWeaponName(weaponid, weaponName, sizeof (weaponName));
        shot[playerid]++;
        if(IsHurt[playerid] == 0)
        {
            new string[64];
            format(string,sizeof(string),"(( Has been injured %d times, Weapon: %s ))", shot[playerid], weaponName);
            new Text3D:wounded;
            wounded = Create3DTextLabel(string, 0xAA3333AA, 30.0, 40.0, 50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(wounded, playerid, 0.0, 0.0, 0.7);
            Update3DTextLabelText(wounded, 0xAA3333AA, string);
        }
    }
    return 1;
}



Re: Damage system help! - TheSnicky - 14.08.2014

Now it says "Has been injured 0.0000 times"


Re: Damage system help! - TheSnicky - 14.08.2014

Someone please help!! :P


Respuesta: Damage system help! - Cepillado - 14.08.2014

Can you show us how you added it?


Re: Respuesta: Damage system help! - TheSnicky - 14.08.2014

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
{
new
weaponName[24],
victimName[MAX_PLAYER_NAME],
attackerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, victimName, sizeof (victimName));
GetPlayerName(issuerid, attackerName, sizeof (attackerName));
GetWeaponName(weaponid, weaponName, sizeof (weaponName));
shot[playerid] ++;
if (IsHurt[playerid] == 0)
{
new string[64];
format(string,sizeof(string),"(( Has been injured %d , Weapon: %s ))", shot[playerid], weaponName);
new Text3D:wounded;
wounded = Create3DTextLabel(string, 0xAA3333AA, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(wounded, playerid, 0.0, 0.0, 0.7);
Update3DTextLabelText(wounded, 0xAA3333AA, string);
}
}
return 1;
}


Re: Damage system help! - TheSnicky - 14.08.2014

Do I have to add it on OnPlayerTakeDamage, because I didn't add it on there?