AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] auto side choose (https://forums.alliedmods.net/showthread.php?t=328086)

FarHaN_ShaiKh 10-26-2020 03:14

[Help] auto side choose
 
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);

        }
    }




r0ma 10-26-2020 09:42

Re: [Help] auto side choose
 
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


All times are GMT -4. The time now is 13:54.

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