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

Kick player before he starts downloading map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dachtone
Junior Member
Join Date: Mar 2016
Location: Moscow
Old 03-22-2016 , 16:58   Kick player before he starts downloading map
Reply With Quote #1

Hello guys, I've been searching here for the answer to my question, but I did't find it. So I thought maybe you'll help me. I've tried to kick specific player using forward OnClientConnected, but it turned out that map downloads before that. I will be happy if someone knows how to do this.
P.S.: Don't be mad at my grammar, I'm from not English speaking country

Last edited by headline; 10-13-2017 at 12:05.
Dachtone is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 03-22-2016 , 17:19   Re: Kick player before he starts downloading map
Reply With Quote #2

Quote:
Originally Posted by Dachtone View Post
Hello guys, I've been searching here for the answer to my question, but I did't find it. So I thought maybe you'll help me. I've tried to kick specific player using forward OnClientConnected, but it turned out that map downloads before that. I will be happy if someone knows how to do this.
P.S.: Don't be mad at my grammar, I'm from not English speaking country
You can do it in OnClientConnect, though at this state you may not have a valid Steam ID yet.

The Connect extension should give you another forward, from where you can actually get a proper validated Steam ID, if required.


Out of curiosity, what is the reason for your wish of this kind of thing?
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Dachtone
Junior Member
Join Date: Mar 2016
Location: Moscow
Old 03-22-2016 , 17:26   Re: Kick player before he starts downloading map
Reply With Quote #3

I am doing some testing on my gamemode and for this I've made a plugin that allows only specific players to connect to the testing server. That plugin checks if player is a member of my private steam group. I don't want everybody to download a map for this gamemode, so that's why I need to figure out how to do this.

Thanks for helping, will try this out tomorrow.

Last edited by Dachtone; 03-22-2016 at 17:29.
Dachtone is offline
Dachtone
Junior Member
Join Date: Mar 2016
Location: Moscow
Old 03-23-2016 , 09:57   Re: Kick player before he starts downloading map
Reply With Quote #4

I've tried, and I think it's impossible. When client connects, the plugins checks if player is a member of my group and if not kicks him. I think it's just not possible to do this check and kick before he starts downloading map.
Dachtone is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 03-23-2016 , 13:20   Re: Kick player before he starts downloading map
Reply With Quote #5

Quote:
Originally Posted by Dachtone View Post
I've tried, and I think it's impossible. When client connects, the plugins checks if player is a member of my group and if not kicks him. I think it's just not possible to do this check and kick before he starts downloading map.
Could you eventually share your full code?

If you are not doing the group checks through some asynchronous way, it may cause small lags every time someone (attempts to) join the game.

Check the group stuff in real time and asynchronously while joining, the group check won't be "waiting" for the answer before proceeding with the next code, and as such, the user may already have downloaded certain things before the final result (e.g. acceptance / rejection) kicks in.

It will be impossible to share any alternate thoughts / suggestions for optimizations, unless you share your full code.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Dachtone
Junior Member
Join Date: Mar 2016
Location: Moscow
Old 03-23-2016 , 13:43   Re: Kick player before he starts downloading map
Reply With Quote #6

Here is the part of my code:
PHP Code:
public OnClientConnected(client// I've tried many forwards, that one is just there
{
    
isConnecting[client] = true// that var is used for displaying a message if players was connecting, not kicked on other events
    
CheckServerAccess(client);
}

public 
OnClientDisconnect(client)
{
    
isConnecting[client] = false;
}

CheckServerAccess(client)
{
    if (
IsValidClient(client))
    {
        if (!
Steam_RequestGroupStatus(clientACCESS_GROUP))
        {
            
KickClient(client"You don't have access!"); // if connection to Steam fails, this will prevent players from connecting to the server
        
}
    }
}

public 
Steam_GroupStatusResult(clientgroupAccountIDbool:groupMemberbool:groupOfficer)
{
    if (
groupAccountID == ACCESS_GROUP)
    {
        if (
IsValidClient(client))
        {
            if (!
groupMember)
            {
                
KickClient(client"You don't have access!");
            }
            else if (
isConnecting[client])
            {
                
PrintToChatAll("Player %N has been checked."client);
            }
        }
    }
    
isConnecting[client] = false;


Last edited by Dachtone; 03-23-2016 at 13:43.
Dachtone is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 03-23-2016 , 14:41   Re: Kick player before he starts downloading map
Reply With Quote #7

Why not just put a password on the server and have said password be within a private announcement within the private Steam Group?
Darkness_ is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 03-23-2016 , 15:02   Re: Kick player before he starts downloading map
Reply With Quote #8

SteamWoirks (and SteamTools) uses an asynchronous way, so I hardly doubt that way will ever get to work as you want it to.

The group you want to check against, is it a big or small group on Steam?

You could eventually through OnConfigsExecuted (or OnMapStart) or something fetch your Steam group and "cache" it on the server until next time a map starts or similar. However, the Steam XML feed with group members seem to become unreliable when you have bigger groups and need to fetch multiple pages to get them all.

Then using the Connect extension as explained above, you could check if that Steam ID is a part of the list, and if not, return false.

I believe that would be the best shot at gaining the functionality you want, but again, it won't check the member status in real time.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Dachtone
Junior Member
Join Date: Mar 2016
Location: Moscow
Old 03-23-2016 , 15:12   Re: Kick player before he starts downloading map
Reply With Quote #9

I don't want password because people can easily tell it to others.

The group is for like 10-15 people, so it's pretty small. Will try getting member list on map start. If it will be something workable, I'll post the code here.

Thanks for helping, again.
Dachtone is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-24-2016 , 11:18   Re: Kick player before he starts downloading map
Reply With Quote #10

You're going to need the CBaseServer extension or Connect extension for their OnClientPreConnect callback in order to check the SteamID early enough.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 03-24-2016 at 11:20.
Powerlord 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 23:06.


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