Hi,
when i´m adding two hooks to the "player_disconnect" gameevent with gameevent.Listen("player_disconnect") it calls only one of it.
hook.Add("player_disconnect","AS_server_disconnect_handlerf", function(data)
print("1")
end)
hook.Add("player_disconnect","AS_server_disconnect_handler", function(data)
print("2")
end)
When i do lua_run PrintTable(hook.GetTable()) i get:
player_disconnect:
AS_server_disconnect_handlerf = function: whatever
AS_server_disconnect_handler = function: whatever
When i disconnect only the handlerf hook gets called.
1
Is there anything i can do about it?
I dont want to use the "player_disconnected" hook bcause it doesnt run when the last player
leaves :/
I can't replicate your results, both player_disconnect hooks are called correctly in all situations. Code:
hook.Add("PlayerDisconnected", "pd1", function(pPlayer)
print(string.format("PlayerDisconnected - %s", pPlayer:Nick()))
end)
gameevent.Listen("player_disconnect")
hook.Add("player_disconnect", "pd2", function(tData)
print(string.format("player_disconnect 1 - %s", tData.name))
end)
hook.Add("player_disconnect", "pd3", function(tData)
print(string.format("player_disconnect 2 - %s", tData.name))
end)
Single-player:
https://i.imgur.com/kFVR5cS.png
Listen server:
https://i.imgur.com/1UnV5GE.png
Dedicated server:
https://i.imgur.com/EqRmtEe.png
Make sure none of your or any other player_disconnect HOOKS are returning a value. As soon as you return a value ( any non-nil value ), any subsequent hooks will cease to work.
He posted his hook.GetTable which has no other hooks.
Thanks for testing it out!
I´m sorry but i forgot to add hook.Remove in my hook.
As i found out, it only happens when i add an hook.Remove in
the hook to remove itself. It removes only itself and not the one that should
run right after it.
And the strange thing is that it only happens with the player_disconnect hook.
-player_disconnect hook
Code:
gameevent.Listen("player_disconnect")
hook.Add("player_disconnect", "AS_OnDisconnectf_STEAM_0:0:50938724", function(tData)
print(string.format("player_disconnect 1 - %s", tData.name))
hook.Remove("player_disconnect", "AS_OnDisconnectf_STEAM_0:0:50938724")
print("hook.remove done")
end)
hook.Add("player_disconnect", "AS_server_disconnect_handler", function(tData)
print(string.format("player_disconnect 2 - %s", tData.name))
end)
Hook table:
player_disconnect:
AS_OnDisconnectf_STEAM_0:0:50938724 = function: 0x038b5960
AS_server_disconnect_handler = function: 0x2913fbd0
Output:
player_disconnect 1 - sadfroger
hook.remove done
-PlayerDeath hook
hook.Add("PlayerDeath", "AS_OnDisconnectf_STEAM_0:0:50938724", function(tData)
print(string.format("PlayerDeath 1 - %s", tData.name))
hook.Remove("player_disconnect", "AS_OnDisconnectf_STEAM_0:0:50938724")
print("hook.remove done")
end)
hook.Add("PlayerDeath", "AS_server_disconnect_handler", function(tData)
print(string.format("PlayerDeath 2 - %s", tData.name))
//override=hook.Run("AS_server_disconnect_ov","test","test")
end)
Hook table:
PlayerDeath:
AS_OnDisconnectf_STEAM_0:0:50938724 = function: 0x2ea4f840
AS_server_disconnect_handler = function: 0x034127b0
Output:
PlayerDeath 1 - nil
hook.remove done
PlayerDeath 2 - nil
Could this be a glua bug?
Sorry, you need to Log In to post a reply to this thread.