Hello,
I am currently trying to just print a simple console message (Might change it later) of when an Admin leaves it prints a message in the server console.
for some reason I get
[code]
[ERROR] lua/autorun/admin_disconnect.lua:49: attempt to index global 'ply' (a nil value)
1. fn - lua/autorun/admin_disconnect.lua:49
2. unknown - addons/ulib/lua/ulib/shared/hook.lua:183
[/code]
Heres the code:
[code]
function AdminLeave( )
if ply:IsAdmin() then
print( "An Admin has left" )
end
end
hook.Add( "PlayerDisconnected", "playerDisconnected", AdminLeave )
[/code]
Thanks!
You've got 'pl' in the function and then player before IsAdmin
change if player:IsAdmin() then
to if pl:IsAdmin() then
note: this will only print an admin has left to the admin that left not everyone on the server.
edit, ninja'd
Yes sorry. This was an old bit of code, I have updated it to the current code
You still have to change ply:IsAdmin() to pl:IsAdmin() since you havea pl in your function
[QUOTE=Invule;46050446]change if player:IsAdmin() then
to if pl:IsAdmin() then
note: this will only print an admin has left to the admin that left not everyone on the server.
edit, ninja'd[/QUOTE]
[code]
[ERROR] lua/autorun/admin_disconnect.lua:49: attempt to index global 'pl' (a nil value)
1. fn - lua/autorun/admin_disconnect.lua:49
2. unknown - addons/ulib/lua/ulib/shared/hook.lua:183
[/code]
[QUOTE=DerfStew;46050488][code]
[ERROR] lua/autorun/admin_disconnect.lua:49: attempt to index global 'pl' (a nil value)
1. fn - lua/autorun/admin_disconnect.lua:49
2. unknown - addons/ulib/lua/ulib/shared/hook.lua:183
[/code][/QUOTE]
ok so now you changed, function AdminLeave(pl ) to AdminLeave()
put pl back in the function like this
function AdminLeave(pl)
if pl:IsAdmin() then
[QUOTE=Invule;46050499]ok so now you changed, function AdminLeave(pl ) to AdminLeave()
put pl back in the function like this
function AdminLeave(pl)
if pl:IsAdmin() then[/QUOTE]
[code]
function AdminLeave(pl)
if pl:IsAdmin() then
print( "An Admin has left" )
end
end
hook.Add( "PlayerDisconnected", "playerDisconnected", AdminLeave )
[/code]
No errors, and no Print function
[editline]23rd September 2014[/editline]
SOLVED
WASN'T ADMIN ON SERVER. Thanks Invule
Sorry, you need to Log In to post a reply to this thread.