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

IP based reserved slots + free reserve slots


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Gruzilkin
Junior Member
Join Date: Sep 2007
Plugin ID:
242
Plugin Version:
1.2
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Extends reserve slots plugin functionality by allowing admins to give reserved slots by IP and also by allowing players to register their steamids to get reserved slots themselves
    Old 12-30-2007 , 20:31   IP based reserved slots + free reserve slots
    Reply With Quote #1

    Description:
    This plugin can be useful for admins who have their servers working both in the internet and in some localnetwork, and they need to give local players a priority to join these servers without adding hundreds of steamids to reserved slots

    And there's more, admins may allow players to register reserved slots themselves... why would any admin want to do this? well, he may be lazy and he doesn't want to do it himself

    This plugin works by setting Admin_Reservation flag to clients who have:
    • IP from a specific network
    • SteamID reserved
    so it should work OK with any SM reserved slots manager

    Requirements:
    - SourceMod v1837 or higher

    Cvars:
    • sm_ips_allowselfregister - Allows people to use "regme" in chat to get a reserve slot for their SteamID
    • sm_ips_allowlisting - Allows people to use "ips" in chat to see the list of players with their networks shown

    Installation:
    place ips.smx into your sourcemod/plugins/ directory and internet.txt with lan.txt into /cstrike/ directory

    Configuration:
    you have to edit internet.txt and lan.txt to define your own networks
    lan.txt is used to check clients who have 10, 192 or 172 in the first byte of their IP address and internet.txt for the rest

    in my example it looks like this:
    PHP Code:
        "CrossNet*1"
        
    {
            
    "ip1"        "81.88.112.1"
            "ip2"        "81.88.127.254"
        

    ip1 and ip2 specify network range
    because ISP may have several network ranges, but they must have the same name, we can specify them by "CrossNet*1", "CrossNet*2" ... "CrossNet*N", you can see that in my example

    the last entry in this list must be 0.0.0.0 - 255.255.255.255, which will define default name (they are LAN and Internet)

    Changelog:
    Version 1.2
    - now works without altering reserved slots plugins
    Version 1.1
    - made some optimizations and cached handles
    - new version requires modified reserved slots plugin

    TODO:
    - make a single config for network ranges to make things easier... at first this plugin was using Event Scripts and I had to split networks list into 2 pieces to make it run faster, but there's no such need in SourceMod
    Attached Files
    File Type: txt internet.txt (1.7 KB, 1120 views)
    File Type: txt lan.txt (2.3 KB, 981 views)
    File Type: sp Get Plugin or Get Source (ips.sp - 2042 views - 5.6 KB)

    Last edited by Gruzilkin; 01-03-2008 at 22:50.
    Gruzilkin is offline
    Gruzilkin
    Junior Member
    Join Date: Sep 2007
    Old 12-31-2007 , 11:17   Re: IP based reserved slots + free reserve slots
    Reply With Quote #2

    mmm... there are some bugs with this version and I can't figure out how to fix them

    the problem is that function AddUserFlags works quite strange when it is called from OnClientPreAdminCheck in my plugin

    when admin joins the game, he has his admin flags overriden to "1" by this code... at first I thought that AddUserFlags didn't add them, but set them, so I changed the code to

    PHP Code:
    new clientFlags 0;
        
    clientFlags GetUserFlagBits(client);
        
    PrintToChat(client"old client flags: %d"clientFlags);
        
    clientFlags += ADMFLAG_RESERVATION;
        
    PrintToChat(client"new client flags: %d"clientFlags);
        
    SetUserFlagBits(clientclientFlags); 
    so typical output was:
    old client flags: 0
    new client flags: 1

    and if I check them later in the game they're still 1... if I use sm_reloadadmins command, my adminflags become 32768 again

    so I can't figure out what's wrong with this code... can somebody help me out?

    what happens to these admin flags when a player joins?
    Gruzilkin is offline
    pRED*
    Join Date: Dec 2006
    Old 12-31-2007 , 21:31   Re: IP based reserved slots + free reserve slots
    Reply With Quote #3

    I think the reason for this is that you are using 'OnClientPreAdminCheck' meaning that you are applying the flags before SourceMod has loaded admin access for this person.

    Applying the flag to the client creates them a temporary adminid and my guess is that SourceMod doesn't bother attempting to load permissions because an adminid already exists. Reloading all admins resets this (it destroys all adminid's and dumps the admin cache and rebuilds everything).

    As for a solution: Hm.

    You can use 'OnClientPostAdminCheck' which should work fine as far as assigning the flag goes (if i'm right). But.
    The current reserved slots plugin also uses 'OnClientPostAdminCheck' to decide if it's going to kick or not. Since theres no guaranteed order it would be completely up to luck whether this plugin manages to set the flag before the player gets kicked.

    I'll have a chat to BAIL about the possibility of introducing a new forward that gives third party plugins a chance to edit admin permissions before other plugins start reading them.
    pRED* is offline
    Gruzilkin
    Junior Member
    Join Date: Sep 2007
    Old 12-31-2007 , 22:24   Re: IP based reserved slots + free reserve slots
    Reply With Quote #4

    Quote:
    I'll have a chat to BAIL about the possibility of introducing a new forward that gives third party plugins a chance to edit admin permissions before other plugins start reading them.
    but isn't it OnClientPreAdminCheck that should allow plugins to change users flags?

    I think that there's no need in new natives, it's just default user flags assigning should be changed...

    this is from admin-sql-threaded.sp
    PHP Code:
    public Action:OnClientPreAdminCheck(client)
    {
        ...
        
    /**
         * If someone has already assigned an admin ID (bad bad bad), don't 
         * bother waiting.
         */
        
    if (GetUserAdmin(client) != INVALID_ADMIN_ID)
        {
            return 
    Plugin_Continue;
        }
        
        
    FetchUser(hDatabaseclient);
        
        return 
    Plugin_Handled;

    so maybe user flags assignment shouldn't skip clients who already have temporary admin id, or it should happen before OnClientPreAdminCheck ...
    and how can you do any adminchecks if there are no user flags at that moment?
    it may even be considered as a bug...

    I think that assigning user flags BEFORE OnClientPreAdminCheck would be more appropriate and will allow plugins to change user flags
    Gruzilkin is offline
    pRED*
    Join Date: Dec 2006
    Old 01-01-2008 , 01:03   Re: IP based reserved slots + free reserve slots
    Reply With Quote #5

    Quote:
    Originally Posted by Gruzilkin View Post
    I think that assigning user flags BEFORE OnClientPreAdminCheck would be more appropriate and will allow plugins to change user flags
    Uhh.. What?

    The Admin Check is when SourceMod assigns flags. The two forwards (pre and post) occur before and after this. If you assigned admin flags beforehand it wouldn't be 'Pre' any more...

    OnClientPreAdminCheck can be used to override flags settings, this is what the threaded sql plugin does. But in your case you want to wait until normal flags have been assigned and add an extra one. So you have to wait until OnClientPostAdminCheck, but still guarantee to be ahead of reservedslots.smx.
    pRED* is offline
    Gruzilkin
    Junior Member
    Join Date: Sep 2007
    Old 01-01-2008 , 08:56   Re: IP based reserved slots + free reserve slots
    Reply With Quote #6

    ok, I see now... so OnClientPreAdminCheck has another puspose and there's really no such function that I need in this case

    then I guess I have to wait for new forwards
    Gruzilkin is offline
    Gruzilkin
    Junior Member
    Join Date: Sep 2007
    Old 01-01-2008 , 08:57   Re: IP based reserved slots + free reserve slots
    Reply With Quote #7

    and before that happens I'll have to edit reserved slots plugin to make checks later in the game...
    Gruzilkin is offline
    Gruzilkin
    Junior Member
    Join Date: Sep 2007
    Old 01-03-2008 , 20:06   Re: IP based reserved slots + free reserve slots
    Reply With Quote #8

    version 1.2 works with the new 1837 sourcemod without any changes to other plugins, use of KeyValues was optimized and I couldn't find any bugs...
    Gruzilkin is offline
    GunMan_Galant
    New Member
    Join Date: May 2009
    Old 05-28-2009 , 06:33   Re: IP based reserved slots + free reserve slots
    Reply With Quote #9

    Hello all!

    Can someone help us with this plugin, please?

    We need to make something like this:
    - when player is connecting - plugin checks his IP
    - if player has IP 10.*.*.* - when all is ok - he can join the server
    - if his IP any other (apart from 10.*.*.*) - when plugin must check:
    --- if this player is first from 10 players like him - he can join;
    --- if this player is 9-10th - he can't join.

    I mean, that we have local dedicated server, and we want only 9-10 players could connect from the Internet (because of bandwidth), and all other slots can be used by our local players.

    Can someone help me to do this with this plugin, or may be write some code, our server admin will finish it...

    Thank you.
    GunMan_Galant is offline
    msleeper
    Veteran Member
    Join Date: May 2008
    Location: Atlanta, Jawjuh
    Old 05-28-2009 , 16:43   Re: IP based reserved slots + free reserve slots
    Reply With Quote #10

    I can't believe this plugin was ever approved, this is just pandering to nosteam users.
    __________________
    msleeper is offline
    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 20:12.


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