From my plugin (in fact a heavily modified existing plugin):
PHP Code:
register_event("TeamInfo", "fw_EvTeamInfo", "a")
public fw_EvTeamInfo(id)
{
client_print(0, print_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 CsTeams: Team = 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_deaths( id, cs_get_user_deaths(id) - 1);
set_user_frags( id, get_user_frags(id) + 1);
}
g_OldTeam[id] = Team;
cs_set_user_team(id, CS_TEAM_SPECTATOR);
}
return PLUGIN_HANDLED;
}
public Cmd_Transfer(id, iLevel, iCid)
{
if(!cmd_access(id, iLevel, iCid, 3))
return PLUGIN_HANDLED;
new szTarget[35], szTeam[5];
read_argv(1, szTarget, charsmax(szTarget));
read_argv(2, szTeam, charsmax(szTeam));
strtoupper(szTeam);
new iTempid = cmd_target(id, szTarget, 2);
if(!iTempid)
return PLUGIN_HANDLED;
new szTeamName[35];
new CsTeams:iCurrentTeam = cs_get_user_team(iTempid)
if(!strlen(szTeam))
{
cs_set_user_team(iTempid, iCurrentTeam == CS_TEAM_T ? CS_TEAM_CT : CS_TEAM_T);
formatex(szTeamName, charsmax(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(iTempid, iArgTeam)
if(iArgTeam == CS_TEAM_SPECTATOR)
user_silentkill(iTempid);
else
ExecuteHamB(Ham_CS_RoundRespawn, iTempid);
// using teamnames variable if szTeam != spec
formatex(szTeamName, charsmax(szTeamName), "%s", iArgTeam == CS_TEAM_SPECTATOR ? "Spectator" : Teamnames[_:iArgTeam - 1])
}
}
new szAdminName[35], szPlayerName[35];
get_user_name(id, szAdminName, charsmax(szAdminName));
get_user_name(iTempid, szPlayerName, charsmax(szPlayerName));
new szAuthid[35];
get_user_authid(id, szAuthid, charsmax(szAuthid));
show_activity_key("AMX_SUPER_TRANSFER_PLAYER_CASE1", "AMX_SUPER_TRANSFER_PLAYER_CASE2", szAdminName, szPlayerName, szTeamName);
client_print(iTempid, print_chat, "%L", iTempid, "AMX_SUPER_TRANSFER_PLAYER_TEAM", szTeamName);
console_print(id, "%L", id, "AMX_SUPER_TRANSFER_PLAYER_CONSOLE", szAdminName, szTeamName);
log_amx("%L", LANG_SERVER, "AMX_SUPER_TRANSFER_PLAYER_LOG", szAdminName, szAuthid, szPlayerName, szTeamName);
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?