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

Help: I need a plugin of choose player in team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gui_saint
New Member
Join Date: Nov 2018
Old 11-26-2018 , 08:31   Help: I need a plugin of choose player in team
Reply With Quote #1

Hi guys, I need a plugin that can force players to enter in "counter-Terrorists" or "Terrorists" through STEAM_ID

Last edited by gui_saint; 11-26-2018 at 08:32.
gui_saint is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 11-26-2018 , 09:21   Re: Help: I need a plugin of choose player in team
Reply With Quote #2

I am not exactly sure how you could miss:



I have moved you thread into Plugin/Gameplay Ideas and Requests.

Please pay more attention to where you are placing your future posts.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
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 - 122 views - 1.5 KB)

Last edited by ThatKidWhoGames; 11-26-2018 at 11:01.
ThatKidWhoGames is offline
Reply



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 15:57.


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