View Single Post
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 06-01-2018 , 15:58   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #37

Quote:
Originally Posted by Papero View Post
If someone is interested using this way you can put a player on a team on connect(without showing the teammenu) and prevent its change.

PHP Code:
public void OnPluginStart()
{
    
HookUserMessage(GetUserMessageId("VGUIMenu"), TeamMenuHooktrue);
    
    
//Team Hooks
    
AddCommandListener(Cmd_JoinTeam"jointeam");
    
AddCommandListener(Cmd_JoinTeam"spectate");
}

public 
Action Cmd_JoinTeam(int client, const char[] commandint args)
{
    
//Prevent team change
    
return Plugin_Stop;
}

public 
Action TeamMenuHook(UserMsg msg_idProtobuf msg, const int[] playersint playersNumbool reliablebool init)
{
    
char buffermsg[64];
    
    
msg.ReadString("name"buffermsgsizeof(buffermsg)); //Use methodmaps
    
if (StrEqual(buffermsg"team"true))
    {
        
int client players[0];
        
        
RequestFrame(Frame_SetTeamGetClientUserId(client));
        return 
Plugin_Stop//Don't show the teammenu
    
}
    
    return 
Plugin_Continue;
}  

public 
void Frame_SetTeam(any userid)
{
    
int client GetClientOfUserId(userid);
    if (!
client)
        return;
        
    
ChangeClientTeam(clientCS_TEAM_CT); //Change team

That’s exactly what I said on the original post -.-
joao7yt is offline