MRThinker Posted September 22, 2018 Share Posted September 22, 2018 hi guys! what is my problem ? function getOnlineAdmins() local t = {} for k,v in ipairs ( getElementsByType("player") ) do while true do local acc = getElementData(v,"esmeAcc") if not acc then break end local isAdmin = getElementData(acc,"staff") if isAdmin == true then table.insert(t,v) end break end end return t end Link to comment
N3xT Posted September 23, 2018 Share Posted September 23, 2018 https://wiki.multitheftauto.com/wiki/GetOnlineAdmins Link to comment
MRThinker Posted September 23, 2018 Author Share Posted September 23, 2018 1 hour ago, N3xT said: https://wiki.multitheftauto.com/wiki/GetOnlineAdmins no! im not work with Admin ACL im working with ElementData example : setElementData(thePlayer,"staff,10) 10 is Server Owner plz fix my code with ElementData Link to comment
Trefeor Posted September 23, 2018 Share Posted September 23, 2018 function getAdminsOnline () local tbl = { } for k,v in ipairs ( getElementsByType ( "player" ) ) do if ( getElementData ( v , "staff" ) ) then table.insert ( tbl , v ) end end return tbl end -- example addCommandHandler("getAdmins", function(player) for k,v in ipairs ( getAdminsOnline() ) do outputChatBox(k.."- "..getPlayerName(v),player) end end ) 1 Link to comment
iMr.WiFi..! Posted September 23, 2018 Share Posted September 23, 2018 Usefull function: --- By iMr.Wifi..! function getElementsFromData( DataName, ElementType, Value ) Elements = { } assert( type( DataName ) == 'string', " Bad Argument @1 ' Not String ' ") assert( ElementType == 'player' or ElementType == 'ped' or ElementType == 'marker' or ElementType == 'vehicle' , " Bad Argument @2 ' Not Element ' ") local ElementType = ElementType or { 'player', 'ped', 'marker', 'vehicle' } local Value = Value or nil if type ( ElementType ) ~= "table" then for i,v in ipairs ( getElementsByType ( ElementType ) ) do if Value == nil then if getElementData ( v, DataName ) ~= nil then table["insert"]( Elements, v ) end else if getElementData ( v, DataName ) == Value then table["insert"]( Elements, v ) end end end else for k,z in ipairs ( ElementType ) do for i,v in ipairs ( getElementsByType ( z ) ) do if Value == nil then if getElementData ( v, DataName ) ~= nil then table["insert"]( Elements, v ) end else if getElementData ( v, DataName ) == Value then table["insert"]( Elements, v ) end end end end end return Elements; end addCommandHandler("getAdmins", function(player) for k,v in ipairs ( getElementsFromData("esmeAcc","player") ) do for i, admin in ipairs( getElementsFromData( "staff", "player" ) ) do outputChatBox( i .. "- ".. getPlayerName(admin), player ) end end end ) 1 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