Would someone make a plugin that switches team scores by admin command /switchscores.
PHP Code:
#include <cshack>
register_clcmd("say /switchscores", "swap_scores")
public swap_scores()
{
new scoreCT = cs_get_team_score(_:CS_TEAM_CT)
new scoreT = cs_get_team_score(_:CS_TEAM_T)
cs_set_team_score(_:CS_TEAM_CT, scoreT)
cs_set_team_score(_:CS_TEAM_T, scoreCT)
}
This is not working, It crashes the server.
Also I've this code, but somewhy it makes both team scores to -1 instead of swaping them.
PHP Code:
#include <amxmodx>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
#define SCORE_T 0
#define SCORE_CT 1
new g_TeamScore[2];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("TeamScore", "eventTeamScore", "a");
register_clcmd("say /swap", "switchScores")
}
public eventTeamScore()
{
new sTeam[2];
read_data(1, sTeam, 1);
if( sTeam[0] == 'T' )
{
g_TeamScore[SCORE_T] = read_data(2);
}
else
{
g_TeamScore[SCORE_CT] = read_data(2);
}
return PLUGIN_CONTINUE;
}
public switchScores()
{
cs_set_team_score(1 ,g_TeamScore[SCORE_CT])
cs_set_team_score(2 ,g_TeamScore[SCORE_T])
}
stock cs_set_team_score(const team , const score) {
new buffer[10];
switch(team)
{
case 1: copy(buffer , 9 , "TERRORIST");
case 2: copy(buffer , 9 , "CT");
default: return 0;
}
message_begin(MSG_ALL , get_user_msgid("TeamScore") , {0,0,0});
write_string(buffer);
write_byte(score);
message_end();
return 1;
}