gedizz
Banned
Hello everyone. Recently for my Persistent World server, Celestial NA, I was looking for a whitelist and saw Illuminati's so I cranked out the bugs and used it. Here is a simple guide to use it.
Simply follow the instructions below and insert the code into the appropriate places. If you have any questions, feel free to post on the topic or send me a PM.
First you will need the php file to run the check. I use GUID to filter through, but if you use WSE you could also use IP address, but you'd have to edit it a little bit to do so. So make a new .php file and call it what you please, and insert this code into it, and put it on your webserver.
Next you will need to add this script into module_scripts.py and edit the 3 placeholders in the send_message_to_url accordingly
Next you will need to add the return codes that are sent from the php file to your game_receive_url_response. This is an example of what your game_receive_url_response might look like.
Finally you will need to call the script in your module_mission_templates on player_joined to ensure that every time the player joins it sends the message to the url and checks if they are on the whitelist
That is all you will need to do. I currently use this whitelist and it works 100%. When you add the guids, it will instantly work. If a player is on your server already, and you wish to remove them from the whitelist, you will need to kick them off the server.
Like I said above, just send me a PM or post here if you have any questions.
Credit to Illuminati for the initial framework, just had a few bugs.
Simply follow the instructions below and insert the code into the appropriate places. If you have any questions, feel free to post on the topic or send me a PM.
First you will need the php file to run the check. I use GUID to filter through, but if you use WSE you could also use IP address, but you'd have to edit it a little bit to do so. So make a new .php file and call it what you please, and insert this code into it, and put it on your webserver.
插入代码块:
<?php
// Whitelist by illuminati
$GUID = $_GET["guid"];
$playerid = $_GET["playerid"];
if($GUID == "" || $playerid == "") {
echo "Error!";
exit;
}
$whitelist = array(
'395145',
'1747169',
'1843467',
'1110715');
// Add guids above here
if (in_array($_GET['guid'], $whitelist)) {
//This will echo a return code used in url_response saying the player is whitelisted
echo "249|$PlayerID";
} else {
//This will echo a return code used in url_response saying the player is not whitelisted
echo "250|$playerid";
}
?>
Next you will need to add this script into module_scripts.py and edit the 3 placeholders in the send_message_to_url accordingly
插入代码块:
("cf_whitelist", # check if the player is whitelisted
[(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://YOURDOMAINHERE/YOURWEBSERVERHERE/YOURPHPFILENAMEHERE.php?guid={reg2}&playerid={reg1}"),
]),
Next you will need to add the return codes that are sent from the php file to your game_receive_url_response. This is an example of what your game_receive_url_response might look like.
插入代码块:
("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", 249), #whitelisted
(assign, ":player_id", reg1),
(player_is_active, ":player_id"),
(str_store_player_username, s2, ":player_id"),
(else_try),
(eq, ":return_code", 250), #not whitelisted
(assign, ":player_id", reg1),
(player_is_active, ":player_id"),
(str_store_player_username, s2, ":player_id"),
(server_add_message_to_log, "@{s2} tried to join without being on the whitelist"),
(str_store_string, s0, "@THE MESSAGE HERE WILL SEND TO THE PLAYER BEFORE KICKING THEM OFF"), #Edit this to your liking
(multiplayer_send_string_to_player, ":player_id", server_event_admin_chat_announce, s0),
(store_mission_timer_a, ":time"), # kick the player after a short delay to try ensure they see the rejection message
(val_add, ":time", name_server_kick_delay_interval), #You can change the kick timer in module_constants under the name_server_kick_delay_interval
(player_set_slot, ":player_id", slot_player_kick_at_time, ":time"),
(try_end),
(try_end),
]),
Finally you will need to call the script in your module_mission_templates on player_joined to ensure that every time the player joins it sends the message to the url and checks if they are on the whitelist
插入代码块:
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_player_check_name", ":player_id"),
(call_script, "script_cf_whitelist_check", ":player_id"), #This is the whitelist call script, if you have other things on player joined just add this line
])
That is all you will need to do. I currently use this whitelist and it works 100%. When you add the guids, it will instantly work. If a player is on your server already, and you wish to remove them from the whitelist, you will need to kick them off the server.
Like I said above, just send me a PM or post here if you have any questions.
Credit to Illuminati for the initial framework, just had a few bugs.