I have one plugin, which picks number of T's according to number of CT's. And I want to implement it into DRM, since it's not working correctly as a second plugin WITH deathrun manager.
Here's the code:
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <engine>
#include <fun>
#include <hamsandwich>
#define PLUGIN "CT and T ratio"
#define VERSION "0.1"
#define AUTHOR "ZssZ"
new const CsInternalModel:g_TModels[] = { CS_T_TERROR, CS_T_LEET, CS_T_ARCTIC, CS_T_GUERILLA }
new g_MaxClients
new dr_enabled, dr_tnum
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("dr_version", VERSION, FCVAR_SERVER)
set_cvar_string("dr_version", VERSION)
dr_enabled = register_cvar("dr_enabled", "1")
dr_tnum = register_cvar("dr_tnum", "8")
server_cmd("amx_lock T")
server_exec()
set_cvar_num("mp_limitteams", get_pcvar_num(dr_tnum))
set_cvar_num("mp_autoteambalance", 0)
g_MaxClients = get_maxplayers()
register_event("HLTV", "new_round", "a", "1=0", "2=0")
}
// On new round
public new_round()
{
set_task(0.1, "port")
}
public port()
{
// Plugin disabled?
if (get_pcvar_num(dr_enabled) == 0)
return;
// Get players count
new player_count, player, CsTeams:team
for (player = 1; player <= g_MaxClients; player++)
{
// Check if user connected
if (!is_user_connected(player))
continue;
// Get player team
team = cs_get_user_team(player)
// Check if user not on a team yet
if (team == CS_TEAM_UNASSIGNED || team == CS_TEAM_SPECTATOR)
continue;
// Switch to CT
cs_set_user_team(player, CS_TEAM_CT)
// Increase player count
player_count++
}
// Do we have enough players?
if (player_count < 1)
return;
// Calculate how many Ts should we have
new num_ts = player_count / get_pcvar_num(dr_tnum)
// Make sure we have at least one
if (num_ts < 1) num_ts = 1
// DEBUG
client_print(0, print_chat, "[Deathrun] %d Players Total - Randomly choosing %d Ts", player_count, num_ts)
// Now pick random Ts
new teamt
// Keep going through loop while we haven't gotten num_ts Ts
while (teamt < num_ts)
{
// Makes loop be able to work properly if player > g_MaxClients
if (player++ > g_MaxClients) player = 1
// Check if user connected
if (!is_user_connected(player))
continue;
// Only switch players from the CT team
if (cs_get_user_team(player) != CS_TEAM_CT)
continue;
// Player has 1 in 10 chance of being selected as the T
if (random_num(1,10) == 1)
{
cs_set_user_team(player, CS_TEAM_T, g_TModels[random_num(0, 3)])
teamt++
}
}
}
So I've checked DRM code and found event where T is picked.
In default, it looks like this:
PHP Code:
public EventRandromize( ) {
if( !g_bEnabled || g_bFirstRound || g_bRandromized )
return PLUGIN_CONTINUE;
g_bRandromized = true;
new i, iPlayers[ 32 ], iNum, iPlayer;
get_players( iPlayers, iNum, "c" );
if( iNum <= 1 )
return PLUGIN_CONTINUE;
for( i = 0; i < iNum; i++ ) {
iPlayer = iPlayers[ i ];
if( cs_get_user_team( iPlayer ) == CS_TEAM_T )
cs_set_user_team( iPlayer, CS_TEAM_CT );
}
new iRandomPlayer, CsTeams:iTeam;
while( ( iRandomPlayer = iPlayers[ random_num( 0, iNum - 1 ) ] ) == g_iLastTerr ) { }
g_iLastTerr = iRandomPlayer;
iTeam = cs_get_user_team( iRandomPlayer );
if( iTeam == CS_TEAM_T || iTeam == CS_TEAM_CT ) {
cs_set_user_team(iRandomPlayer, CS_TEAM_T);
new szName[ 32 ];
get_user_name( iRandomPlayer, szName, 31 );
for( i = 0; i < iNum; i++ )
ColorChat(iPlayers[ i ], RED, "%s^4 %L", g_szPrefix, iPlayers[ i ], "DR_NOW_TERR", szName);
if( !g_bRestart && is_valid_ent( g_iThinker ) )
entity_set_float( g_iThinker, EV_FL_nextthink, get_gametime( ) + 15.0 );
} else {
g_bRandromized = false;
EventRandromize( );
}
return PLUGIN_CONTINUE;
}
So basically I want to pick T's in DRM just like that plugin is picking T's for a new round, so there would be 1 T for each X (in my case 9) CT's.
I did something like this (I'm not that deep into coding
):
PHP Code:
public EventRandromize( ) {
// Get players count
new player_count, player, CsTeams:team;
new const CsInternalModel:g_TModels[] = { CS_T_TERROR, CS_T_LEET, CS_T_ARCTIC, CS_T_GUERILLA };
for (player = 1; player <= g_iMaxplayers; player++)
{
// Check if user connected
if (!is_user_connected(player))
continue;
// Get player team
team = cs_get_user_team(player)
// Check if user not on a team yet
if (team == CS_TEAM_UNASSIGNED || team == CS_TEAM_SPECTATOR)
continue;
// Switch to CT
cs_set_user_team(player, CS_TEAM_CT)
// Increase player count
player_count++
}
// Do we have enough players?
if (player_count < 1)
return;
// Calculate how many Ts should we have
new num_ts = player_count / 9
// Make sure we have at least one
if (num_ts < 1) num_ts = 1
// DEBUG
client_print(0, print_chat, "[Deathrun] %d Players Total - Randomly choosing %d Ts", player_count, num_ts)
// Now pick random Ts
new teamt
// Keep going through loop while we haven't gotten num_ts Ts
while (teamt < num_ts)
{
// Makes loop be able to work properly if player > g_MaxClients
if (player++ > g_iMaxplayers) player = 1
// Check if user connected
if (!is_user_connected(player))
continue;
// Only switch players from the CT team
if (cs_get_user_team(player) != CS_TEAM_CT)
continue;
// Player has 1 in 10 chance of being selected as the T
if (random_num(1,10) == 1)
{
cs_set_user_team(player, CS_TEAM_T, g_TModels[random_num(0, 3)])
teamt++
}
}
}
However, it results in:
Quote:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team
Error: Expected token: ";", but found "if" on line 274
Error: Expected token: ";", but found "-identifier-" on line 281
Error: Expected token: ";", but found "}" on line 282
Error: Expected token: ";", but found "if" on line 292
Error: Expected token: ";", but found "-identifier-" on line 295
Error: Expected token: ";", but found "new" on line 298
Error: Expected token: ";", but found "while" on line 301
Error: Expected token: ";", but found "if" on line 307
Error: Expected token: ";", but found "-identifier-" on line 318
Error: Expected token: ";", but found "}" on line 319
Warning: Symbol is assigned a value that is never used: "g_bRandromized" on line 831
Warning: Symbol is never used: "g_iLastTerr" on line 831
10 Errors.
|
Can anyone please help me with this?
Again, I'm not that deep into coding to understand what the hell is wrong.