Wei Posted April 27, 2012 Posted April 27, 2012 local pGroup; call ( getResourceFromName ( 'scoreboard' ), 'addScoreboardColumn', 'Group' ); function addRoleToScoreboard() local data = getElementData(source, "role") if data == police then pGroup = "Police Officer"; end setElementData ( source, 'Group', pGroup ); end addEventHandler("onClientRender", root, addRoleToScoreboard) no errors in debug. Problem: it doesn't show the group Diet with russian vodka, lose 3 days in one week !
arezu Posted April 27, 2012 Posted April 27, 2012 if there are no errors, then you should debug it yourself like this: local pGroup; call ( getResourceFromName ( 'scoreboard' ), 'addScoreboardColumn', 'Group' ); function addRoleToScoreboard() local data = getElementData(source, "role") dxDrawText("data: "..tostring(data), 500, 300) dxDrawText("police: "..tostring(police), 500, 350) if data == police then dxDrawText("data == police", 500, 400) pGroup = "Police Officer"; end dxDrawText("pGroup: "..tostring(pGroup), 500, 450) setElementData ( source, 'Group', pGroup ); end addEventHandler("onClientRender", root, addRoleToScoreboard)
Wei Posted April 28, 2012 Author Posted April 28, 2012 Sorry idk how to use this... Diet with russian vodka, lose 3 days in one week !
Wei Posted April 28, 2012 Author Posted April 28, 2012 now i've remaded the code: setTimer( function () call ( getResourceFromName ( 'scoreboard' ), 'addScoreboardColumn', 'Group' ); local role = getElementData(sourcePlayer,'role') if role == tostring(police) then setElementData ( sourcePlayer, 'Group','Police'); end end ,5000,0) naz helped me. Whats the problem here ? ERROR: [2012-04-28 21:42:21] WARNING: testing\server.lua:5: Bad argument @ 'getElementData' [Expected element at argument 1, got nil] Diet with russian vodka, lose 3 days in one week !
Castillo Posted April 28, 2012 Posted April 28, 2012 'sourcePlayer' is not defined there. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Wei Posted April 29, 2012 Author Posted April 29, 2012 still same Diet with russian vodka, lose 3 days in one week !
Castillo Posted April 29, 2012 Posted April 29, 2012 I guess "police" variable is defined, right? call ( getResourceFromName ( 'scoreboard' ), 'addScoreboardColumn', 'Group' ) setTimer ( function ( ) for index, player in ipairs ( getElementsByType ( "player" ) ) do local role = getElementData ( player, 'role' ) if ( role == tostring ( police ) ) then setElementData ( player, 'Group', 'Police' ) end end end ,5000, 0 ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Michael# Posted April 29, 2012 Posted April 29, 2012 I think you can simplify all to: exports [ 'scoreboard' ]:addScoreboardColumn ( 'Group' ) setTimer ( function ( ) for _, player in ipairs ( getElementsByType 'player' ) do local data = getElementData ( player, 'role' ) setElementData ( player, 'Group', tostring ( data ) == tostring ( police ) and 'Police' or nil ) end end, 5000, 0 ) If don't work, show us what is "police" variable.
Kenix Posted April 29, 2012 Posted April 29, 2012 exports [ 'scoreboard' ]:addScoreboardColumn 'Group' setTimer ( function ( sPolice ) for _, pPlayer in ipairs ( getElementsByType 'player' ) do setElementData ( pPlayer, 'Group', tostring ( getElementData ( pPlayer, 'role' ) ) == tostring ( sPolice ) and 'Police' ) end end, 5000, 0, police ) Blazy your variable 'police' is defined? http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Wei Posted April 29, 2012 Author Posted April 29, 2012 Thank both. Both of you are my life savers !! Diet with russian vodka, lose 3 days in one week !
Kenix Posted April 29, 2012 Posted April 29, 2012 No problem. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
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