PDA

View Full Version : IP based reserved slots + free reserve slots


Gruzilkin
12-30-2007, 20:31
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:
"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

Gruzilkin
12-31-2007, 11:17
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

new clientFlags = 0;
clientFlags = GetUserFlagBits(client);
PrintToChat(client, "old client flags: %d", clientFlags);
clientFlags += ADMFLAG_RESERVATION;
PrintToChat(client, "new client flags: %d", clientFlags);
SetUserFlagBits(client, clientFlags);

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?

pRED*
12-31-2007, 21:31
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.

Gruzilkin
12-31-2007, 22:24
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
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(hDatabase, client);

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

pRED*
01-01-2008, 01:03
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.

Gruzilkin
01-01-2008, 08:56
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
01-01-2008, 08:57
and before that happens I'll have to edit reserved slots plugin to make checks later in the game...

Gruzilkin
01-03-2008, 20:06
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...

GunMan_Galant
05-28-2009, 06:33
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... :wink:

Thank you.

msleeper
05-28-2009, 16:43
I can't believe this plugin was ever approved, this is just pandering to nosteam users.

CS:S*
06-10-2009, 13:38
Can you pls tell me where the id-s are stored ?? I don't want to give everyone to register their id's i just want to set certain people.And I also I would like to turn off advertising because i already have another plugin which does this 4 me ...


Tnx for this plugin and I hope we can fix this soon :)