Closed pizzahut2 closed 3 years ago
I assumed it's an AMXX issue because it worked fine with previous versions. I appreciate a work-around if it's down to a bug in FoxBot, though in this case I'll ask the FoxBot maintainer if he has an idea.
Well I'm not too sure but Jeefo from Bots-United helped on FoxBot by removing that performance bugs and to use less CPU last year for FoxBot 0.793
Ok. I see. Definitely. So, basically it's not amxmodx issue. But we will fix it. Whatever.
Could you please add an explanation of the issue here so that there is a record of it, and so there is some guidance for what changes need to be made.
because as we all know spawn could be called once before connection.
I don't think that is at all obvious.
FWIW, SourceMod does a bunch of work with bots to make sure plugins see things happen in the same order as if they were regular players - I think the same would make sense here. Plugins shouldn't have to care about handling bots explicitly if they don't want to.
Indeed I thought a player is connected when the HUD gets reset. I realise he could still be spectating due to the "register_event" bug with the "alive" flag. It worked fine though before updating, and after reverting to 1.9, it immediately worked again (and no further errors in the AMXX logs).
The problem was that the bots didn't change model at all, not when actually spawning or when respawning after death. Not sure why.
It's always failing the is_user_alive test on AMXX v1.10 build 5414. I have added some debugging code.
I did compile with AMXX 1.9, is this ok? I wanted the ".amxx" to be compatible with both 1.9 and 1.10.
Result with AMXX v1.10 build 5414:
Creating bot... ResetHUD/be for player 1 - not actually alive ResetHUD/b for player 1 ResetHUD/b for player 1 ResetHUD/be for player 1 - not actually alive ResetHUD/b for player 1
Result with AMXX 1.9 build 5271:
Creating bot... ResetHUD/be for player 1 - not actually alive ResetHUD/b for player 1 ResetHUD/b for player 1 ResetHUD/be for player 1 - is really alive ResetHUD/b for player 1
#include <amxmodx>
#include <engine>
#include <tfcx>
#define PLUGIN "TF2 player models"
#define AUTHOR "pizzahut"
#define VERSION "1.1"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("ResetHUD", "player_spawned", "be")
register_event("ResetHUD", "player_spawn_test", "b")
}
public plugin_precache()
{
precache_model("models/player/tf2_scout/tf2_scout.mdl")
precache_model("models/player/tf2_sniper/tf2_sniper.mdl")
precache_model("models/player/tf2_soldier/tf2_soldier.mdl")
precache_model("models/player/tf2_demo/tf2_demo.mdl")
precache_model("models/player/tf2_medic/tf2_medic.mdl")
precache_model("models/player/tf2_hvyweapon/tf2_hvyweapon.mdl")
precache_model("models/player/tf2_pyro/tf2_pyro.mdl")
precache_model("models/player/tf2_spy/tf2_spy.mdl")
precache_model("models/player/tf2_engineer/tf2_engineer.mdl")
}
public player_spawned(id)
{
if (!is_user_alive(id))
{
server_print("ResetHUD/be for player %d - not actually alive",id)
return
}
server_print("ResetHUD/be for player %d - is really alive",id)
switch(entity_get_int(id, EV_INT_playerclass))
{
case TFC_PC_SCOUT: tfc_setmodel(id, "tf2_scout", "")
case TFC_PC_SNIPER: tfc_setmodel(id, "tf2_sniper", "")
case TFC_PC_SOLDIER : tfc_setmodel(id, "tf2_soldier", "")
case TFC_PC_DEMOMAN: tfc_setmodel(id, "tf2_demo", "")
case TFC_PC_MEDIC: tfc_setmodel(id, "tf2_medic", "")
case TFC_PC_HWGUY: tfc_setmodel(id, "tf2_hvyweapon", "")
case TFC_PC_PYRO: tfc_setmodel(id, "tf2_pyro", "")
case TFC_PC_SPY: tfc_setmodel(id, "tf2_spy", "")
case TFC_PC_ENGINEER: tfc_setmodel(id, "tf2_engineer", "")
}
}
public player_spawn_test(id)
{
server_print("ResetHUD/b for player %d",id)
}
bot addbot Client 1 is connecting Creating bot... Client 1 is connecting ResetHUD/b for player 1 - connected, dead ResetHUD/b for player 1 - connected, dead Client 1 is connecting ResetHUD/b for player 1 - connected, dead Client 1 is connecting
#include <amxmodx>
#include <engine>
#include <tfcx>
#define PLUGIN "TF2 player models"
#define AUTHOR "pizzahut"
#define VERSION "1.2"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("ResetHUD", "event_ResetHUD", "b")
}
public client_putinserver(id) server_print("Client %d connected", id)
public client_connect(id) server_print("Client %d is connecting", id)
public client_disconnected(id) server_print("Client %d disconnected", id)
public event_ResetHUD(id)
{
if (!is_user_alive(id))
{
if (is_user_connected(id))
server_print("ResetHUD/b for player %d - connected, dead",id)
else
server_print("ResetHUD/b for player %d - not connected",id)
return
}
server_print("ResetHUD/b for player %d - connected, alive",id)
switch(entity_get_int(id, EV_INT_playerclass))
{
case TFC_PC_SCOUT: tfc_setmodel(id, "tf2_scout", "")
case TFC_PC_SNIPER: tfc_setmodel(id, "tf2_sniper", "")
case TFC_PC_SOLDIER : tfc_setmodel(id, "tf2_soldier", "")
case TFC_PC_DEMOMAN: tfc_setmodel(id, "tf2_demo", "")
case TFC_PC_MEDIC: tfc_setmodel(id, "tf2_medic", "")
case TFC_PC_HWGUY: tfc_setmodel(id, "tf2_hvyweapon", "")
case TFC_PC_PYRO: tfc_setmodel(id, "tf2_pyro", "")
case TFC_PC_SPY: tfc_setmodel(id, "tf2_spy", "")
case TFC_PC_ENGINEER: tfc_setmodel(id, "tf2_engineer", "")
}
}
public plugin_precache()
{
precache_model("models/player/tf2_scout/tf2_scout.mdl")
precache_model("models/player/tf2_sniper/tf2_sniper.mdl")
precache_model("models/player/tf2_soldier/tf2_soldier.mdl")
precache_model("models/player/tf2_demo/tf2_demo.mdl")
precache_model("models/player/tf2_medic/tf2_medic.mdl")
precache_model("models/player/tf2_hvyweapon/tf2_hvyweapon.mdl")
precache_model("models/player/tf2_pyro/tf2_pyro.mdl")
precache_model("models/player/tf2_spy/tf2_spy.mdl")
precache_model("models/player/tf2_engineer/tf2_engineer.mdl")
}
Just for comparison, human player:
Client 1 is connecting Client 1 connected ResetHUD/b for player 1 - connected, dead ResetHUD/b for player 1 - connected, alive Client 1 disconnected Dropped pizzahut.SoK from server Reason: Client sent 'drop'
The fixed FoxBot works with "old" build 5414.
Client 1 is connecting (connect)
Creating bot...
Client 1 connected (putinserver)
Client 1 ResetHUD alive:no connected:yes connected_ex:yes
L 03/12/2021 - 20:06:12: "Lance<1>
#include <amxmodx>
#include <engine>
#include <tfcx>
public plugin_init()
{
register_plugin("TF2 player models", "1.3", "pizzahut")
register_event("ResetHUD", "event_ResetHUD", "b")
}
public client_connect(id) server_print("Client %d is connecting (connect)", id)
#if AMXX_VERSION_NUM >= 190
public client_connectex(id, const name[], const ip[], reason[128])
{
server_print("Client %d is connecting (connectex)", id)
return PLUGIN_CONTINUE
}
#endif
public client_putinserver(id) server_print("Client %d connected (putinserver)", id)
public client_disconnected(id) server_print("Client %d disconnected", id)
public event_ResetHUD(id)
{
#if AMXX_VERSION_NUM >= 200
server_print("Client %d ResetHUD alive:%s connected:%s connected_ex:%s", id,
is_user_alive(id)?"yes":"no",
is_user_connected(id)?"yes":"no",
is_user_connected_ex(id)?"yes":"no")
#else
server_print("Client %d ResetHUD alive:%s connected:%s", id,
is_user_alive(id)?"yes":"no",
is_user_connected(id)?"yes":"no")
#endif
if (!is_user_alive(id))
return
switch(entity_get_int(id, EV_INT_playerclass))
{
case TFC_PC_SCOUT: tfc_setmodel(id, "tf2_scout", "")
case TFC_PC_SNIPER: tfc_setmodel(id, "tf2_sniper", "")
case TFC_PC_SOLDIER : tfc_setmodel(id, "tf2_soldier", "")
case TFC_PC_DEMOMAN: tfc_setmodel(id, "tf2_demo", "")
case TFC_PC_MEDIC: tfc_setmodel(id, "tf2_medic", "")
case TFC_PC_HWGUY: tfc_setmodel(id, "tf2_hvyweapon", "")
case TFC_PC_PYRO: tfc_setmodel(id, "tf2_pyro", "")
case TFC_PC_SPY: tfc_setmodel(id, "tf2_spy", "")
case TFC_PC_ENGINEER: tfc_setmodel(id, "tf2_engineer", "")
}
}
public plugin_precache()
{
precache_model("models/player/tf2_scout/tf2_scout.mdl")
precache_model("models/player/tf2_sniper/tf2_sniper.mdl")
precache_model("models/player/tf2_soldier/tf2_soldier.mdl")
precache_model("models/player/tf2_demo/tf2_demo.mdl")
precache_model("models/player/tf2_medic/tf2_medic.mdl")
precache_model("models/player/tf2_hvyweapon/tf2_hvyweapon.mdl")
precache_model("models/player/tf2_pyro/tf2_pyro.mdl")
precache_model("models/player/tf2_spy/tf2_spy.mdl")
precache_model("models/player/tf2_engineer/tf2_engineer.mdl")
}
AMXX build 5416 works fine with the fixed FoxBot. "is_user_connected_ex" has been removed apparently.
Bot per team balance Off
--All bot commands must be enclosed in quotes-- e.g. bot "bot_chat 20"
Client 1 is connecting (connect)
Client 1 connected (putinserver)
Creating bot...
Client 1 ResetHUD alive:no connected:yes
L 03/12/2021 - 20:42:54: "Alvin Steele<11>
Did a quick test with the original version 1 of my plugin (which doesn't check alive state) and the unpatched FoxBot 0.793, and it seems to work fine with AMXX build 5416.
Environment
Description
I've updated AMXX from v1.10 build 5406 to build 5414 and got this:
L 03/10/2021 - 01:54:51: [TFCX] Invalid player 1 L 03/10/2021 - 01:54:51: [AMXX] Displaying debug trace (plugin "tf2_player_models.amxx", version "1") L 03/10/2021 - 01:54:51: [AMXX] Run time error 10: native error (native "tfc_setmodel") L 03/10/2021 - 01:54:51: [AMXX] [0] tf2_player_models.sma::player_spawned (line 32)
Problematic Code (or Steps to Reproduce)
The player models are from this pack, but renamed as seen in plugin_precache:
https://gamebanana.com/skins/125910