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