Jump to content

help with table plz


Derpy

Recommended Posts

hi

i just got a this little table thing

adminList = { 
{"1C2F2D1B38C02ACAE922426CAFF701F3",3},  
{"BB324608511608C41E9D94A3D4E7F742",3},  
} 

and those are serials,yeah.

so if i want to get joining player's serial how would i do it?

how could i check all table values of serials without looping and then if they are compared and same as other player's serial then it does something?

i think it would need to be accessed like this but i dont know

  
if adminList[idk-what-to-put-here] == getPlayerSerial(element) then 
-- 

please help

Link to comment
  
local adminList = { 
{"SERIAL_ONE", 69}, 
{"SERIAL_TWO", 69} 
} 
  
function isAdminInList() 
for i, v in ipairs(getElementsByType("player")) do 
local serial = getPlayerSerial(v) 
for k, d in ipairs(adminList) do 
if d[1] == serial then 
outputChatBox(getPlayerName(v).." | Level: "..d[2], root, 255, 0, 0) 
end 
end 
end 
end 
  
isAdminInList() 
  

Try it, server sided obviously.

Link to comment
  
local adminList = { 
{"SERIAL_ONE", 69}, 
{"SERIAL_TWO", 69} 
} 
  
function isAdminInList() 
for i, v in ipairs(getElementsByType("player")) do 
local serial = getPlayerSerial(v) 
for k, d in ipairs(adminList) do 
if d[1] == serial then 
outputChatBox(getPlayerName(v).." | Level: "..d[2], root, 255, 0, 0) 
end 
end 
end 
end 
  
isAdminInList() 
  

Try it, server sided obviously.

I used the same method

Link to comment

DNL's code is correct. You don't need a loop for checking string keys. I modified his code a bit.

  
  
local adminList = { 
    ["1C2F2D1B38C02ACAE922426CAFF701F3"] = 3,-- if you don't need those numbers then replace them with true 
    ["BB324608511608C41E9D94A3D4E7F742"] = 3 
} 
addEventHandler("onPlayerJoin",root,function() 
if adminList[getPlayerSerial(source)] then  
-- Now do your stuff here 
end 
    end) 

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