Jump to content

[HELP] Online Admins


MRThinker

Recommended Posts

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
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 )

 

  • Thanks 1
Link to comment

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 )

 

  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...