golanu21 Posted March 2, 2013 Posted March 2, 2013 exports.scoreboard:scoreboardAddColumn( "WantedLv" ) function getwan() local players = getElementsByType ( "player" ) for theKey,source in ipairs(players) do local wanted = getPlayerWantedLevel(source) local zero = "" local one = "*" local two = "**" local three = "***" local four = "****" local five = "*****" local six = "******" if wanted == 0 then setElementData ( source, "Wanted", zero ) else if wanted == 1 then setElementData ( source, "Wanted", one ) else if wanted == 2 then setElementData ( source, "Wanted", two ) else if wanted == 3 then setElementData ( source, "Wanted", three ) else if wanted == 4 then setElementData ( source, "Wanted", four ) else if wanted == 5 then setElementData ( source, "Wanted", five ) else if wanted == 6 then setElementData ( source, "Wanted", six ) end end end end end end end end end setTimer(getwan,100,0) addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), getwan ) the column appear in the scoreboard, but when i have wanted level > 0 the stars (**) not appear [Dev]BloWnRPG - We BloW the World [1%]
csiguusz Posted March 2, 2013 Posted March 2, 2013 Use "WantedLv" for set element data instead of "Wanted". setElementData ( source, "WantedLv", zero ) Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003
golanu21 Posted March 2, 2013 Author Posted March 2, 2013 oo thanx .. i am noob ) [Dev]BloWnRPG - We BloW the World [1%]
csiguusz Posted March 2, 2013 Posted March 2, 2013 You are welcome. Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003
Anderl Posted March 2, 2013 Posted March 2, 2013 (edited) Easier way: exports[ "scoreboard" ]:scoreboardAddColumn ( "WantedLv" ); local lastTick = getTickCount(); function SetWantedLevel() if ( eventName == "onClientRender" ) then if ( ( getTickCount() - lastTick ) < 500 ) then return end lastTick = getTickCount(); end for index, value in ipairs ( getElementsByType "player" ) do local wantedLevel = ( "*" ):rep ( getPlayerWantedLevel ( value ) ); setElementData ( value, "WantedLv", wantedLevel ); end end addEventHandler ( "onResourceStart", resourceRoot, SetWantedLevel ); addEventHandler ( "onClientRender", root, SetWantedLevel ); There might be a problem with time counting, I'm not awesome with maths. If someone finds any error in my code, please let me know. Edited March 2, 2013 by Guest "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
csiguusz Posted March 2, 2013 Posted March 2, 2013 getTickCount() will always be a bigger number than lastTick, won't it? So it will be always smaller than 500. Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003
Anderl Posted March 2, 2013 Posted March 2, 2013 From what I know, "start tick + getTickCount = time passed", am I wrong? Also, getTickCount should start counting from 0, shouldn't it? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
csiguusz Posted March 2, 2013 Posted March 2, 2013 Yeah, I also know it so. But lastTick is a tick count in the past, and getTickCount() will return the current tick count wich will be bigger than lastTick I think. If I'm right then "if ( lastTick - getTickCount() < 500 ) then" doesn't have much sense. Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003
Anderl Posted March 2, 2013 Posted March 2, 2013 Nevermind, I forgot completely what getTickCount actually returned. Took a look at wiki's page, will fix the code. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
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