Klesh Posted June 25, 2011 Share Posted June 25, 2011 Hi to everyone, im doing a health script and this shows the health of the player on the scoreboard but some code is wrong and is not showing, here is the code: Server-Side: addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() exports.scoreboard:addScoreboardColumn("Health") end) function scoreboardHealthUpdate(a,b,c) if getElementType(source) == "player" then player = source elseif getElementHealth(source) == "player" then player = getElementHealth(source) end if player and player then local damage = 0 if not b and not c then damage = a end local health = math.floor((getElementHealth(player)-250-damage)/750*100) setElementData(player, "Health", health.."%") elseif player then setElementData(player, "Health", "---") end end addEventHandler("onPlayerDamage", getRootElement(), scoreboardHealthUpdate) addEventHandler("onPlayerSpawn", getRootElement(), scoreboardHealthUpdate) addEventHandler("onPlayerLogin", getRootElement(), scoreboardHealthUpdate) addEventHandler("onPlayerWasted", getRootElement(), scoreboardHealthUpdate) Link to comment
Castillo Posted June 25, 2011 Share Posted June 25, 2011 I don't know why you do all that, it's useless. addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() exports.scoreboard:addScoreboardColumn("Health") end) function scoreboardHealthUpdate() if source and getElementType(source) == "player" then local health = math.floor(getElementHealth(source)) setElementData(source, "Health", health.."%") end end addEventHandler("onPlayerDamage", getRootElement(), scoreboardHealthUpdate) addEventHandler("onPlayerSpawn", getRootElement(), scoreboardHealthUpdate) addEventHandler("onPlayerLogin", getRootElement(), scoreboardHealthUpdate) addEventHandler("onPlayerWasted", getRootElement(), scoreboardHealthUpdate) Link to comment
Klesh Posted June 25, 2011 Author Share Posted June 25, 2011 Yes but is not useless, im making a complete server as you can see, but will be Freeroam like yours. "UFS" Link to comment
Castillo Posted June 25, 2011 Share Posted June 25, 2011 And what has that to do with this? I tested this in a freeroam server and works fine. Link to comment
Klesh Posted June 25, 2011 Author Share Posted June 25, 2011 Its only in-game the health player have and to know if this is hack or not: Example: I kill someone with Hunter or grenades but i cant see the player with that you see the player health. Link to comment
Castillo Posted June 25, 2011 Share Posted June 25, 2011 Well...... then use the code I posted, it works fine. Link to comment
JR10 Posted June 25, 2011 Share Posted June 25, 2011 Its only in-game the health player have and to know if this is hack or not:Example: I kill someone with Hunter or grenades but i cant see the player with that you see the player health. he is not talking about that your function had useless things, i think. Link to comment
Klesh Posted June 25, 2011 Author Share Posted June 25, 2011 Yes works fine, thanks a lot castillo and my error was here: if player and player then local damage = 0 if not b and not c then damage = a end local health = math.floor((getElementHealth(player)-250-damage)/750*100) setElementData(player, "Health", health.."%") elseif player then setElementData(player, "Health", "---") end end The Fix: function scoreboardHealthUpdate() if source and getElementType(source) == "player" then local health = math.floor(getElementHealth(source)) setElementData(source, "Health", health.."%") end end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now