[SNIPPET/CODE] How to properly check Team score
Posted: Sun Oct 04, 2026 2:08 pm
Using the next code example i'm going to show you a good way to get team scores, based on my tests, this is working even if is planting bomb/ hostage save, etc ...
First, create 2 new global variables, inside of them will store the actual score of teams:
Register these events in the plugin_init:
In Game restart public:
We get the real score inside of the events:
An example inside of 'test' public:
The whole code without comments:
First, create 2 new global variables, inside of them will store the actual score of teams:
Code: Select all
new TeroScore;
new CtScore;Code: Select all
public plugin_init( )
{
// Events when Terrorists and Counter-terrorists win ( hostage saved, bomb exploded, all are already included in these ... )
register_event("TeamScore", "Event_TeroWin", "a", "1=TERRORIST")
register_event("TeamScore", "Event_CTWin", "a", "1=CT")
// This event is called when Round is restarted, we need to reset TeroScore and CtScore variables when the game are restarted.
register_event("TextMsg", "fwEvGameWillRestart", "a", "2=#Game_will_restart_in")
// We register a 'test' command to see if is completly work and show the good score:
register_clcmd( "say /test", "test" );
} Code: Select all
public fwEvGameWillRestart( )
{
// We reset the variables at server restart:
TeroScore = 0;
CtScore = 0;
} Code: Select all
public Event_CTWin( ) CtScore = read_data( 2 );
public Event_TeroWin( ) TeroScore = read_data( 2 );Code: Select all
public test( id )
{
client_print( id, print_chat, "Tero score: %i, Ct score: %i", TeroScore, CtScore );
} Code: Select all
#include <amxmodx>
new TeroScore;
new CtScore;
public plugin_init( )
{
register_event("TeamScore", "Event_TeroWin", "a", "1=TERRORIST")
register_event("TeamScore", "Event_CTWin", "a", "1=CT")
register_event("TextMsg", "fwEvGameWillRestart", "a", "2=#Game_will_restart_in")
register_clcmd( "say /test", "test" );
}
public fwEvGameWillRestart( )
{
TeroScore = 0;
CtScore = 0;
}
public Event_CTWin( ) CtScore = read_data( 2 );
public Event_TeroWin( ) TeroScore = read_data( 2 );
public test( id )
{
client_print( id, print_chat, "Tero score: %i, Ct score: %i", TeroScore, CtScore );
}