AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   TeamInfo event issue with another plugin (https://forums.alliedmods.net/showthread.php?t=309626)

fatal_nl 08-01-2018 19:22

TeamInfo event issue with another plugin
 
From my plugin (in fact a heavily modified existing plugin):

PHP Code:

register_event("TeamInfo""fw_EvTeamInfo""a")

public 
fw_EvTeamInfo(id)
{
    
client_print(0print_chat"team change detected")


This works perfectly fine besided one exception:

I also have the amx_super-serious plugin running on my server. When an admin transfers a player to another team, the TeamInfo event get triggered. When a player type /spec, TeamInfo doesn't see this. Both amx_transfer and clcmd /spec use cs_set_user_team:

From amx_super-serious:
PHP Code:

register_clcmd("say /spec""Cmd_Spec")
register_concmd("amx_transfer""Cmd_Transfer"ADMIN_LEVEL_D"<nick, #userid or authid> <CT/T/Spec> Transfers that player to the specified team");

public 
Cmd_Spec(id)
{
    new 
CsTeamsTeam cs_get_user_team(id);
    
    if(( 
Team == CS_TEAM_CT || Team == CS_TEAM_T ) && get_pcvar_num(g_pAllowSpec) || get_pcvar_num(g_pAllowPublicSpec)) 
    {
        if(
is_user_alive(id))
        {
            
user_kill(id);
            
            
cs_set_user_deathsidcs_get_user_deaths(id) - 1);
            
set_user_fragsidget_user_frags(id) + 1);
        }
        
        
g_OldTeam[id] = Team;
        
        
cs_set_user_team(idCS_TEAM_SPECTATOR);
    }

    return 
PLUGIN_HANDLED;
}

public 
Cmd_Transfer(idiLeveliCid)
{
    if(!
cmd_access(idiLeveliCid3))
        return 
PLUGIN_HANDLED;
    
    new 
szTarget[35], szTeam[5];
    
read_argv(1szTargetcharsmax(szTarget));
    
read_argv(2szTeamcharsmax(szTeam));
    
strtoupper(szTeam);
    
    new 
iTempid cmd_target(idszTarget2);
    
    if(!
iTempid)
        return 
PLUGIN_HANDLED;
    
    new 
szTeamName[35];
    new 
CsTeams:iCurrentTeam cs_get_user_team(iTempid)

    if(!
strlen(szTeam))
    {    
        
cs_set_user_team(iTempidiCurrentTeam == CS_TEAM_T CS_TEAM_CT CS_TEAM_T);
        
formatex(szTeamNamecharsmax(szTeamName), "%s"Teamnames[_:iCurrentTeam 1]);
    }
    
    else
    {
        new 
CsTeams:iArgTeam
        
switch(szTeam[0])
        {
            case 
'C'iArgTeam CS_TEAM_CT;
            case 
'T'iArgTeam CS_TEAM_T;
            case 
'S'iArgTeam CS_TEAM_SPECTATOR;
            default:
            {
                
console_print(id"%L"id"AMX_SUPER_TEAM_INVALID");
                return 
PLUGIN_HANDLED;
            }
        }
        
        if (
iArgTeam == iCurrentTeam)
        {
            
console_print(id"%L"id"AMX_SUPER_TRANSFER_PLAYER_ALREADY")
            return 
PLUGIN_HANDLED
        
}
        
        else
        {
            
/*
            if (iArgTeam == CS_TEAM_SPECTATOR)
                user_silentkill(iTempid)
                
            cs_set_user_team(iTempid, iArgTeam)
            
            if (iArgTeam != CS_TEAM_SPECTATOR)
                ExecuteHamB(Ham_CS_RoundRespawn, iTempid)
                
            */
            
cs_set_user_team(iTempidiArgTeam)
            
            if(
iArgTeam == CS_TEAM_SPECTATOR)
                
user_silentkill(iTempid);
                
            else
                
ExecuteHamB(Ham_CS_RoundRespawniTempid);

            
// using teamnames variable if szTeam != spec
            
formatex(szTeamNamecharsmax(szTeamName), "%s"iArgTeam == CS_TEAM_SPECTATOR "Spectator" Teamnames[_:iArgTeam 1])
        }
    }
    
    new 
szAdminName[35], szPlayerName[35];
    
get_user_name(idszAdminNamecharsmax(szAdminName));
    
get_user_name(iTempidszPlayerNamecharsmax(szPlayerName));
    
    new 
szAuthid[35];
    
get_user_authid(idszAuthidcharsmax(szAuthid));
    
    
show_activity_key("AMX_SUPER_TRANSFER_PLAYER_CASE1""AMX_SUPER_TRANSFER_PLAYER_CASE2"szAdminNameszPlayerNameszTeamName);

    
client_print(iTempidprint_chat"%L"iTempid"AMX_SUPER_TRANSFER_PLAYER_TEAM"szTeamName);

    
console_print(id"%L"id"AMX_SUPER_TRANSFER_PLAYER_CONSOLE"szAdminNameszTeamName);
    
log_amx("%L"LANG_SERVER"AMX_SUPER_TRANSFER_PLAYER_LOG"szAdminNameszAuthidszPlayerNameszTeamName);
    
    return 
PLUGIN_HANDLED;


My options:

1. Make my own plugin work so TeamInfo also receive the event when someone type /spec. How?
2. Also add register_clcmd for /spec in my own plugin, but then there's no check in case amx_super-serious is disabled or removed.
3. Edit the amx_super-serious plugin the let it work in my plugin. How?

fatal_nl 08-02-2018 18:12

Re: TeamInfo event issue with another plugin
 
I wasn't able to catch the /spec in my plugin. I decided to choose a middle ground solution by editing amx_super-serious. Instead of using cs_set_user_team which couldn't be detected by TeamInfo event in my plugin I used engclient_cmd(id, "jointeam", "6"). The amx_super-serious plugin also contains an /unspec function which I couldn't get to work easily without stripping VGUI menus to let the engclient_cmd work (even with joinclass added). I stripped the function that put the player back to the previous team automatically and added chooseteam instead which let the player choose a team manually.


All times are GMT -4. The time now is 12:15.

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