AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [CS:GO] Final and fancy solution for putting a player in a team on connect (https://forums.alliedmods.net/showthread.php?t=300549)

joao7yt 08-20-2017 22:00

[CS:GO] Final and fancy solution for putting a player in a team on connect
 
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

th7nder 08-22-2017 05:37

Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
 
Finally! Thank you very much <3

joao7yt 08-22-2017 05:52

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

Originally Posted by th7nder (Post 2543519)
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.

th7nder 08-22-2017 07:51

Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
 
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

joao7yt 08-22-2017 07:59

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

Originally Posted by th7nder (Post 2543544)
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 08-22-2017 16:09

Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
 
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.

asherkin 08-24-2017 08:56

Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
 
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).

joao7yt 08-24-2017 09:04

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

Originally Posted by asherkin (Post 2544023)
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?

joao7yt 09-05-2017 19:05

Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
 
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.

Neuro Toxin 09-06-2017 03:02

Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
 
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.


All times are GMT -4. The time now is 23:25.

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