Kod:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
new bool: choosen[ 33 ];
public plugin_init() {
register_event("HLTV", "mantik", "a", "1=0", "2=0");
}
public mantik( ) {
new players[32],inum,takim[ 3 ],aradalazim[ 10 ];
get_players(players,inum);
for(new i;i<inum;i++){
switch(get_user_team(players[i])){
case 1 :
takim[1] ++;
case 2 :
takim[2] ++;
}
}
if(takim[1]==takim[2])
return PLUGIN_HANDLED;
aradalazim[ 1 ]=max(takim[1],takim[2]);
if(takim[1]==aradalazim[1]){
aradalazim[2]=1;
aradalazim[4]=(takim[1]-takim[2])/2;
dengele(aradalazim[4],aradalazim[2]);
}
else if(takim[2]==aradalazim[1]){
aradalazim[2]=2;
aradalazim[4]=(takim[2]-takim[1])/2;
dengele(aradalazim[4],aradalazim[2]);
}
return PLUGIN_HANDLED;
}
public dengele(user,team) {
new players[ 32 ], pnum, tid[ 3 ];
get_players( players, pnum );
if( pnum < user ) return;
for( new i = 0; i < user; i++ ) {
tid[ i ] = players[ random_num( 0, pnum ) ];
while( choosen[ tid[ i ] ] ) {
tid[ i ] = players[ random_num( 0, pnum ) ];
}
choosen[ tid[ i ] ] = true;
cs_set_user_team(tid[ i ],team);
console_cmd(tid[i],"[DENGELEM-SISTEMI] Takimini dengeleme sistemi degistirdi.");
}
for( new k = 0; k < pnum; k++ ) {
if( choosen[ players[ k ] ] )
choosen[ players[ k ] ] = false;
}
}