Georges1999 Posted March 17, 2018 Share Posted March 17, 2018 (edited) Hello guys, i need help with this script i made, it's not working as i expect it to. The thing is that i was adding an adminlogin on the ChatBox, whenever an admin login's a messages appears. But then i made a table so i add a command to all the admins that don't want that message to appear, i haven't mastered table yet, so i came here asking for help,and also Some hints so i can learn from it. Script: invisibleAdmins = {} function adminLoginCommand (player, commandName) if commandName == "invlogin" then if isObjectInACLGroup ("user." ..getAccountName( getPlayerAccount(player) ), aclGetGroup ("Admin"))then outputDebugString("Line 7") invisibleAdmins[getPlayerSerial(player)] = true outputDebugString("Working , true") if invisibleAdmins[getPlayerSerial(player)] then outputChatBox("[COB]System:You are now invisible!", player, 0, 0, 255) else outputChatBox("You are not invisible", player, 255,0,0) end if getPlayerSerial(player) == invisibleAdmins[getPlayerSerial(player)] then outputChatBox("You are already invisible", player, 255,0 ,0) end elseif isObjectInACLGroup ("user." ..getAccountName( getPlayerAccount(player) ), aclGetGroup ("Console"))then invisibleAdmins = invisibleAdmins[getPlayerSerial(player)] outputDebugString("Line 18") outputChatBox("[COB]System:You are now invisible!", player, 0, 0, 255) if getPlayerSerial(player) == invisibleAdmins[getPlayerSerial(player)] then outputChatBox("You are already invisible!", player, 255,0 ,0) end elseif isObjectInACLGroup ("user." ..getAccountName( getPlayerAccount(player) ), aclGetGroup ("SuperModerator"))then outputDebugString("Line 26") invisibleAdmins= invisibleAdmins[getPlayerSerial(player)] outputChatBox("[COB]System:You are now invisible!", player, 0, 0, 255) if getPlayerSerial(player) == invisibleAdmins[getPlayerSerial(player)] then outputChatBox("You are already invisible!", player, 255,0 ,0) end elseif isObjectInACLGroup ("user." ..getAccountName( getPlayerAccount(player) ), aclGetGroup ("Moderator"))then outputDebugString("Line 35") invisibleAdmins = invisibleAdmins[getPlayerSerial(player)] outputChatBox("[COB]System:You are now invisible!", player, 0, 0, 255) if getPlayerSerial(player) == invisibleAdmins[getPlayerSerial(player)] then outputChatBox("You are already invisible!", player, 255,0 ,0) end else outputChatBox("[COB]System: You cannot use this command!",player, 255, 0 ,0) end end end addCommandHandler("invlogin", adminLoginCommand) --{Admin}~> <username> logged in as <accountname> function alogin (_ ,theCurrentAccount) if isObjectInACLGroup ("user." ..getAccountName( theCurrentAccount ), aclGetGroup ("Admin"))then outputDebugString("Admin account.") if getPlayerSerial(source) ~= invisibleAdmins[1] then outputDebugString("Working fine, function 3") outputChatBox("{Dev}~> ".. getPlayerName(source).. " has logged in as ".. getAccountName( theCurrentAccount), root, 0, 255, 0 ,true) end elseif isObjectInACLGroup ("user." ..getAccountName( theCurrentAccount ), aclGetGroup ("Console"))then if getPlayerSerial(source) ~= invisibleAdmins[getPlayerSerial(source)] then outputChatBox("{Admin}~> ".. getPlayerName(source).. " has logged in as ".. getAccountName( theCurrentAccount), root, 255, 0, 0 ,true) end elseif isObjectInACLGroup ("user." ..getAccountName( theCurrentAccount ), aclGetGroup ("SuperModerator"))then if getPlayerSerial(source) ~= invisibleAdmins[getPlayerSerial(source)] then outputChatBox("{SuperModerator}~> ".. getPlayerName(source).. " has logged in as ".. getAccountName( theCurrentAccount), root, 255, 0, 0 ,true) end elseif isObjectInACLGroup ("user." ..getAccountName( theCurrentAccount ), aclGetGroup ("Moderator"))then if getPlayerSerial(source) ~= invisibleAdmins[getPlayerSerial(source)] then outputChatBox("{Mod}~> ".. getPlayerName(source).. " has logged in as ".. getAccountName( theCurrentAccount), root, 0, 0, 255 ,true) end end end addEventHandler("onPlayerLogin",root, alogin) Thanks in advance Edited March 17, 2018 by Georges1999 Link to comment
Moderators IIYAMA Posted March 18, 2018 Moderators Share Posted March 18, 2018 invisibleAdmins = {} iprint(invisibleAdmins) -- table (empty) Interaction with the table: invisibleAdmins[getPlayerSerial(player)] = true iprint(invisibleAdmins) -- table {["<serial>"] = true} After using this: invisibleAdmins = invisibleAdmins[getPlayerSerial(player)] iprint(invisibleAdmins) -- true You just deleted your table. (not good) Solution: local isInvisible = invisibleAdmins[getPlayerSerial(player)] iprint(invisibleAdmins) -- table {["<serial>"] = true} iprint(isInvisible) -- true 1 1 Link to comment
Georges1999 Posted March 18, 2018 Author Share Posted March 18, 2018 IIYAMA thank you for ur explanation. I did understand what u've done. You made a variable and u saved the table that contains a key with it. And u left the real table without touching it. If i am wrong correct me. 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