im not sure why this is happening. i have a function that once you get to two rounds, the script will transfer the players to the other team and the restart the round. now the script does that, but it does it two times and i have been sitting here for two hours and trying to figure out why and now i have given up and ask for ur pro-assistance!
also, how do you print out the value of a boolean? with string u use %s and int %i but how do u do with bool?
anyways, here is the relevant code
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <fun>
#include <cstrike>
new team_wins[2]
new bool:swapMess
public plugin_init() {
register_plugin("ready", "1.00", "hehu")
register_event("TeamScore", "team_score", "a")
register_logevent("round_start", 2, "1=Round_Start")
//register_logevent("round_end",2,"1=Round_End")
}
public team_score()
{
new team[2]
read_data(1, team, 1)
if(team[0] == 'C') {
team_wins[0] = read_data(2)
} else if(team[0] == 'T') {
team_wins[1] = read_data(2)
}
if(team_wins[0]+team_wins[1]==2)
{
swapMess=true
}
return PLUGIN_CONTINUE
}
public round_start()
{
if(swapMess==true)
{
swapMess=false
swap()
//server_cmd("sv_restartround 10")
}
return swapMess
}
public swap() {
new maxplayers=get_maxplayers()
new team[16]
for(new i=0;i<=maxplayers;i++)
if(is_user_connected(i)) {
get_user_team(i,team,15)
if(equal(team,"CT")) {
if(is_user_alive(i))
{
user_kill(i)
cs_set_user_team(i, CS_TEAM_T)
}
}
else
{
if(equal(team,"TERRORIST")) {
if(is_user_alive(i))
{
user_kill(i)
cs_set_user_team(i, CS_TEAM_CT)
}
}
}
}
return PLUGIN_CONTINUE
}
}
some of the code i have found in the forums, like the one for swapping teams