Raised This Month: $ Target: $400
 0% 

Solved Player "not in-game" at Ham_Spawn (post) on lastest 1.9 but working on 1.8.2


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Th3822
Member
Join Date: Jan 2013
Location: Venezuela
Old 09-12-2019 , 22:10   Re: Player "not in-game" at Ham_Spawn (post) on lastest 1.9 but working on 1.8.2
Reply With Quote #1

Quote:
Originally Posted by bad_boy View Post
That's why you are getting the error. E1_531G is correct.
PHP Code:
if( is_user_aliveid ) && is_spawn_valid(idfVector)) 
The player is indeed alive at that moment, but is_user_alive returns 0 because is_user_connected is also returning 0...
Anyways, i'll re-add the user alive check and the "solution" (it's more a workaround) that i got for that

---

I got my own answer after checking and rechecking things, and to notice it better i wrote a small plugin to get this output (on both versions):
PHP Code:
  client_connect(1) *
 * 
client_authorized(1) *
 * 
Ham_Player_Spawn_Pre(1) *
    * 
is_user_connecting(1): is_user_connected(1): *
    * 
pev_valid(1): is_user_alive(1): *
    * 
ExecuteHam(Ham_IsAlive1): entity_get_float(1EV_FL_health): 0.00 *
 * 
Ham_Player_Spawn_Post(1) *
    * 
is_user_connecting(1): is_user_connected(1): *
    * 
pev_valid(1): is_user_alive(1): *
    * 
ExecuteHam(Ham_IsAlive1): entity_get_float(1EV_FL_health): 100.00 *
 * 
client_putinserver(1) *
    * 
is_user_connecting(1): is_user_connected(1): *
    * 
pev_valid(1): is_user_alive(1): *
    * 
ExecuteHam(Ham_IsAlive1): entity_get_float(1EV_FL_health): 100.00 
AMXX doesn't consider the client fully connected until just before calling the client_putinserver forward... And... As is_user_alive also includes the is_user_connected check, it will return 0

I initially thought that it was an issue on 1.9, but on 1.8.2 lot's of engine functions didn't have safeguard checks for the entity, that's why it was working on 1.8.2.
So getting the error was the correct result, now i have to fix my plugin:

Re-adding the is_user_alive check that was commented on Ham_Player_Spawn_Post will make it work fine, but it won't be called "correctly" with the spawn when user joins, so as solution i will call the hook function on client_putinserver and that is all.

PHP Code:
public client_putinserver(id)
{
    
// Workaround for first spawn at join
    
Ham_Player_Spawn_Post(id);

Not all things works in the same way as cstrike plugins, i will mark the thread as solved.
Th3822 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-13-2019 , 21:28   Re: Player "not in-game" at Ham_Spawn (post) on lastest 1.9 but working on 1.8.2
Reply With Quote #2

Quote:
Originally Posted by Th3822 View Post
AMXX doesn't consider the client fully connected until just before calling the client_putinserver forward... And... As is_user_alive also includes the is_user_connected check, it will return 0

I initially thought that it was an issue on 1.9, but on 1.8.2 lot's of engine functions didn't have safeguard checks for the entity, that's why it was working on 1.8.2.
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.
__________________
fysiks is offline
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 #3

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
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode