Add HP + Armor
#1

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);
Reply
#2

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);
Reply
#3

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)