Damage system help!
#1

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!
Reply
#2

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

How do I make it like I want it ?
Reply
#4

Maybe you could make something like

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

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

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;
}
Reply
#6

Now it says "Has been injured 0.0000 times"
Reply
#7

Someone please help!! :P
Reply
#8

Can you show us how you added it?
Reply
#9

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;
}
Reply
#10

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


Forum Jump:


Users browsing this thread: 2 Guest(s)