View Single Post
Re: [Suggestion] Amxmodx API for YaPB.
Old
  (#6)
wbyokomo
Zombie Slayer
 
Status: Offline
Posts: 17
Join Date: Apr 2012
Location: Cyberjaya MY
Default Re: [Suggestion] Amxmodx API for YaPB. - 04-11-2015

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(PLUGINVERSIONAUTHOR)
    
    
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_CTSetPlayerTeam(idCS_TEAM_CT);
}

//silly team changer fix
SetPlayerTeam(idCsTeams:team)
{
    
bTeamChangeSpawn[id] = true //mark team change flag
    
get_user_origin(idiOrigin[id]) //get current origin
    
cs_set_user_team(idteamCS_NORESET//set our new team
    
ExecuteHam(Ham_CS_RoundRespawnid//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(idiOrigin[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
  
Reply With Quote