SA-MP Forums Archive
Add HP + Armor - 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: Add HP + Armor (/showthread.php?tid=361071)



Add HP + Armor - (_AcE_) - 19.07.2012

I am trying to get it to say:

Player 1 has killed Player 2 (Weapon: Deagle)(HP: 125) // TO ADD THE HP + ARMOUR TOGETHER TO GET 1 NUMBER

pawn Код:
GetWeaponName(reason,gunname,sizeof(gunname));
            GetPlayerName(playerid,fName,MAX_PLAYER_NAME);
            GetPlayerName(killerid,sName,MAX_PLAYER_NAME);
            format(string, sizeof(string), "** %s has killed %s (Weapon: %s)(HP: %0.f).", sName, fName, gunname, khp+kar);
            SendClientMessageToAll(TEAM_AWAY_COLOR,string);



Re: Add HP + Armor - Kindred - 19.07.2012

Did you already define the Health and Armour floats and get the variable? If not, here:
pawn Код:
new Float:khp, Float:kar;
GetPlayerHealth(playerid,khp);
GetPlayerArmour(playerid,kar);
GetWeaponName(reason,gunname,sizeof(gunname));
GetPlayerName(playerid,fName,MAX_PLAYER_NAME);
GetPlayerName(killerid,sName,MAX_PLAYER_NAME);
format(string, sizeof(string), "** %s has killed %s (Weapon: %s)(HP: %.0f).", sName, fName, gunname, khp+kar);
SendClientMessageToAll(TEAM_AWAY_COLOR,string);



Re: Add HP + Armor - blewert - 19.07.2012

Precision when using floats must be in the format "%.(precision)f", not "%(precision).f".

Try:

pawn Код:
GetWeaponName(reason,gunname,sizeof(gunname));
            GetPlayerName(playerid,fName,MAX_PLAYER_NAME);
            GetPlayerName(killerid,sName,MAX_PLAYER_NAME);
            format(string, sizeof(string), "** %s has killed %s (Weapon: %s)(HP: %.0f).", sName, fName, gunname, (khp+kar));
            SendClientMessageToAll(TEAM_AWAY_COLOR,string);