Raised This Month: $209 Target: $400
 52% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-30-2018 , 09:24   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #41

With the new panorama, you can assign a team in player_connect_full (i tried with requestframe) without any bugs. I can buy and i can switch teams, also the teammenu is no more called on connect.
There is a bug if you assign a team in player_spawn event (if teamnum is CS_TEAM_NONE, also with request frame): you can't switch teams.
player_connect_full is called after player_spawn (the first spawn).

Last edited by Ilusion9; 08-30-2018 at 10:33.
Ilusion9 is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 08-30-2018 , 12:36   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #42

//Edit: Be warned that if you change the client's team here, it might throw a fatal error and crash the server.
// To prevent it, use RequestFrame and pass the client index through it.

No.

pass the userid through it.
__________________
I am looking for devs to help maintain some projects I have

Discord: Eyal282#1334
If you like my work, feel free to donate in appreciation with PayPal or CSGO Skins.

Total Donated: 15$
eyal282 is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 08-31-2018 , 00:29   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #43

Quote:
Originally Posted by eyal282 View Post
//Edit: Be warned that if you change the client's team here, it might throw a fatal error and crash the server.
// To prevent it, use RequestFrame and pass the client index through it.

No.

pass the userid through it.
Hmm, I dont think it's necessary since the userid of the said client won't change in 1 frame of the RequestFrame.
joao7yt is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 08-31-2018 , 02:07   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #44

Quote:
Originally Posted by Ilusion9 View Post
With the new panorama, you can assign a team in player_connect_full (i tried with requestframe) without any bugs. I can buy and i can switch teams, also the teammenu is no more called on connect.
There is a bug if you assign a team in player_spawn event (if teamnum is CS_TEAM_NONE, also with request frame): you can't switch teams.
player_connect_full is called after player_spawn (the first spawn).
So, I tested with player_connect_full and seems like I can go to spec but then i can't join ct again...
joao7yt is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-31-2018 , 03:19   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #45

Quote:
Originally Posted by joao7yt View Post
Hmm, I dont think it's necessary since the userid of the said client won't change in 1 frame of the RequestFrame.
Its always necessary to use userids as their is a chance the client will be kicked from slot reservation which will fill the client index slot with a new userid during one frame.
__________________

Last edited by Neuro Toxin; 08-31-2018 at 03:20.
Neuro Toxin is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-31-2018 , 05:36   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #46

Quote:
Originally Posted by joao7yt View Post
So, I tested with player_connect_full and seems like I can go to spec but then i can't join ct again...
with or without requestframe?
i use requestframe and i can switch the teams whenever i want.
Ilusion9 is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 08-31-2018 , 09:33   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #47

Quote:
Originally Posted by Ilusion9 View Post
with or without requestframe?
i use requestframe and i can switch the teams whenever i want.
With.

Can you provide the exact code?
joao7yt is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-31-2018 , 09:48   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #48

PHP Code:

HookEvent
("player_connect_full"Event_PlayerConnect);

public 
void Event_PlayerConnect(Event event, const char[] namebool dontBroadcast
{    
    
RequestFrame(SetDefaultTeamevent.GetInt("userid"));
}

public 
void SetDefaultTeam(int userid)
{
    
int client GetClientOfUserId(userid);
    
    if (
client)
    {
        
CS_SwitchTeam(clientCS_TEAM_CT);
    }

Also, i found joingame command.
https://forums.alliedmods.net/showthread.php?t=282035

PHP Code:

AddCommandListener
(Command_JoinGame"joingame");

public 
Action Command_JoinGame(int client, const char[] commandint args)
{
    
SetEntProp(clientProp_Send"m_iPendingTeamNum"CS_TEAM_CT);


Last edited by Ilusion9; 08-31-2018 at 13:08.
Ilusion9 is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 08-31-2018 , 14:48   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #49

Quote:
Originally Posted by Ilusion9 View Post
PHP Code:

HookEvent
("player_connect_full"Event_PlayerConnect);

public 
void Event_PlayerConnect(Event event, const char[] namebool dontBroadcast
{    
    
RequestFrame(SetDefaultTeamevent.GetInt("userid"));
}

public 
void SetDefaultTeam(int userid)
{
    
int client GetClientOfUserId(userid);
    
    if (
client)
    {
        
CS_SwitchTeam(clientCS_TEAM_CT);
    }

Also, i found joingame command.
https://forums.alliedmods.net/showthread.php?t=282035

PHP Code:

AddCommandListener
(Command_JoinGame"joingame");

public 
Action Command_JoinGame(int client, const char[] commandint args)
{
    
SetEntProp(clientProp_Send"m_iPendingTeamNum"CS_TEAM_CT);

So, figured out why for me it was bugging.

I was using the "EventHookMode_Pre" mode on the hook:
PHP Code:
HookEvent("player_connect_full"Event_OnConnectFullEventHookMode_Pre); 
Seems like with the panorama it's possible to use "player_connect_full" to set the player team on connect without bugs. Cool
joao7yt is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-31-2018 , 15:37   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #50

PHP Code:

AddCommandListener
(Command_JoinGame"joingame");

public 
Action Command_JoinGame(int client, const char[] commandint args)
{
    
SetEntPropFloat(clientProp_Send"m_fForceTeam"0.0);
    
SetEntProp(clientProp_Send"m_iPendingTeamNum"CS_TEAM_CT);

Another way to assign a team on connect. Tested only on local server.
Ilusion9 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 10:59.


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