AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Off-Topic (https://forums.alliedmods.net/forumdisplay.php?f=15)
-   -   Capture the flag balance plugin. (https://forums.alliedmods.net/showthread.php?t=257776)

dBsRT 02-07-2015 16:42

Capture the flag balance plugin.
 
Can you help me do a plugin that autobalances teams in captrue the flag mod? Thanks.

Spirit_12 02-07-2015 19:58

Re: Capture the flag balance plugin.
 
That feature is built into the jctf plugin. You don't need external plugins to do that.

zmd94 02-08-2015 02:44

Re: Capture the flag balance plugin.
 
2 Attachment(s)
Just try below code. ;)
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <cs_teams_api>

new g_MaxPlayers

public plugin_init()
{
    
// Credit: ZP Dev Team. ;)
    
register_plugin("Auto Balance""1.0""zmd94")
    
    
register_logevent("logevent_round_end"2"1=Round_End")
    
register_event("TextMsg""event_game_restart""a""2=#Game_will_restart_in")
    
    
g_MaxPlayers get_maxplayers()
}

public 
event_game_restart()
{
    
logevent_round_end()
}

public 
logevent_round_end()
{
    
// Balance the teams
    
balance_teams()
}

// Balance Teams
balance_teams()
{
    
// Get amount of users playing
    
new players_count GetPlayingCount()
    
    
// No players, don't bother
    
if (players_count 1) return;
    
    
// Split players evenly
    
new iTerrors
    
new iMaxTerrors players_count 2
    
new idCsTeams:team
    
    
// First, set everyone to CT
    
for (id 1id <= g_MaxPlayersid++)
    {
        
// Skip if not connected
        
if (!is_user_connected(id))
            continue;
        
        
team cs_get_user_team(id)
        
        
// Skip if not playing
        
if (team == CS_TEAM_SPECTATOR || team == CS_TEAM_UNASSIGNED)
            continue;
        
        
// Set team
        
cs_set_player_team(idCS_TEAM_CT0)
    }
    
    
// Then randomly move half of the players to Terrorists
    
while (iTerrors iMaxTerrors)
    {
        
// Keep looping through all players
        
if (++id g_MaxPlayersid 1
        
        
// Skip if not connected
        
if (!is_user_connected(id))
            continue;
        
        
team cs_get_user_team(id)
        
        
// Skip if not playing or already a Terrorist
        
if (team != CS_TEAM_CT)
            continue;
        
        
// Random chance
        
if (random_num(01))
        {
            
cs_set_player_team(idCS_TEAM_T0)
            
iTerrors++
        }
    }
}

// Get Playing Count -returns number of users playing-
GetPlayingCount()
{
    new 
iPlayingidCsTeams:team
    
    
for (id 1id <= g_MaxPlayersid++)
    {
        if (!
is_user_connected(id))
            continue;
        
        
team cs_get_user_team(id)
        
        if (
team != CS_TEAM_SPECTATOR && team != CS_TEAM_UNASSIGNED)
            
iPlaying++
    }
    
    return 
iPlaying;


Please download below .sma file and also .inc file. ;)

dBsRT 02-08-2015 04:48

Re: Capture the flag balance plugin.
 
Your plugin failed to compile! Read the errors below:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

/tmp/textzndUDy.sma(56) : error 017: undefined symbol "cs_set_player_team"
/tmp/textzndUDy.sma(78) : error 017: undefined symbol "cs_set_player_team"

2 Errors.
Could not locate output file /home/groups/amxmodx/public_html/websc3/textzndUDy.amx (compile failed).


I have this error ... :cry:

Kia 02-08-2015 05:24

Re: Capture the flag balance plugin.
 
Try using a local compiler and not a webcompiler.

dBsRT 02-08-2015 06:23

Re: Capture the flag balance plugin.
 
not work... :(

zmd94 02-08-2015 07:49

Re: Capture the flag balance plugin.
 
Sorry, my fault. I have updated the code:

https://forums.alliedmods.net/showpo...49&postcount=3


All times are GMT -4. The time now is 02:54.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.