public Plugin:myinfo = { name = "Jail Ratio", author = "Toast", description = "A simple Jail ratio", version = "0.0.1", url = "bitbucket.toastdev.de" }
/************************ Global Variabels *************************/
// ConVar Handle new Handle:g_cRatio = INVALID_HANDLE; new Handle:g_cBlockRounds = INVALID_HANDLE; new Handle:g_cRestrictRatio = INVALID_HANDLE;
// Integer new g_iBlockRounds = 0;
// Float new Float:g_fRatio = 0.5;
// Boolean new bool:g_bRestrictRatio = false;
// Array new g_aPlayerBlockRounds[MAXPLAYERS + 1];
public OnPluginStart() { LoadTranslations("jratio.phrases");
// Handle the CVars g_cRatio = AutoExecConfig_CreateConVar("sm_jratio_ratio", "0.5", "How many CTs should be for one T?"); g_cBlockRounds = AutoExecConfig_CreateConVar("sm_jratio_block_rounds", "0", "How many Rounds should somone get blocked from CT Team, if the ratio is bad, if he gets swaped by the plugin?"); g_cRestrictRatio = AutoExecConfig_CreateConVar("sm_jratio_restrict_ratio", "0", "Shall the ratio fit always? (Lock CT Team if it's full) (1 = Enable / 0 = Disable)", _, true, 0.0, true, 1.0);
public Action:TeamJoin(client, const String:command[], args) { // Somone tries to join a team by himself if(!IsClientInGame(client)){ return Plugin_Stop; }
new String:Team[2]; GetCmdArg(1, Team, sizeof(Team)); new TargetTeam = StringToInt(Team);
public Event_PlayerDeath_Callback(Handle:event, const String:name[], bool:dontBroadcast) { new p_iUserid = GetEventInt(event, "userid"); new p_iClient = GetClientOfUserId(p_iUserid);
public Event_PlayerDisconnect_Callback(Handle:event, const String:name[], bool:dontBroadcast) { // Someone left the game new p_iUserid = GetEventInt(event, "userid"); new p_iClient = GetClientOfUserId(p_iUserid);
g_aPlayerBlockRounds[p_iClient] = 0; }
public Event_PlayerConnect_Callback(Handle:event, const String:name[], bool:dontBroadcast) { // Someone joined the game new p_iUserid = GetEventInt(event, "userid"); new p_iClient = GetClientOfUserId(p_iUserid);
g_aPlayerBlockRounds[p_iClient] = 0; }
public Event_RoundStart_Callback(Handle:event, const String:name[], bool:dontBroadcast) { for(new i = 0; i <= MAXPLAYERS; i++) { if(IsClientInGame(i) && g_aPlayerBlockRounds[i] != 0) { g_aPlayerBlockRounds[i] = g_aPlayerBlockRounds[i] - 1; } } }
CheckRatio(any:p_iClient = 0) { new Float:p_fCTCount = float(GetTeamClientCount(3)); new Float:p_fTCount = float(GetTeamClientCount(2));
I wrote it a long time ago. Should work with SM 1.6, didn't tested it with 1.7. Tell me if you find any bug, because its nearly untested. (upped it to my bitbucket for auto updates).