Raised This Month: $ Target: $400
 0% 

Capture the flag balance plugin.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dBsRT
Junior Member
Join Date: Mar 2014
Old 02-07-2015 , 16:42   Capture the flag balance plugin.
Reply With Quote #1

Can you help me do a plugin that autobalances teams in captrue the flag mod? Thanks.
dBsRT is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 02-07-2015 , 19:58   Re: Capture the flag balance plugin.
Reply With Quote #2

That feature is built into the jctf plugin. You don't need external plugins to do that.
Spirit_12 is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 02-08-2015 , 02:44   Re: Capture the flag balance plugin.
Reply With Quote #3

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. ;)
Attached Files
File Type: sma Get Plugin or Get Source (cs_teams_api.sma - 702 views - 3.7 KB)
File Type: inc cs_teams_api.inc (519 Bytes, 257 views)

Last edited by zmd94; 02-08-2015 at 07:48.
zmd94 is offline
dBsRT
Junior Member
Join Date: Mar 2014
Old 02-08-2015 , 04:48   Re: Capture the flag balance plugin.
Reply With Quote #4

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(7 : 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 ...
dBsRT is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 02-08-2015 , 05:24   Re: Capture the flag balance plugin.
Reply With Quote #5

Try using a local compiler and not a webcompiler.
__________________
Kia is offline
dBsRT
Junior Member
Join Date: Mar 2014
Old 02-08-2015 , 06:23   Re: Capture the flag balance plugin.
Reply With Quote #6

not work...
dBsRT is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 02-08-2015 , 07:49   Re: Capture the flag balance plugin.
Reply With Quote #7

Sorry, my fault. I have updated the code:

https://forums.alliedmods.net/showpo...49&postcount=3
zmd94 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:33.


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