E-mail Posted September 6, 2011 Share Posted September 6, 2011 Hi all i need to add scorebord cloun [Exp] and every exp update play sound levelup.mp3 1.function rewardOnWasted ( killer ) 2.local exp = getElementData(killer,"exp") 3.if exp then 4.setElementData(killer,"exp",tonumber(getElementData(killer,"exp"))+5) 5.outputChatBox("Experience gained +5! total ".. tonumber(exp)+5,killer,0,255,0) 6.else 7.setElementData(killer,"exp",5) 8. end 9.end 10.addEvent("onPlayerWasted",true) 11.addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) Link to comment
JR10 Posted September 6, 2011 Share Posted September 6, 2011 client: addEvent ( "playSound" , true ) addEventHandler ( "playSound" , root , function() playSound ( "levelup.mp3" , false ) end) server: function rewardOnWasted ( killer ) local exp = getElementData(killer,"exp") if exp then setElementData(killer,"exp",tonumber(getElementData(killer,"exp"))+5) outputChatBox("Experience gained +5! total ".. tonumber(exp)+5,killer,0,255,0) triggerClientEvent ( killer , "playSound" , killer ) else setElementData(killer,"exp",5) triggerClientEvent ( killer , "playSound" , killer ) end end addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) Can't you try something yourself first? And why are you adding onPlayerWasted. It exists already. Link to comment
E-mail Posted September 6, 2011 Author Share Posted September 6, 2011 Thx For Help JR10 but where is addscorebordCloum exp ? Link to comment
Castillo Posted September 6, 2011 Share Posted September 6, 2011 Is that hard to type this: exports.scoreboard:addScoreboardColumn("exp") ? Link to comment
E-mail Posted September 6, 2011 Author Share Posted September 6, 2011 Like This ? function rewardOnWasted ( killer ) local exp = getElementData(killer,"exp") if exp then setElementData(killer,"exp",tonumber(getElementData(killer,"exp"))+3) outputChatBox("Experience gained +3! total ".. tonumber(exp)+5,killer,255,255,0) triggerClientEvent ( killer , "playSound" , killer ) else setElementData(killer,"exp",3) triggerClientEvent ( killer , "playSound" , killer ) exports.scoreboard:addScoreboardColumn("exp") end end addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) Link to comment
JR10 Posted September 6, 2011 Share Posted September 6, 2011 No, this way you will add it on every kill. Add it on resource start. Link to comment
E-mail Posted September 6, 2011 Author Share Posted September 6, 2011 JR10 Sorry I made you tire me see function rewardOnWasted ( killer ) local exp = getElementData(killer,"exp") if exp then setElementData(killer,"exp",tonumber(getElementData(killer,"exp"))+5) outputChatBox("Experience gained +5! total ".. tonumber(exp)+5,killer,255,255,0) triggerClientEvent ( killer , "playSound" , killer ) else setElementData(killer,"exp",5) triggerClientEvent ( killer , "playSound" , killer ) exports.scoreboard:addScoreboardColumn("exp") end end addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) By the way you and soldSnake14 are the Best best assistants in in section Link to comment
JR10 Posted September 6, 2011 Share Posted September 6, 2011 function rewardOnWasted ( killer ) local exp = getElementData(killer,"exp") if exp then setElementData(killer,"exp",tonumber(getElementData(killer,"exp"))+5) outputChatBox("Experience gained +5! total ".. tonumber(exp)+5,killer,255,255,0) triggerClientEvent ( killer , "playSound" , killer ) else setElementData(killer,"exp",5) triggerClientEvent ( killer , "playSound" , killer ) end end addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) addEventHandler("onResourceStart" , resourceRoot , function() exports.scoreboard:addScoreboardColumn("exp") end) I told you to add it on resource start. Link to comment
Castillo Posted September 6, 2011 Share Posted September 6, 2011 addEventHandler("onResourceStart",resourceRoot, function () exports.scoreboard:addScoreboardColumn("exp") end) function rewardOnWasted ( killer ) local exp = getElementData(killer,"exp") if exp then setElementData(killer,"exp",tonumber(getElementData(killer,"exp"))+5) outputChatBox("Experience gained +5! total ".. tonumber(exp)+5,killer,255,255,0) triggerClientEvent ( killer , "playSound" , killer ) else setElementData(killer,"exp",5) triggerClientEvent ( killer , "playSound" , killer ) end end addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) 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