Swap teams & scores
Hey, why my server crashes when plugin tries to swap teams & score...
here it is:
PHP Code:
#include <amxmodx> #include <fakemeta> #include <cshack> #include <cstrike>
new const VERSION[] = "1.0"
const MAX_PLAYERS = 32
const XTRA_OFS_PLAYERS = 5 const OFFSET_TEAM = 114
const TEAM_T = 1 const TEAM_CT = 2
new iRound;
new cvar_rounds; public plugin_init() { register_plugin("Swap teams & score", VERSION, "reinert")
register_logevent("Logevent_Round_End", 2, "1=Round_End") cvar_rounds = register_cvar("swap_rounds", "6") register_event("HLTV", "event_new_round", "a", "1=0", "2=0") }
public event_new_round(){ iRound+=1; client_print(0, print_chat,"new round works") if(iRound == get_pcvar_num(cvar_rounds) - 1){ set_task(2.5, "LastRound") } }
public LastRound(){ new Players[32] new playerCount, i, player get_players(Players, playerCount, "ch") for (i=0; i<playerCount; i++) player = Players[i] client_cmd(player, "stopsound") client_cmd(player, "spk tmreverse") }
public Logevent_Round_End() { client_print(0, print_chat,"round end works") if(iRound == get_pcvar_num(cvar_rounds)){ set_task(0.1, "SwapScore") set_task(0.1, "SwapPlayers") iRound = 0; } }
public SwapScore() { static scoreCT, scoreT; scoreT = cs_get_team_score( _:CS_TEAM_T ); scoreCT = cs_get_team_score( _:CS_TEAM_CT ); cs_set_team_score(_:CS_TEAM_T, scoreCT) cs_set_team_score(_:CS_TEAM_CT, scoreT) }
public SwapPlayers() { new iPlayers[MAX_PLAYERS], iNum, id get_players(iPlayers, iNum, "h") for(new i; i<iNum; i++) { id = iPlayers[i] switch( get_pdata_int(id, OFFSET_TEAM, XTRA_OFS_PLAYERS) ) { case TEAM_T: { set_pdata_int(id, OFFSET_TEAM, TEAM_CT, XTRA_OFS_PLAYERS) } case TEAM_CT: { set_pdata_int(id, OFFSET_TEAM, TEAM_T, XTRA_OFS_PLAYERS) } } set_task(2.5,"Swaped") } }
public Swaped(){ new Players[32] new playerCount, i, player get_players(Players, playerCount, "ch") for (i=0; i<playerCount; i++) player = Players[i] client_cmd(player, "stopsound") client_cmd(player, "spk tmreversed") }
No errors in logs, I'm also using this CsHack module. (it's working -
[ 8] CS Hack RUN - cshack_amxx.dll v1.00 pl2 ANY ANY ).. Is there another, better way to swap teams and their scores ???
|