Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Silkroad Online > SRO Private Server
You last visited: Today at 18:42

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C#] Disconnecting a spacific player

Discussion on [C#] Disconnecting a spacific player within the SRO Private Server forum part of the Silkroad Online category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2015
Posts: 150
Received Thanks: 6
[C#] Disconnecting a spacific player

Hello elites,
as title says i wanna disconnect a spacific player how should i do that?
Kardil is offline  
Old 05/07/2016, 18:31   #2

 
AceSpace's Avatar
 
elite*gold: 21
Join Date: Mar 2011
Posts: 1,613
Received Thanks: 1,122
Well if it's a filter, try creating a list and add every player on it aka PlayersList.Add(this); etc
Then make a loop or use linq.

Like:
Code:
for (int i =0; i < PlayersList.Count; i++)
{
if (PlayersList[i].CharName == ""Kardil") //example
   PlayersList[i].Disconnect(); // call disconnect
}
or LINQ:
Code:
var Player = PlayersList.Where(p => p.CharName == "Kardil");
Player.Disconnect();
Though the list must be in a different class from the class which handles the player packets etc aka the base itself.
AceSpace is offline  
Thanks
1 User
Old 05/07/2016, 19:23   #3
 
elite*gold: 0
Join Date: Sep 2015
Posts: 150
Received Thanks: 6
Thanks alot, iam really use a list but seems i couldn't be obvious enough
iam asking about that part

PHP Code:
PlayersList[i].Disconnect(); 
The Disconnect function itself, how it works? i heard that it working with a socket and i have it but it's disconnecting everyone in the server, i mean i can't determine just one player to let that socket work on him only.

hope iam obvious this time.
Kardil is offline  
Old 05/08/2016, 12:59   #4

 
AceSpace's Avatar
 
elite*gold: 21
Join Date: Mar 2011
Posts: 1,613
Received Thanks: 1,122
Quote:
Originally Posted by Kardil View Post
Thanks alot, iam really use a list but seems i couldn't be obvious enough
iam asking about that part

PHP Code:
PlayersList[i].Disconnect(); 
The Disconnect function itself, how it works? i heard that it working with a socket and i have it but it's disconnecting everyone in the server, i mean i can't determine just one player to let that socket work on him only.

hope iam obvious this time.
Socket.Close();?
And you need to create a new instance for every new connection for it to have it's own socket.
AceSpace is offline  
Thanks
1 User
Old 05/09/2016, 14:17   #5
 
elite*gold: 0
Join Date: Sep 2015
Posts: 150
Received Thanks: 6
Quote:
Originally Posted by Skipper* View Post
Socket.Close();?
And you need to create a new instance for every new connection for it to have it's own socket.
Yes that's exactly what am trying to say/to do but i don't have an idea how to do that
When i send that everyone disconnects not just the one i want

So any guide or good hint?
Kardil is offline  
Old 05/09/2016, 17:49   #6

 
sarkoplata's Avatar
 
elite*gold: 166
Join Date: Apr 2009
Posts: 2,339
Received Thanks: 2,661
Quote:
Originally Posted by Kardil View Post
Yes that's exactly what am trying to say/to do but i don't have an idea how to do that
When i send that everyone disconnects not just the one i want

So any guide or good hint?
Find the player's instance's client socket and close it...
PlayersList[i].ClientSocket.Close();

it doesn't get any easier than that
sarkoplata is offline  
Thanks
1 User
Old 05/10/2016, 06:10   #7

 
MeGaMaX's Avatar
 
elite*gold: 29890
Join Date: Sep 2006
Posts: 1,086
Received Thanks: 2,566
get his CharName > UserID > SMC > UserControl > put UserID press Query find his userid press ban xD ? or simply put his ip in windows firewall for a sec , im kidding btw xD.

//Get the player client socket and close it !
MeGaMaX is offline  
Thanks
1 User
Old 05/10/2016, 06:21   #8

 
AceSpace's Avatar
 
elite*gold: 21
Join Date: Mar 2011
Posts: 1,613
Received Thanks: 1,122
Alright I made a fast project to see you how it works. I attached it below, open it with VS & see how it works.

Commands => /begin - will add players to list
/disconnect - will dc player based on number of player
/list - will list current online players
/count - will tell you the count of the online players

This couldn't be any easier..
Attached Files
File Type: rar Example.rar (29.7 KB, 26 views)
AceSpace is offline  
Thanks
2 Users
Old 05/12/2016, 23:52   #9
 
elite*gold: 0
Join Date: Sep 2015
Posts: 150
Received Thanks: 6
I could do it, Thanks everyone here it's appreciated.
Kardil is offline  
Old 07/16/2016, 16:05   #10
 
elite*gold: 0
Join Date: Jul 2016
Posts: 37
Received Thanks: 4
First you should make a loop and define i as integer and = 0 . as shown then use the if condition
for (int i =0; i < PlayersList.Count; i++)
{
if (PlayersList[i].CharName == ""Kardil") //example
PlayersList[i].Disconnect(); // call disconnect
}
PlayIGNITE is offline  
Reply


Similar Threads Similar Threads
Disconnecting others
09/07/2013 - Need for Speed World - 6 Replies
Is this something, someone here made, being able to temp ban players after a race? It's all around the place.
Disconnecting
05/03/2013 - SRO Private Server - 4 Replies
Hey, I have started up a priv server for me and a few mates. But every 5-10 minutes after login we get disconnected. I was wondering if any1 know a solution to it. All help is appreciated.
I keep on disconnecting.
07/14/2008 - Dekaron - 4 Replies
the report bug keep on poping up is there a way to fix this.
[QUESTION]DOES ANYONE KNOWS OF FORCIBLY DISCONNECTING A PLAYER?
04/10/2008 - Perfect World - 1 Replies
uhm this may sound weird. but does anyone knows of forcibly disconnecting a targeted player from a game? i believe if you flood the targeted player's IP with packets it couldnt understand it might force a player's client to disconnect just to refresh. like when you use CE and you got it wrong and the client just cant understand what to do with your edits and just disconnects you from the game.. i've seen this "bug" being done in some old 2d mmo's and uses a trick during a trade...
disconnecting
04/03/2008 - Dekaron - 3 Replies
ok so i was able to downloed the full client but after installing i logged in. and my problem is i get disconnected after 3-5 secs of appearing at loa castle. cant even play with this problem. do you guys have any solutions. thanks for your help and response!



All times are GMT +1. The time now is 18:45.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.