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

[EXTENSION] CBaseServer (+ Detouring class) - Reserved Slots with 0 wasted slots


Post New Thread Reply   
 
Thread Tools Display Modes
Acksull
Member
Join Date: Jul 2008
Old 07-20-2009 , 13:44   Re: [EXTENSION] CBaseServer (+ Detouring class) - Reserved Slots with 0 wasted slots
Reply With Quote #411

Same problem as derigg. I have everything installed, admin.cfg set up... try to connect through console when my server is 32/32 and still get "Server is full" message.

windows hlds 1.0.6.2
sm 1.2.1
mm 1.7.1
__________________
Axl's TF2 - Where 2fort is a BAD thing.
66.150.188.34:27015
Acksull is offline
MoggieX
Veteran Member
Join Date: Aug 2007
Location: n00bville
Old 07-20-2009 , 14:51   Re: [EXTENSION] CBaseServer (+ Detouring class) - Reserved Slots with 0 wasted slots
Reply With Quote #412

Yea same here too, just tested it properly and responds back with "Server is Full", plugin and ext loaded (multiple TF2 servers)

SM V1.2.1

Matt
__________________

Last edited by MoggieX; 07-20-2009 at 17:58.
MoggieX is offline
Send a message via Skype™ to MoggieX
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 07-20-2009 , 22:21   Re: [EXTENSION] CBaseServer (+ Detouring class) - Reserved Slots with 0 wasted slots
Reply With Quote #413

It works fine for me on Windows TF2.
__________________

DontWannaName is offline
MoggieX
Veteran Member
Join Date: Aug 2007
Location: n00bville
Old 07-21-2009 , 04:13   Re: [EXTENSION] CBaseServer (+ Detouring class) - Reserved Slots with 0 wasted slots
Reply With Quote #414

Quote:
Originally Posted by DontWannaName View Post
It works fine for me on Windows TF2.
heya,

What version of SM are you running?

Matt
__________________
MoggieX is offline
Send a message via Skype™ to MoggieX
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 07-21-2009 , 04:14   Re: [EXTENSION] CBaseServer (+ Detouring class) - Reserved Slots with 0 wasted slots
Reply With Quote #415

I am running the latest 1.3 snapshot.
__________________

DontWannaName is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-21-2009 , 07:37   Re: [EXTENSION] CBaseServer (+ Detouring class) - Reserved Slots with 0 wasted slots
Reply With Quote #416

It also works fine for me on Windows TF2 using SM 1.2.1
psychonic is offline
deriggs007
Senior Member
Join Date: May 2009
Location: USA
Old 07-21-2009 , 13:01   Re: [EXTENSION] CBaseServer (+ Detouring class) - Reserved Slots with 0 wasted slots
Reply With Quote #417

It works fine on my windows server, it works fine on my gameservers.com linux

and then it doesn't work on my 2 new Linux server...
deriggs007 is offline
Send a message via MSN to deriggs007
MoggieX
Veteran Member
Join Date: Aug 2007
Location: n00bville
Old 07-21-2009 , 18:04   Re: [EXTENSION] CBaseServer (+ Detouring class) - Reserved Slots with 0 wasted slots
Reply With Quote #418

Quote:
Originally Posted by MoggieX View Post
Yea same here too, just tested it properly and responds back with "Server is Full", plugin and ext loaded (multiple TF2 servers)

SM V1.2.1

Matt
I take it back, I am a pr0 n00b, for anyone else, don't forget to install the cbaseserver.so or dll files as well.

ffs Matt
__________________
MoggieX is offline
Send a message via Skype™ to MoggieX
deriggs007
Senior Member
Join Date: May 2009
Location: USA
Old 07-21-2009 , 18:09   Re: [EXTENSION] CBaseServer (+ Detouring class) - Reserved Slots with 0 wasted slots
Reply With Quote #419

yes, those came with the package and I merely added the whole package and it's in there, it shows it's loaded in both SM plugins and sm exts

But no... still doesn't work and I haven't seen any other insight to this
deriggs007 is offline
Send a message via MSN to deriggs007
MoggieX
Veteran Member
Join Date: Aug 2007
Location: n00bville
Old 07-22-2009 , 12:22   Re: [EXTENSION] CBaseServer (+ Detouring class) - Reserved Slots with 0 wasted slots
Reply With Quote #420

Quote:
Originally Posted by pRED* View Post
Note2: If you are using threaded sql admins this won't work because It cant instantly check if a steamid is an admin.
This was a problem for us as I didn't want to move back to using non threaded admins due to the numbers we have.

So instead I have altered pRED*'s plugin to make a non threaded check when a player connects and the server is full.

So if you like us use threaded admins, you can now have your cake and eat it.

Instructions:
Its a straight replacement, drop in the smx file and either changemaps or run sm plugins reload cbaseservertest in the console.

If you have problems, use sm_cvar cb_rs_mysql 1 and then with a full server attempt to connect, it will leave messages behind in your log file accordingly.

Code, noting it will not compile via the "Get Plugin" option as it needs the cbaseserver include file
PHP Code:
/**
*
*    cbaseservertest by pRED*
*     MysQL Checking Option added by |UKMD| MoggieX
*
*/

#include <sourcemod>
#include "include/cbaseserver.inc"

enum KickType
{
    
Kick_HighestPing,
    
Kick_HighestTime,
    
Kick_Random,    
};

new 
g_maxClients;
new 
sdkVersion;
new 
Handle:g_IpTrie;

//Added for MySQL Checks
new Handle:ErrorChecking        INVALID_HANDLE;
new 
Handle:MySQLCheck            INVALID_HANDLE;
new 
bool:IsAllowed            false;

public 
OnPluginStart()
{
    
sdkVersion GuessSDKVersion();
    
g_IpTrie CreateTrie();
    
ErrorChecking     CreateConVar("cb_rs_ec","0","Error Checking CVar, 0= don't show, 1 = show");
    
MySQLCheck         CreateConVar("cb_rs_mysql","1","MySQLCheck CVar, 1 = Enabled ");
    
    
//Also added here for starting when aready running
    
g_maxClients GetMaxClients();

}

public 
OnMapStart()
{
    
g_maxClients GetMaxClients();    
}

public 
OnClientPostAdminCheck(client)
{
    
decl String:ip[32];
    
GetClientIP(clientipsizeof(ip));
    
decl String:auth[32];
    
GetClientAuthString(clientauthsizeof(auth));
    
    new 
flags GetUserFlagBits(client);
    
    if (
flags ADMFLAG_RESERVATION)
    {
        
SetSteamForIp(ipauth);
    }
}

public 
OnClientPreConnect(const String:name[], const String:pass[], const String:ip[], const String:authid[])
{
    if (
GetClientCount(false) < g_maxClients)
    {
        return;    
    }

    new 
AdminId:admin;

    
///////////////////////////////////
    //    Inserted Code
    //////////////////////////////////
    
if(GetConVarInt(MySQLCheck) == 1)
    {
        
/* Error Checking */
        
if (GetConVarInt(ErrorChecking) == 1)
        {
            
PrintToServer("[CBS Res Slots] MySQL Function Started");
            
LogAction(0, -1"[CBS Res Slots] MySQL Function Started");
        }

        
decl String:error[255];        // Error!
        // Open connection
        
new Handle:db SQL_Connect("default"trueerrorsizeof(error));
        if (
db == INVALID_HANDLE)
        {
            
/* Error Checking */
            
if (GetConVarInt(ErrorChecking) == 1)
            {
                
PrintToServer("[CBS Res Slots] Could Not Connect to Database, error: %s"error);
                
LogError("[CBS Res Slots] Could Not Connect to Database, error: %s"error);
            }
            
CloseHandle(db);
            return;
        }
    
        
// db connection OK carry on
        
decl String:query[255]
        new 
Handle:hQuery;

        
Format(querysizeof(query), "SELECT flags FROM sm_admins WHERE identity ='%s'"authid);
        if ((
hQuery SQL_Query(dbquery)) == INVALID_HANDLE)
        {
            
SQL_GetError(dberrorsizeof(error));
            
LogError("[CBS Res Slots] query failed: %s"query);
            return;
        }

        
// Not and admin BAIL (added first as I expect this is more common)
        
if (!SQL_FetchRow(hQuery))
        {
            
CloseHandle(hQuery);
            return;
        }
        else
        {
            
decl String:UserFlags[24];            // UserFlags
            
SQL_FetchString(hQuery,0UserFlagssizeof(UserFlags));
            if (
StrContains(UserFlags"b") || StrContains(UserFlags"z"))
            {
                if (
GetConVarInt(ErrorChecking) == 1)
                {
                    
// You WIN!
                    
LogAction(0, -1"[CBS Res Slots] An Admin PASSSED admin checks");
                    
PrintToServer("[CBS Res Slots] An Admin PASSSED admin checks");
                }
                
IsAllowed true;
                
CloseHandle(hQuery);
            }
            else
            {
                if (
GetConVarInt(ErrorChecking) == 1)
                {
                    
// You FAIL!
                    
PrintToServer("[CBS Res Slots] An player FAILED admin checks");
                    
LogAction(0, -1"[CBS Res Slots] An Admin FAILED admin checks");
                }
                
CloseHandle(hQuery);
                return;
            }

        }
    }
    
// Not MySQLCheck Enabled, same code as original
    
else
    {
        if (
sdkVersion SOURCE_SDK_EPISODE2)
        {
            
decl String:guessedSteamId[32];
            if (!
GetSteamFromIP(ipguessedSteamIdsizeof(guessedSteamId)))
            {
            return;
            }
            
            
PrintToServer("PreConnect From %s (%s) matched to %s"ipnameauthid);

            
admin FindAdminByIdentity(AUTHMETHOD_STEAMguessedSteamId);
            
            
decl String:AdminPass[32];
            if (
admin != INVALID_ADMIN_ID && GetAdminPassword(adminAdminPasssizeof(AdminPass)))
            {
                
/* User has a password set */
                
if (!StrEqual(AdminPasspass))
                {
                    return;    
                }    
            }
        }
        else
        {
            
admin FindAdminByIdentity(AUTHMETHOD_STEAMauthid);
        }
        if (
admin == INVALID_ADMIN_ID)
        {
            return;
        }
    }

    
// If they've got this far they're almost a winner!
    
if (GetAdminFlag(adminAdmin_Reservation) || IsAllowed == true)
    {
        if (
GetConVarInt(ErrorChecking) == 1)
        {
            
// You FAIL!
            
PrintToServer("[CBS Res Slots] A player has been picked to be kicked to make room");
            
LogAction(0, -1"[CBS Res Slots] A player has been picked to be kicked to make room");
        }

        new 
target SelectKickClient();
                        
        if (
target)
        {
            
KickClientEx(target"Slot reserved");
        }
    }
}

SelectKickClient()
{
    new 
KickType:type Kick_HighestPing;
    
    new 
Float:highestValue;
    new 
highestValueId;
    
    new 
Float:highestSpecValue;
    new 
highestSpecValueId;
    
    new 
bool:specFound;
    
    new 
Float:value;
    
    new 
maxclients GetMaxClients();
    
    for (new 
i=1i<=maxclientsi++)
    {    
        if (!
IsClientConnected(i))
        {
            continue;
        }
    
        new 
flags GetUserFlagBits(i);
        
        if (
IsFakeClient(i) || flags ADMFLAG_ROOT || flags ADMFLAG_RESERVATION || CheckCommandAccess(i"sm_reskick_immunity"ADMFLAG_RESERVATIONfalse))
        {
            continue;
        }
        
        
value 0.0;
            
        if (
IsClientInGame(i))
        {
            if (
type == Kick_HighestPing)
            {
                
value GetClientAvgLatency(iNetFlow_Outgoing);
            }
            else if (
type == Kick_HighestTime)
            {
                
value GetClientTime(i);
            }
            else
            {
                
value GetRandomFloat(0.0100.0);
            }

            if (
IsClientObserver(i))
            {            
                
specFound true;
                
                if (
value highestSpecValue)
                {
                    
highestSpecValue value;
                    
highestSpecValueId i;
                }
            }
        }
        
        if (
value >= highestValue)
        {
            
highestValue value;
            
highestValueId i;
        }
    }
    
    if (
specFound)
    {
        return 
highestSpecValueId;
    }
    
    return 
highestValueId;
}

bool:GetSteamFromIP(const String:ip[], String:steam[], len)
{
    return 
GetTrieString(g_IpTrieipsteamlen);
}

bool:SetSteamForIp(const String:ip[], const String:steam[])
{
    return 
SetTrieString(g_IpTrieipsteamtrue);

Matt
Attached Files
File Type: sp Get Plugin or Get Source (cbaseservertest.sp - 179 views - 5.8 KB)
File Type: smx cbaseservertest.smx (5.3 KB, 182 views)
__________________

Last edited by MoggieX; 07-22-2009 at 12:27. Reason: Added smx as cbaseserver.inc not in web compiler
MoggieX is offline
Send a message via Skype™ to MoggieX
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 21:06.


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