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

[CS:GO] Final and fancy solution for putting a player in a team on connect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 08-20-2017 , 22:00   [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #1

As the Panorama doesn't have a Continue Screen, it's now possible to use the "player_connect_full" HookEvent:

PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_connect_full"Event_PlayerConnectFull);
}

public 
Action Event_PlayerConnectFull(Handle event, const char[] namebool dontBroadcast)
{
    
RequestFrame(SetClientTeamGetEventInt(event"userid"));
}

public 
void SetClientTeam(int userid)
{
    
int client GetClientOfUserId(userid);
    
    
//Do stuff here
    //Now you can check if the client is valid and then put it in a team using CS_SwitchTeam or ChangeClientTeam.

Scaleform legacy:
Spoiler

Last edited by joao7yt; 08-31-2018 at 15:05.
joao7yt is offline
th7nder
Senior Member
Join Date: Oct 2014
Old 08-22-2017 , 05:37   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #2

Finally! Thank you very much <3
th7nder is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 08-22-2017 , 05:52   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #3

Quote:
Originally Posted by th7nder View Post
Finally! Thank you very much <3
Yw, hope everyone with plugins that put players into a team on join see this, this will make everyone's life easier.
joao7yt is offline
th7nder
Senior Member
Join Date: Oct 2014
Old 08-22-2017 , 07:51   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #4

This plugins has one bug, it returns Plugin_Handled on every VGUI, you should return Plugin_Handled only if this is VGUI for teams, but overall idea is the best! <3
th7nder is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 08-22-2017 , 07:59   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #5

Quote:
Originally Posted by th7nder View Post
This plugins has one bug, it returns Plugin_Handled on every VGUI, you should return Plugin_Handled only if this is VGUI for teams, but overall idea is the best! <3
You are right, fixed
joao7yt is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 08-22-2017 , 16:09   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #6

Note: for some reason "return Plugin_Handled;" is necessary after doing a "ChangeClientTeam", otherwise the server crashes. I'm saying it because I tried doing "PbSetBool(msg, "show", false);" (which will make the team menu to not show) and then "return Plugin_Continue;", because idk if simply doing "return Plugin_Handled;" would lead to a future bug, but seems it's not possible to call "return Plugin_Continue;" after changing the client's team without crashing the server.
joao7yt is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 08-24-2017 , 08:56   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #7

Your PbSetBool would have been throwing an error (because usermessages can't be modified from a usermessage hook) and aborting the call, which would cause later usermessage creation to become unbalanced, which caused the "crash" (it wasn't a crash in the normal sense, the server threw a fatal error).
__________________
asherkin is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 08-24-2017 , 09:04   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #8

Quote:
Originally Posted by asherkin View Post
Your PbSetBool would have been throwing an error (because usermessages can't be modified from a usermessage hook) and aborting the call, which would cause later usermessage creation to become unbalanced, which caused the "crash" (it wasn't a crash in the normal sense, the server threw a fatal error).
I didn't get it. Is changing the client's team changing the UserMessenge? If so, why when returning Continue cause the Error but returning Handled doesn't?

Last edited by joao7yt; 08-24-2017 at 09:05.
joao7yt is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 09-05-2017 , 19:05   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #9

Guys, I might have found a bug related to it: if you change the client's team inside that hook, it could rarely throw a fatal error and crash the srcds.exe. I did a few tests and it might have gone if you create a timer to change the client's team, which is not a problem since we will still be able to hook when the team menu shows, it will only put the client in a team a bit later. I put 0.1 seconds in my timer and got no crashes. So be warned, guys.
joao7yt is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 09-06-2017 , 03:02   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #10

I hook on player spawn.

The first occurrence is from client connecting. The second occurrence u can change the team and cs_respawn the client.

A better way is to listen to the jointeam command. Wait a frame and then set your team.
__________________
Neuro Toxin 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 09:22.


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