Ping check / kick

Users who are viewing this thread

hi !

i search how to check players ping and kick if to high.

I think its can do like TK kick/ban (http://forums.taleworlds.com/index.php/topic,133745.0.html) with a ping php script.

Someone can help me?

thx
 
(try_begin), 
(multiplayer_is_server),
(get_max_players,":num_players"),
(try_for_range,":cur_player",1,":num_players"),
(player_get_ping,":cur_player_ping"), 
(gt,":cur_player_ping",150),  #ping too low? change it
(kick_player,":cur_player"), 
(try_end),
(try_end),
i am srop.
http://srop.blogbus.com
 
module_mission_templates.py

multiplayer_dm
add:
(0,0,0,[],[
(try_begin), 
(multiplayer_is_server),
(get_max_players,":num_players"),
(try_for_range,":cur_player",1,":num_players"),
(player_get_ping,":cur_player_ping"), 
(gt,":cur_player_ping",150),  #ping too low? change it
(kick_player,":cur_player"), 
(try_end),
(try_end),
]),
 
player_get_ping                      = 437 # (player_get_ping, <destination>, <player_id>),
 
Use this. It's also a bit more optimized. It checks every 5 seconds each players ping and if any players ping is over 200, it kicks the player and displays a message to everyone.

Code:
(5, 0, 0, [],
[
    (multiplayer_is_server),
	
	#Loop through every player and check their ping.
	(get_max_players, ":max"),
	(try_for_range, ":i", 0, ":max"),
	    (player_is_active, ":i"),
		(player_get_ping, ":ping", ":i"),
		(gt, ":ping", 200), #Maximum ping: 200.
		
		#Inform.
		(str_store_player_username, s1, ":i"),
		(str_store_string, s2, "@[Server] {s1} kicked: high ping."),
		(display_message, s2, 0x999000),
		(server_add_message_to_log, s2),
	(try_end),
]),
 
Woops. I forgot the actual kicking command. Correct code below.

Code:
(5, 0, 0, [],
[
    (multiplayer_is_server),
	
	#Loop through every player and check their ping.
	(get_max_players, ":max"),
	(try_for_range, ":i", 0, ":max"),
	    (player_is_active, ":i"),
		(player_get_ping, ":ping", ":i"),
		(gt, ":ping", 200), #Maximum ping: 200.
		
		#Inform.
		(str_store_player_username, s1, ":i"),
		(str_store_string, s2, "@[Server] {s1} kicked: high ping."),
		(display_message, s2, 0x999000),
		(server_add_message_to_log, s2),
      (kick_player, ":i"),
	(try_end),
]),
 
Mission templates, under the template what your server will run.
 
Code:
#This in mission templates.
(5, 0, 0, [],
[
    (multiplayer_is_server),
	
	#Loop through every player and check their ping.
	(get_max_players, ":max"),
	(try_for_range, ":i", 0, ":max"),
	    (player_is_active, ":i"),
		(player_get_ping, ":ping", ":i"),
		(gt, ":ping", 200), #Maximum ping: 200.
		
		#Inform.
		(str_store_player_username, s1, ":i"),
		(str_store_string, s0, "@[Server] {s1} kicked: high ping."),
		(try_for_range, ":j", 0, ":max"),
		    (player_is_active, ":j"),
			(multiplayer_send_string_to_player, ":j", client_display_message, s0),
		(try_end),
		(server_add_message_to_log, s0),
        (kick_player, ":i"),
	(try_end),
]),

#This in module_scripts.py to game_receive_network_message, client-side events.
(eq, ":event_type", client_display_message),
(display_message, s0, 0x999000),
 
Back
Top Bottom