Raised This Month: $12 Target: $400
 3% 

[CSGO] Simple reserved slot plugin problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
VJScope
Senior Member
Join Date: Jul 2012
Location: Finland
Old 12-25-2017 , 14:36   [CSGO] Simple reserved slot plugin problem
Reply With Quote #1

Hello!

This plugin was created for a specific 10vs10 server (22 slots). I have no intention of publishing any official version of this, but feel free to copy, modify and use it if you like it.

The idea is this: When ever a player with any admin flags (let's call them "vip") joins from spectate to CT or Terrorist team, this plugin will kick the first non-vip player it can find - provided that both teams are full. Then it automatically moves the vip to that team.

It works over 90% of the time, but sometimes it kicks players even when the teams are not full. Another problem, which is much less relevant here, is that it doesn't always kick the non-vip player. I think that this happens only if there is just one non-vip in the game. Like I said, this plugin works most of the time, but I would like to know if anyone has any idea of how to fix it...

Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

public Plugin:myinfo = 
{
	name = "Simple Reserved Slots",
	author = "vjscope",
	description = "Kick non-admin/vip if server is full and admin/vip is joining a team",
	url = ""
};

public OnPluginStart()
{
	AddCommandListener(Command_JoinTeam, "jointeam");
}

public Action:Command_JoinTeam(client, const String:command[], args)
{
	new players = GetClientCount(true);
	new playersInTeams = 1;
	new kickYes = 1;
	
	//Player needs to be a spectator
	if(GetClientTeam(client) != CS_TEAM_CT || GetClientTeam(client) != CS_TEAM_T)
	{
		//Player needs to have an admin flag
		if(GetUserAdmin(client) != INVALID_ADMIN_ID)
		{
			//Count the amount of players in both teams
			for(new x = 1; x <= players; x++)
			{
				if(GetClientTeam(x) == CS_TEAM_T || GetClientTeam(x) == CS_TEAM_CT)
				{
					playersInTeams += 1;
				}
			}
			
			//Find a player with no admin flags
			for(new i = 1; i <= players; i++)
			{
				if (GetClientTeam(i) == CS_TEAM_CT || GetClientTeam(i) == CS_TEAM_T)
				{
					if(GetUserAdmin(i) == INVALID_ADMIN_ID && kickYes == 1 && playersInTeams > 19)
					{
						//Get the about-to-be-kicked player's team
						new teamToJoin = GetClientTeam(i);
						
						//Not sure if this is the best way to inform the kicked player - or if it even works...
						PrintToConsole(i, "[SM] You got kicked because Admin/VIP joined from spectate and teams are full.");
						
						ServerCommand("kickid %d", GetClientUserId(i));
						
						//Don't kick any more players
						kickYes = 0;
						
						PrintToChatAll(" \x04[SM] Player got kicked because Admin/VIP joined from spectate and teams are full.");
						
						//Replace vip player with kicked player
						ChangeClientTeam(client, teamToJoin);
					}
				}
			}
		}
	}
}
__________________
Strange women lying in ponds distributing swords is no basis for a system of government. Supreme executive power derives from a mandate from the masses, not from some farcical aquatic ceremony.
VJScope is offline
Reply


Thread Tools
Display Modes

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 12:04.


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