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

private server.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
loadrino
Junior Member
Join Date: May 2015
Old 05-29-2015 , 00:52   private server.
Reply With Quote #1

Hello everyone, i need a plugin for kick every people who connect on server with an exception of some steamids, i was wondering if could uses the reservation slot plugin with lower flags.
ps: i've tried to search before but i didnt found any good keywords to search something like this.
loadrino is offline
secondtimesold
Senior Member
Join Date: Feb 2015
Old 05-29-2015 , 01:00   Re: private server.
Reply With Quote #2

why not just use a password on server?
__________________
secondtimesold is offline
Toastbrot_290
SourceMod Donor
Join Date: Apr 2013
Old 05-29-2015 , 01:41   Re: private server.
Reply With Quote #3

Try it with the keyword whitelist. There are plugins like that one that you would like to have.
__________________

Last edited by Toastbrot_290; 05-29-2015 at 01:41.
Toastbrot_290 is offline
loadrino
Junior Member
Join Date: May 2015
Old 05-29-2015 , 03:18   Re: private server.
Reply With Quote #4

Quote:
Originally Posted by secondtimesold View Post
why not just use a password on server?
because i just manage the servers, and it up to 100 ppl at same time, everytime someone else just tell the password for some friend who arent to be there, so i need to spend time to connect to server and check out the "whitelist" steamids and if needed kick him, something with an auto kick will be perfect.
Quote:
Originally Posted by Toastbrot_290 View Post
Try it with the keyword whitelist. There are plugins like that one that you would like to have.
i've tried this one, it's pretty usualy word on most of topics, sure probably that one exist on forum but so deep :/
loadrino is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 05-29-2015 , 04:03   Re: private server.
Reply With Quote #5

I made that for you, make sure to create a new config file called 'ServerWhiteList.txt' in your config folder. He should contains STEAMIDs of allowed user (In any format you want, this mean 2,3 and 64 format !).

EDIT:
Oh and you can use sm_reloadwhitelist to reload the whitelist.

EDIT #2:
Updated to match with Asherkin advices.

PHP Code:
#include <sourcemod>

Handle ListSteamID INVALID_HANDLE;
char listKey[55];

public 
Plugin:myinfo =
{
    
name        "Server locker",
    
author      "Arkarr",
    
description "An alternative to make your servers private",
    
version     "0.1",
    
url         "http://www.sourcemod.net"
};

public 
void OnPluginStart()
{
    
    
RegAdminCmd("sm_reloadwhitelist"CMD_ReloadWhiteListADMFLAG_ROOT"Reload the white list.");
    
    
ListSteamID CreateTrie();
    
ReadConfigFile();
    
    
PrintToServer("*** SERVER IS IN PRIVATE MODE ! ***");
}

public 
void OnClientAuthorized(client)
{
     
char steamID[50];
     
char clientSteamID2[50];
     
char clientSteamID3[50];
     
char clientSteamID64[50];
     
GetClientAuthId(clientAuthId_Steam2clientSteamID2sizeof(clientSteamID2));
     
GetClientAuthId(clientAuthId_Steam3clientSteamID3sizeof(clientSteamID3));
     
GetClientAuthId(clientAuthId_SteamID64clientSteamID64sizeof(clientSteamID64));
     
     for(
int i 0GetArraySize(ListSteamID); i++)
     {
        
Format(listKeysizeof(listKey), "SteamID#%i"i);
         
GetTrieString(ListSteamIDlistKeysteamIDsizeof(steamID));
         if(
StrEqual(steamIDclientSteamID2) || StrEqual(steamIDclientSteamID3) || StrEqual(steamIDclientSteamID64) )
        {
            
KickClient(client"You are not allowed to join this server !");
        }
     }
}

public 
Action CMD_ReloadWhiteList(clientargs)
{
    
PrintToServer("*** RELOADING THE SERVER WHITLIST ***");
    
    
ReadConfigFile();
    
    
PrintToServer("*** DONE ! ***");
    
    return 
Plugin_Handled;
}

public 
void ReadConfigFile()
{
    
int index;
    
ClearTrie(ListSteamID);
    
decl String:path[PLATFORM_MAX_PATH],String:line[128];
    
BuildPath(Path_SM,path,PLATFORM_MAX_PATH,"config/ServerWhiteList.txt");
    new 
Handle:fileHandle=OpenFile(path,"r");
    while(
ReadFileLine(fileHandle,line,sizeof(line)))
    {
        
Format(listKeysizeof(listKey), "SteamID#%i"index);
        
SetTrieString(ListSteamIDlistKeylinefalse);
        
index++;
    }
    
CloseHandle(fileHandle);

__________________
Want to check my plugins ?

Last edited by Arkarr; 05-29-2015 at 07:33. Reason: Updated to match with Asherkin advices.
Arkarr is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-29-2015 , 06:12   Re: private server.
Reply With Quote #6

  1. You can't get a client's steamid before OnClientAuthorized.
  2. Use StringMap, your implementation there will get slower as more steamids are added.
  3. You can just use ReadFileLine, it returns false on EOF.
  4. Your CMD_ReloadWhiteList function is missing a return statement.
__________________

Last edited by asherkin; 05-29-2015 at 06:14.
asherkin is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 05-29-2015 , 07:16   Re: private server.
Reply With Quote #7

Quote:
Originally Posted by asherkin View Post
  1. You can't get a client's steamid before OnClientAuthorized.
  2. Use StringMap, your implementation there will get slower as more steamids are added.
  3. You can just use ReadFileLine, it returns false on EOF.
  4. Your CMD_ReloadWhiteList function is missing a return statement.
Right right right, so much erros I should have take more time to do that.

EDIT:
Mind to check if it's better now ?
__________________
Want to check my plugins ?

Last edited by Arkarr; 05-29-2015 at 07:29.
Arkarr is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-29-2015 , 10:52   Re: private server.
Reply With Quote #8

Quote:
Originally Posted by Arkarr View Post
Mind to check if it's better now ?
That's just using the StringMap as an array - store the config file lines as the map keys (you probably also want to call TrimString first).
__________________
asherkin is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 05-29-2015 , 10:57   Re: private server.
Reply With Quote #9

Quote:
Originally Posted by asherkin View Post
That's just using the StringMap as an array - store the config file lines as the map keys (you probably also want to call TrimString first).
I don't understand this. I should store the steamIDs into a keyvalue file ? Something like that ?
__________________
Want to check my plugins ?
Arkarr is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-29-2015 , 11:20   Re: private server.
Reply With Quote #10

Quote:
Originally Posted by Arkarr View Post
I don't understand this. I should store the steamIDs into a keyvalue file ? Something like that ?
Not tested, but something like this:
PHP Code:
#pragma semicolon 1
#pragma newdecls required

StringMap whitelist;

public 
void OnPluginStart()
{
    
whitelist = new StringMap();
    
    
RegAdminCmd("sm_reloadwhitelist"OnReloadWhitelistADMFLAG_GENERIC"Reload the whitelist.");
    
    
OnReloadWhitelist(00);
}

public 
Action OnReloadWhitelist(int clientint args)
{
    
char path[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMpathsizeof(path), "configs/server_whitelist.txt");
    
    
File whitelistFile OpenFile(path"r");
    if (!
whitelistFile) {
        
ReplyToCommand(client"Failed to open whitelist file. (%s)"path);
        
        return 
Plugin_Handled;
    }
    
    
whitelist.Clear();
    
    
int count;
    
char line[64];
    while (
whitelistFile.ReadLine(linesizeof(line))) {
        
TrimString(line);
        
        if (
line[0] == '\0' || line[0] == '#') {
            continue;
        }
        
        
whitelist.SetValue(linetrue);
        
        
count++;
    }
    
    
delete whitelistFile;
    
    
ReplyToCommand(client"Reloaded whitelist with %d entries."count);
    
    return 
Plugin_Handled;
}

public 
void OnClientAuthorized(int client, const char[] auth)
{
    
char steamid[64];
    
int unused;
    
    if (
GetClientAuthId(clientAuthId_Steam2steamidsizeof(steamid)) && whitelist.GetValue(steamidunused)) {
        return;
    }
    
    if (
GetClientAuthId(clientAuthId_Steam3steamidsizeof(steamid)) && whitelist.GetValue(steamidunused)) {
        return;
    }
    
    if (
GetClientAuthId(clientAuthId_SteamID64steamidsizeof(steamid)) && whitelist.GetValue(steamidunused)) {
        return;
    }
    
    
KickClient(client"Not on whitelist.");

__________________

Last edited by asherkin; 05-29-2015 at 19:36. Reason: Moved whitelist file.
asherkin 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 12:19.


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