OSP Code MP Whitelist system

Users who are viewing this thread

domipoppe

Knight
Old Guard
I DIDN'T TEST IT YET! Please someone test it & respond to me if it works. If it doesn't then I will fix it asap!

Hey, I was a bit bored & I thought people could need it. What is it? A very simple GUID whitelisting system. You need a webhost (only apache needed no mysql) & a gameserver with your edited MS (doesn`t matter what MS).

How does it work? Basically the webserver contains a .PHP file & a .txt file. In the text file are all whitelisted GUID's. If the player's GUID is not included there then he get kicked & if it's included then he can join without any problems. The server console will show a message if a player is whitelisted or not.

For who? It could be useful for clans, roleplay servers, event servers etc.

How do I add a GUID? You open whitelist.txt & you add following in it: "GUID;". Don't forget the ";" it`s a important seperator.
A working & good list would look like this: 213123;151234;12356;334134;

What I need to do? Just follow the instructions!

This you have to create on your webserver:
check.php:
Code:
<?php
//Whitelist System by Illuminati/Meijk Vandat

$GUID = $_GET["guid"];
$PlayerID = $_GET["playerid"];

if($GUID == "" OR $PlayerID == "") {
	echo "Error!";
	exit;
}

$whitelist = file_get_contents("whitelist.txt");

if (strpos($whitelist,"$GUID;") !== false) {
    //Player is whitelisted
	echo "100|$PlayerID";
	exit;
	
} else {
	//Player is not whitelisted
	echo "200|$PlayerID";
	exit;
}
?>

whitelist.txt: Empty text file or a file with containing already some GUID's. Don't forget to have ";" at all end of GUIDS even on the last one!



This you have to do on the module system:
module_scripts.py:
Change/Add/Edit/Replace "game_receive_url_response":
Code:
  ("game_receive_url_response", # called by the game when a response is received from a web server, if used
   [(store_script_param, ":integer_count", 1),

    (try_begin),
      (ge, ":integer_count", 1),
      (assign, ":return_code", reg0),
	  (assign, ":player_id", reg1),
	  
	(try_begin),
		(eq, ":return_code", 100), #Player is whitelisted
		(gt, ":player_id", 0),
		(player_is_active, ":player_id"),
                (str_store_player_username, s2, ":player_id"),
                (display_message, "@{s2} is whitelisted!"),
		#Here you can extend features
	(else_try),
		(eq, ":return_code", 200), #Player is not whitelisted
		(gt, ":player_id", 0),
		(player_is_active, ":player_id"),
                (str_store_player_username, s2, ":player_id"),
		(kick_player, ":player_id"),
                (display_message, "@{s2} is not whitelisted!"),
                #Here you can extend features
	(try_end),
	
    (try_end),
    ]),

Add this:
Code:
  ("cf_whitelist_check", # server: check if whitelisted or not
   [(store_script_param, ":player_id", 1), # must be valid
   
	  (player_is_active, ":player_id"),
	  (assign, reg1, ":player_id"),
	  (player_get_unique_id, ":guid", ":player_id"),
	  (assign, reg2, ":guid"),
      (send_message_to_url, "@http://YOURHOST/check.php?guid={reg2}&playerid={reg1}"),
    ]),

module_mission_templates.py:
Change/Edit/Replace/Add player_joined with this:
Code:
player_joined = (ti_server_player_joined, 0, 0, [], # server: handle connecting players
   [(store_trigger_param_1, ":player_id"),
    (call_script, "script_setup_player_joined", ":player_id"),
    (call_script, "script_cf_whitelist_check", ":player_id"),
    ])
 
Back
Top Bottom