I found the reason why yapb failed to instantly detect team change, it because TeamInfo message cannot be read by any other metamod module.
I tried to send TeamInfo message via emessage_begin but it failed too.
So i found a silly method to fix this issue, but it need to modify our custom cs1.6 mod, example in Zombie Plague and Biohazard.
Here is an example of fix:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#define PLUGIN "Silly Fix"
#define VERSION "0.0.1"
#define AUTHOR "wbyokomo"
new bool:bTeamChangeSpawn[33], iOrigin[33][3]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Spawn, "player", "OnSpawnPost", 1)
}
public client_putinserver(id)
{
bTeamChangeSpawn[id] = false //reset flag
}
public OnSpawnPost(id)
{
//stop here if changing team
if(bTeamChangeSpawn[id])
{
bTeamChangeSpawn[id] = false
return;
}
//our new post actions
if(!is_user_alive(id)) return;
if(cs_get_user_team(id) != CS_TEAM_CT) SetPlayerTeam(id, CS_TEAM_CT);
}
//silly team changer fix
SetPlayerTeam(id, CsTeams:team)
{
bTeamChangeSpawn[id] = true //mark team change flag
get_user_origin(id, iOrigin[id]) //get current origin
cs_set_user_team(id, team, CS_NORESET) //set our new team
ExecuteHam(Ham_CS_RoundRespawn, id) //call round respawn, in order to update TeamInfo, using emessage_begin is useless too. metamod still can't retrieve it. Use ExecuteHam not ExecuteHamB
set_user_origin(id, iOrigin[id]) //set back our origin
//you need to add unstuck code here sometime our origin will stuck.
}
I know this is not efficient but at least it working and bot instantly can detect new team changes. Fast target change is awesome