Hello,
I am currently learning LUA and I am having a lot of difficulty with a code I am making by myself.
The code modifies an [B]admin report system[/B] that so [B]if there is an admin currently on the server, then the report will not be sent.
[/B]I put in about 3 hours trying to figure this out by myself (trying to learn) but I just can't do it. It's just too complex.
Here is the code I currently am working on.
Please keep in mind this is the most recently altered version so there will be lots of ignorant mistakes.
[CODE]
for k, v in pairs(player.GetAll()) do if v:IsAdmin() or v:IsSuperAdmin()
then
adminfound = true
end
if adminfound == true then
net.Receive("SEND_REPORTS", function()
local id = net.ReadString()
table.insert(report_table, net.ReadTable() )
table.sort(report_table, function(a, b) return tonumber(a.STATUS) < tonumber(b.STATUS) end)
--report_table[id] = net.ReadTable()
Got_Report_Data = true
end)
end
end
if adminfound == false then
PrintMessage(HUD_PRINTTALK, "An Admin Report has been Rejected - An Admin is currently online!" )
end
[/CODE]
This is the most advanced snippet I have worked on thus far and I know it's pitiful.
Any help in correcting this code would be greatly appreciated.
Thanks in advance!
[lua]net.Receive("SEND_REPORTS", function()
local adminfound = false
for k,v in pairs(player.GetAll()) do
if(v:IsAdmin() or v:IsSuperAdmin()) then
adminfound = true
break
end
end
if not(adminfound) then
local id = net.ReadString()
table.insert(report_table, net.ReadTable() )
table.sort(report_table, function(a, b) return tonumber(a.STATUS) < tonumber(b.STATUS) end)
--report_table[id] = net.ReadTable()
Got_Report_Data = true
else
PrintMessage(HUD_PRINTTALK, "An Admin Report has been Rejected - An Admin is currently online!")
end
end)[/lua]
that's about as much as I can do without more context
Thank you so much!
The code works, however it seems as if whenever an admin ISN'T on the server there is spam of the PrintMessage.
I'm assuming you may need more context to the code in which this lies so here it is:
[url]http://pastebin.com/JU1s3B78[/url]
I will be away from the computer until later today so excuse me if I don't respond.
Sorry, you need to Log In to post a reply to this thread.