Raised This Month: $ Target: $400
 0% 

Help: I need a plugin of choose player in team


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 11-26-2018 , 10:49   Re: Help: I need a plugin of choose player in team
Reply With Quote #3

Untested. Generates a config file called steamidteams.cfg in addons/sourcemod/configs. Valid values for teams in the config file are t (terrorists) and ct (counter-terrorists).
PHP Code:
#include <sourcemod>
#include <cstrike>

StringMap g_hHashMap;

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

public 
void OnMapStart()
{
    
BrowseKeyValues();
}

public 
void Event_PlayerConnectFull(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (
client && IsClientInGame(client))
    {
        
char steamid[21];
        
int team;
        if (
GetClientAuthId(clientAuthId_Steam2steamidsizeof(steamid)) && g_hHashMap.GetValue(steamidteam))
        {
            
CS_SwitchTeam(clientteam);
        }
    }
}

void BrowseKeyValues()
{
    
delete g_hHashMap;

    
KeyValues kv = new KeyValues("SteamIDs for Teams");
    
char config[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMconfigsizeof(config), "configs/steamidteams.cfg");
    if (!
FileExists(config))
    {
        
kv.JumpToKey("STEAM_0:0:00000000"true);
        
kv.SetString("team""ct");
        
kv.Rewind();
        
kv.JumpToKey("STEAM_0:0:11111111"true);
        
kv.SetString("team""t");
        
kv.Rewind();
        
kv.ExportToFile(config);
        
LogMessage("Generated the config file %s!"config);
    }

    if (!
kv.ImportFromFile(config) || !kv.GotoFirstSubKey())
    {
        
delete kv;
        
SetFailState("Failure parsing the config file %s!"config);
    }

    
g_hHashMap = new StringMap();
    
char steamid[21], team[11];
    do {
        
kv.GetSectionName(steamidsizeof(steamid));
        
kv.GetString("team"teamsizeof(team));
        
g_hHashMap.SetValue(steamidStrEqual(team"t"false) ? CS_TEAM_T CS_TEAM_CT);
        
LogMessage("Set team for SteamID: '%s' to '%s'!"steamidteam);
    } while 
kv.GotoNextKey();
    
delete kv;

Attached Files
File Type: sp Get Plugin or Get Source (steamidteams.sp - 134 views - 1.5 KB)

Last edited by ThatKidWhoGames; 11-26-2018 at 11:01.
ThatKidWhoGames 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 04:04.


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