Raised This Month: $ Target: $400
 0% 

Prevent class change in TF2


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
cidra
Junior Member
Join Date: Jun 2016
Location: Italy
Old 02-26-2017 , 05:35   Prevent class change in TF2
Reply With Quote #1

Yes, i don't know how, i typed "class" instead of "team" in the topic title, i'm sleeping i guess. Sorry!


Hi all. I'm trying to make something simple in Sourcemod that simply prevent a client from switching team when it's reached the limit.


Code:
public OnPluginStart()
{
	HookEvent("player_team",Event_PlayerTeam);
}

public Event_PlayerTeam(Handle:event,  const String:name[], bool:dontBroadcast)
{
	new iClient = GetClientOfUserId(GetEventInt(event, "userid")),
			oldTeam   = GetClientTeam(iClient),
			newTeam = GetEventInt(event, "team");
			
	if (fullTeam(newTeam))
	{
		PrintToChat(iClient, "Full team.");
		TF2_SetPlayerClass(iClient, TFClass_Unknown);
		ChangeClientTeam(iClient, 1);
	}
}

bool:fullTeam(iTeam)
{
	if(iTeam < 2)
		return false;
	
	else if(GetTeamClientCount(iTeam) >= 2)
	{
		return true;
	}
	return false;
}
Plugin is compiled without errors. I run it in my server but when there are (for example) 2 players on team RED and i try to switch to RED team this appears in chat:


cidra has joined team RED
Full team.
cidra has joined team SPECTATORS

This should be normal, but actually my client stays on RED team, not on SPEC.


At the beginning i tried to set the client's team to the old one. Now i also tried to simply switch to spectator team but with the same results (Here the reason why oldTeam is never used)

What could be the problem? Thanks in advance for you availability.

Last edited by cidra; 02-26-2017 at 06:05.
cidra is offline
 



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:34.


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