|
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen.
|
01-31-2014
, 08:20
Re: [TF2]How to Team Player Limit?
|
#2
|
Give me a sec, I want try to do this.
This doesn't work. And, well, almost everything is done. But I'm too lazy the found why it actually doesn't...
Spoiler
PHP Code:
#include <sourcemod> #include <morecolors> #include <tf2> #include <tf2_stocks>
new Handle:CVAR_plugin_stat; new Handle:CVAR_limit_t1; new Handle:CVAR_limit_t2;
/* NOTE : 0 = teamless (as for most of games) 1 = spectators (as for most of games) 2 = terrorists/RED/? 3 = CT/BLU/? Thanks RedSword ! http://docs.sourcemod.net/api/index.php?fastload=show&id=411& */ public Plugin:myinfo = { name = "Team Limiter", author = "Arkarr", description = "Allow to set a max limit of player in each team.", version = "1.0", url = "http://www.sourcemod.net" };
public OnPluginStart() { CVAR_plugin_stat = CreateConVar("sm_TL_playerlimit_enabled", "1", "Enable or disable plugin. VALUE : 1 = ENABLED 0 = DISABLED"); CVAR_limit_t1 = CreateConVar("sm_TL_playerlimit_team_1", "0", "Maxium player(s) in team 1. NOTE: team 1 include Terrorists/RED/?"); CVAR_limit_t2 = CreateConVar("sm_TL_playerlimit_team_2", "32", "Maxium player(s) in team 2. NOTE: team 2 include CounterTerrorists/BLU/?"); HookEvent("player_team", Event_PlayerTeam); }
public Action:Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) { new client = GetClientOfUserId(GetEventInt(event, "userid")); if(!IsValidClient(client)) { return Plugin_Handled; } if(GetConVarInt(CVAR_plugin_stat) <= 0) { return Plugin_Continue; } new nbr_player = 0; new max_player_team = 0; new selected_team = 0; new old_team = 0; //selected_team = GetClientTeam(client); selected_team = GetEventInt(event, "team"); old_team = GetEventInt(event, "oldteam"); if(selected_team == 2 || selected_team == 3) { nbr_player = GetTeamClientCount(selected_team); if(selected_team == 2) { max_player_team = GetConVarInt(CVAR_limit_t1); } else { max_player_team = GetConVarInt(CVAR_limit_t2); } } else { return Plugin_Continue; } //PrintToChatAll("number of player in selected team : %i", nbr_player); if(nbr_player >= max_player_team) { CPrintToChat(client, "{fullred}[TeamLimiter]{default} Sorry, you can't join this team now."); ChangeClientTeam(client, old_team); ForcePlayerSuicide(client); }
return Plugin_Continue; }
stock bool:IsValidClient(client) { if(client <= 0 ) return false; if(client > MaxClients) return false; if(!IsClientConnected(client)) return false; return IsClientInGame(client); }
__________________
Last edited by Arkarr; 01-31-2014 at 10:16.
|
|
|
|