View Single Post
Th3822
Member
Join Date: Jan 2013
Location: Venezuela
Old 09-15-2019 , 19:14   Re: Player "not in-game" at Ham_Spawn (post) on lastest 1.9 but working on 1.8.2
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
Realize that AMX Mod X doesn't do much, if any, of this logic. For example, Ham_Spawn is a function in the actual game and AMX Mod X simply allows you to hook it. If the original developers of the game decided to use that function in ways that you don't expect, it's just something that you have to deal with. E.g. it has always been a necessity (afaik) to have an alive check in a Ham_Spawn hook.

I'm not sure why you think you wouldn't need an alive check in any version of AMX Mod X. Also, I didn't really understand why you are calling your Ham_Spawn post function at client_putinserver(). Ham_Spawn will occur when you spawn.

Also, you can't be alive is you are not yet in the server.
Players always spawns alive at PutInServer, but on cstrike gets switched to spec until teamselect, then CGameRules manages it's respawn. (That was a lot of links XD)

In HL there is no team/class select on connect, so you spawn directly at PutInServer as there is no need to defer the (alive) spawn...
But, on that first spawn (hooked with HAM), is_user_alive returns false because AMXX's PutInServer_Post hook (from meta) hasn't been called yet...
It's something a little bit like this issue.

So, i have 2 options for doing the stuff i need to do on that first spawn when is_user_alive (and _connected) are true and can run functions on the player:
  • Do the stuff on the player on the next hookable action ( that it's just client_putinserver(id) )
  • Detect the "first spawn" (!is_user_alive(id) && is_user_connecting(id)) at my hook and set a task for doing it "later"

The first one it's the best option, so that's why there is a call to the Spawn_Post hook at there.
Th3822 is offline