Raised This Month: $32 Target: $400
 8% 

[Help] auto side choose


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FarHaN_ShaiKh
New Member
Join Date: Sep 2020
Old 10-26-2020 , 03:14   [Help] auto side choose
Reply With Quote #1

Guys i want a plugin, when a player will enter/join the server if his steamid is not registered he will kick and we will decide their teams by their steam id, here you can check a code which i got from a friend but it is not working anyone plz help.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <reapi>

#define PLUGIN  "New Plug-In"
#define VERSION "1.0"
#define AUTHOR  "Author"

new n_steamidMAX_PLAYERS ];
new 
n_connectidMAX_PLAYERS ];
new 
filename256 ];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
get_configsdir(filename,255);
    
format(filename,255,"%s/matchplayers.ini",filename);
}

public 
client_authorizedid )
{
    
get_user_authid(idn_connectidcharsmaxn_connectid ));
}

public 
client_putinserver(id)
{
    new 
linelenData128 ];
    new 
team];

    while((
line read_filefilename line Data 127 len) ) != 
    {
          
parse(Datateam,7n_steamid,7);

        if( 
n_connectid[id] != n_steamid[id] )
        {
            
server_cmd("amx_kick #%s You Have No Entry To The Server^n"n_steamid);
        }

          if( 
equalteam"CT") )
          {
              
rg_set_user_team(idTEAM_CTMODEL_AUTOtrue);

        }

        if( 
equalteam"TT") )
          {
              
rg_set_user_team(idTEAM_TERRORISTMODEL_AUTOtrue);

        }
    }


FarHaN_ShaiKh is offline
r0ma
Senior Member
Join Date: Apr 2012
Location: Great Tomb of Nazarick
Old 10-26-2020 , 09:42   Re: [Help] auto side choose
Reply With Quote #2

I'm not use reapi, test:

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <reapi>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "r0ma'"

#define FILE "steamid.ini"

new Trie:g_Steam;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_concmd("amx_reload_steamid""concmd_reload");
}

public 
plugin_cfg() {
    
g_Steam TrieCreate();
    
    
load_configfile();
}

public 
concmd_reload(id) {
    if(!(
get_user_flags(id) & ADMIN_BAN)) {
        return 
PLUGIN_HANDLED;
    }
    
    
load_configfile();
    
    return 
PLUGIN_HANDLED;
}

public 
load_configfile() {
    
TrieClear(g_Steam);
    
    new 
szConfigDir[64], szBuffer[128], szTeam[6], szSteam[33];

    
get_configsdir(szConfigDircharsmax(szConfigDir));
    
formatex(szBuffercharsmax(szBuffer), "%s/%s"szConfigDirFILE);
    
    if(!
file_exists(szBuffer))
        
set_fail_state("File '%s' not found."szBuffer);
    
    new 
file fopen(szBuffer"rt");
    
    if(!
file)
        
set_fail_state("Failed to open file.");

    while(!
feof(file)) {
        
fgets(fileszBuffercharsmax(szBuffer));
        
trim(szBuffer);

        if(!
szBuffer[0] || szBuffer[0] == ';')
            continue;

        
strtok(szBufferszSteamcharsmax(szSteam), szTeamcharsmax(szTeam), '=');

        
trim(szSteam);
        
trim(szTeam);
        
        if(!
szTeam[0])
            continue;
        
        if(
szTeam[0] == 'T' || szTeam[0] == 't')
            
TrieSetCell(g_SteamszSteam1);
        else
            
TrieSetCell(g_SteamszSteam2);
    }
    
    
fclose(file);
    
    
console_print(0"[AMXX] Loaded %d steams from file."TrieGetSize(g_Steam));
}

public 
client_putinserver(id) {
    new 
szSteam[33], iTeam;
    
    
get_user_authid(idszSteamcharsmax(szSteam));
    
    if(
TrieKeyExists(g_SteamszSteam)) {
        
TrieGetCell(g_SteamszSteamiTeam);
        
        if(
iTeam == 1)
            
rg_set_user_team(idTEAM_TERRORISTMODEL_AUTOtrue);
        else
            
rg_set_user_team(idTEAM_CTMODEL_AUTOtrue);
    }
    else
        
server_cmd("kick #%d ^"You Have No Entry To The Server^""get_user_userid(id));

in steamid.ini:
STEAM_ID = CT
STEAM_ID = TT
__________________
Discord:FluffyDeveloper#4753
Github: https://github.com/francoromaniello
AMX-ES: https://amxmodx-es.com/r0ma'

Last edited by r0ma; 10-26-2020 at 09:43.
r0ma is offline
Send a message via MSN to r0ma
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 17:40.


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