Derpy Posted October 18, 2014 Share Posted October 18, 2014 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
Anubhav Posted October 18, 2014 Share Posted October 18, 2014 (edited) if adminList[1][1] == getPlayerSerial(element) then -- Edited October 19, 2014 by Guest Link to comment
DNL291 Posted October 19, 2014 Share Posted October 19, 2014 local adminList = { ["1C2F2D1B38C02ACAE922426CAFF701F3"] = true, ["BB324608511608C41E9D94A3D4E7F742"] = true } if adminList[getPlayerSerial(thePlayer)]then end I think that didn't understand what you want to do. Link to comment
Derpy Posted October 19, 2014 Author Share Posted October 19, 2014 both methods dont work.. Link to comment
#DRAGON!FIRE Posted October 19, 2014 Share Posted October 19, 2014 Client Side .. : local adminList = { [ "Serial" ] = true, [ "Serial"] = true, } if ( adminList [ getPlayerSerial ( ) ] ) then Link to comment
crismar Posted October 19, 2014 Share Posted October 19, 2014 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
Anubhav Posted October 19, 2014 Share Posted October 19, 2014 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
Saml1er Posted October 19, 2014 Share Posted October 19, 2014 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
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