[OSP] Punishments Manager (Name Server Addon)

Users who are viewing this thread

Punishments Manager - Name Server Addon


I - Presentation

Hello' People, I come up with a little something for server owners. It's something that I like to call 'Punishments Manager', even if it doesn't have a real name, but eh, let's begin by explaining you what it is. This punishment manager is an unofficial addon for the Vornne's Name Server. This tool has for purpose to keep tracks of past punishments of players, and having the ban list online allowing admins to set a given amount of time for each bans. In addition, with an account system and a simple permissions editing, server owners can let their admin having access to different sections of the name server according to their permissions.



II - Features

  • Web Hosted ban list
  • No waiting time on unban
  • Custom Ban Time (1 Hour, 3 Hours, 12 Hours, 1 Day, 3 Days, 1 Week, 2 Weeks, 3 Weeks, 1 Month)
  • Every Punishment Saved
  • Welcome message on join (different if the player is banned) with variables (such as player uid, unban date, player name etc..)
  • Every Punishment Saved And readable at any time
  • Account Permissions Managing (can give or remove access to tabs of the name server / punishments manager)
  • Player Unbans Saved



III - Installation

NOTE: If you already got the name server installed, it's advised to do files & database backup before editing anything.

Vornne's Readme said:
To install, you need a web server with PHP and MySQL installed; I use Linux and Apache (LAMP) so the instructions will be tailored to that. Lines starting with "$" represent commands to run in the shell prompt, and lines starting with "mysql>" represent queries to run in the mysql command line tool.

To start off, you will need to uncompress 'pwnameserver' into the web directory of your server. If you already got the name server installed, replace its folder. Make sure to set the name server as the directory you are in before connecting as root to your MySQL Server:

$ cd /var/www/pwnameserver/
$ mysql -u root -p


If you do not have the name server already installed:

mysql> CREATE DATABASE pw_player_names;
mysql> GRANT ALL PRIVILEGES ON pw_player_names.* TO 'pw_name_server'@'localhost' IDENTIFIED BY 'FX3nQGY5Hdqc';
mysql> USE pw_player_names;
mysql> SOURCE private/create_database.sql;
mysql> UPDATE warband_servers SET password = SHA1('N6XcqAXD') WHERE name = 'Server';


The last command set the connection password between your game server and the web server.
If you do have the name server installed:

mysql> USE pw_player_names;
mysql> SOURCE private/update.sql;


Now, the database tables and basic informations were created, you need to set the root user password:

mysql> UPDATE web_accounts SET passwd = SHA1('Qy7rQf9n') WHERE name = 'root';
mysql> exit;


Now the database is ready, make sure to edit the file 'private/config.php' to fit with your database informations.
Edit the constant lines (if needed) 'database_server_name', 'database_username', 'database_password', 'database_name'.

We are almost done, web side, now, connect to the name server as root (in this tutorial, username:password = root:Qy7rQf9n).
Head to the tab 'Web Settings' create a new account with your UID (you can find it in your game server logs when you join it).
Now, make sure to always use the account you just created for yourself, you should only use the root account in case you loose the 'Web Settings' permissions.
You can also create an account for each of the admins you got in your team.

Now, you'll need to set a cronjob. It'll be a script that will be triggered each X minutes and that will check if the ban time is over. If it is, then, the player is removed from the ban list and is able to join the server, else, he'll remain banned untill his ban time is over. To do this, you must ensure cURL is installer.

$ crontab -e

Go at the bottom of the file and add a line:

*/10 * * * * curl -L localhost/pwnameserver/server-requests/auto_unban.php

Save and quit. This line means the link 'localhost/pwnameserver/server-requests/auto_unban.php' will be triggered each 10 minutes. You can find more informations about cronjobs by following this link.

Last step on the webserver. Every unbans are saved in a file 'unban.log'. However, this file display IP of the admin who unbanned the player (in case the unban was not done by the cronjob). This file is stored in the folder 'private', this folder is protected by the file '.htaccess', only listed IPs in this file can access the folder via a web interface. In order to grant yourself the access, at the end of the file, add the line: 'Allow from xx.xx.xx.xx' (replace the X values by your IP).

Now, game scripts need to be edited in order to link game server & webserver. To do so, open the folder 'scripts' from the archive you downloaded and search for 'str_name_server' & 'str_name_server_password'. Make sure those four strings fit correctly with what you have set on your server (str_name_server_password correspond to the password for the server set in the database, in our tutorial, the password is 'N6XcqAXD'). Once done, you can upload the content of 'scripts' inside the folder 'PW_4.4' of your server.

You will also need to have the content of the scripts folder in your PW_4.4 module folder in your client directory in order to be able to temp ban players and have punishments recorded. Every admins using this tool will also need it. WARNING: Before handing out the scripts to someone, make sure to edit the four strings listed above with incorrect values to prevent security holes.




IV - Questions - Answers


Q. When I log ban someone, his name appears as 'NO NAME', why ?
A. It's because the player you're attempting to ban is not registered in the 'Player Names' table.

Q. What are the variables for the custom welcome / banned message ?
A. Welcome message got two different variables & banned message got six different variables:


[list type=decimal]
[*]Welcome Message:
  • *name* = Display Player Name
  • *uid* = Display Player UID
[*]Banned Message:
  • *name* = Display Player Name
  • *uid* = Display Player UID
  • *invoker* = Display Ban Invoker
  • *invoker_uid* = Display Ban Invoker UID
  • *ban_date* = Display date the player got banned on
  • *unban_date* = Display date the player will be unbanned on
[/list]

Q. I can't get something working, please, can you help me ?
A. Sure, make sure you correctly read the installation instructions before posting your question, if you post, make sure you provide a maximum of details.

[size=14pt]Q. What's supposed to be the UID of the account I want to create ?
A. It's the Unique ID the admin got in game. Saving it has for purpose to display the name of his account in the past punishments / ban list each time this UID would punish someone. By doing so, an admin can easily be recognized if he punished someone under an 'unknown' nickname.



[size=18pt]V - Download

Punishments_Manager.rar
MD5: c3024b9efecef3c65a04f52b90a95c05
Punishments Manager - Name Server/
├── pwnameserver
│  ├── admin_permissions.php
│  ├── ban_list.php
│  ├── checkplayer.php
│  ├── index.php
│  ├── log_ban.php
│  ├── log_in.php
│  ├── main.css
│  ├── player_names.php
│  ├── private
│  │  ├── config.php
│  │  ├── create_database.sql
│  │  ├── unban.log
│  │  └── update.sql
│  ├── punishments.php
│  ├── server-requests
│  │  ├── auto_unban.php
│  │  ├── ban-player.php
│  │  └── check-ban.php
│  ├── servers.php
│  └── web_settings.php
├── README.txt
└── scripts
    ├── build_module.py
    ├── compile_shaders.py
    ├── dump_crafting_recipes.py
    ├── generate_stockpiles_from_items.py
    ├── header_animations.py
    ├── header_common.py
    ├── header_debug.py
    ├── header_dialogs.py
    ├── header_factions.py
    ├── header_game_menus.py
    ├── header_ground_types.py
    ├── header_item_modifiers.py
    ├── header_items.py
    ├── header_lazy_evaluation.py
    ├── header_map_icons.py
    ├── header_meshes.py
    ├── header_mission_templates.py
    ├── header_mission_types.py
    ├── header_music.py
    ├── header_operations.py
    ├── header_particle_systems.py
    ├── header_parties.py
    ├── header_postfx.py
    ├── header_presentations.py
    ├── header_quests.py
    ├── header_scene_props.py
    ├── header_scenes.py
    ├── header_skills.py
    ├── header_skins.py
    ├── header_sounds.py
    ├── header_strings.py
    ├── header_tableau_materials.py
    ├── header_terrain_types.py
    ├── header_triggers.py
    ├── header_troops.py
    ├── LICENSE_explanation.txt
    ├── LICENSE.txt
    ├── module_animations.py
    ├── module_constants.py
    ├── module_dialogs.py
    ├── module_factions.py
    ├── module_flora_kinds.py
    ├── module_game_menus.py
    ├── module_generated_scripts.py
    ├── module_generated_strings.py
    ├── module_ground_specs.py
    ├── module_info_pages.py
    ├── module_info.py
    ├── module_items.py
    ├── module_map_icons.py
    ├── module_meshes.py
    ├── module_mission_templates.py
    ├── module_music.py
    ├── module_particle_systems.py
    ├── module_parties.py
    ├── module_party_templates.py
    ├── module_postfx.py
    ├── module_presentations.py
    ├── module_quests.py
    ├── module_scene_props.py
    ├── module_scenes.py
    ├── module_scripts.py
    ├── module_simple_triggers.py
    ├── module_skills.py
    ├── module_skins.py
    ├── module_skyboxes.py
    ├── module_sounds.py
    ├── module_strings.py
    ├── module_tableau_materials.py
    ├── module_triggers.py
    ├── module_troops.py
    ├── Output
    │  ├── actions.txt
    │  ├── conversation.txt
    │  ├── dialog_states.txt
    │  ├── factions.txt
    │  ├── info_pages.txt
    │  ├── item_kinds1.txt
    │  ├── map_icons.txt
    │  ├── menus.txt
    │  ├── meshes.txt
    │  ├── mission_templates.txt
    │  ├── music.txt
    │  ├── particle_systems.txt
    │  ├── parties.txt
    │  ├── party_templates.txt
    │  ├── postfx.txt
    │  ├── presentations.txt
    │  ├── quests.txt
    │  ├── quick_strings.txt
    │  ├── scene_props.txt
    │  ├── scenes.txt
    │  ├── scripts.txt
    │  ├── simple_triggers.txt
    │  ├── skills.txt
    │  ├── skins.txt
    │  ├── sounds.txt
    │  ├── strings.txt
    │  ├── tableau_materials.txt
    │  ├── triggers.txt
    │  ├── troops.txt
    │  └── variables.txt
    ├── print_opcode_name.py
    ├── process_animations.py
    ├── process_common.py
    ├── process_dialogs.py
    ├── process_factions.py
    ├── process_game_menus.py
    ├── process_info_pages.py
    ├── process_items.py
    ├── process_map_icons.py
    ├── process_meshes.py
    ├── process_mission_templates.py
    ├── process_music.py
    ├── process_operations.py
    ├── process_particle_systems.py
    ├── process_parties.py
    ├── process_party_templates.py
    ├── process_postfx.py
    ├── process_presentations.py
    ├── process_quests.py
    ├── process_scene_props.py
    ├── process_scenes.py
    ├── process_scripts.py
    ├── process_simple_triggers.py
    ├── process_skills.py
    ├── process_skins.py
    ├── process_sounds.py
    ├── process_strings.py
    ├── process_tableau_materials.py
    ├── process_triggers.py
    ├── process_troops.py
    ├── README.txt
    ├── STYLE.txt
    └── variables.txt

5 directories, 153 files



VI - Credits

Vornne, first, for having made Persistent World wich is an excellent module that still after ages from its release is still played and quite popular. But mainly, I would like to thank you for all the help you provided me on TaleWorlds and all the help you provide to people. Without you, and you module, I for sure wouldn't have gone far, so, thank you, a lot.
Wolfstar, couple with Vornne were the best teachers I could have. You learnt me a lot in SQL and PHP and I'm really glad I know someone like you. I wish you good luck for your projects.
 
This is simply amazing Ra'Jiska!
I'll definitely be checking this out and every single detail about it, when I am on my computer.
 
Looks good, based on a quick glance. I never really bothered to flesh out the web server part of PW further than various bits that took my fancy at times, so it is good to see other people releasing features that they find useful in practice.

Though one thing: the tag "OSP" stands for Open Source Pack, but you have not released the source code for the module system part, making it the wrong term to use for this case. Releasing only .txt files also means that people should not use it unless they are using totally unmodified PW 4.4.0 (or whatever you have based it on), because the .txt file format is not designed to be merged, with loads of potential bugs and crashes for anyone that tries - unlike module system code.
 
Vornne said:
Looks good, based on a quick glance. I never really bothered to flesh out the web server part of PW further than various bits that took my fancy at times, so it is good to see other people releasing features that they find useful in practice.

Though one thing: the tag "OSP" stands for Open Source Pack, but you have not released the source code for the module system part, making it the wrong term to use for this case. Releasing only .txt files also means that people should not use it unless they are using totally unmodified PW 4.4.0 (or whatever you have based it on), because the .txt file format is not designed to be merged, with loads of potential bugs and crashes for anyone that tries - unlike module system code.

Well if I ask about "Why didn't you put it under OSP" Then it's logical that I know what it is. And yea, for sure it's only based on PW system so it can't go further for other mods, if it isn't modified though.
 
Vornne said:
Looks good, based on a quick glance. I never really bothered to flesh out the web server part of PW further than various bits that took my fancy at times, so it is good to see other people releasing features that they find useful in practice.

Though one thing: the tag "OSP" stands for Open Source Pack, but you have not released the source code for the module system part, making it the wrong term to use for this case. Releasing only .txt files also means that people should not use it unless they are using totally unmodified PW 4.4.0 (or whatever you have based it on), because the .txt file format is not designed to be merged, with loads of potential bugs and crashes for anyone that tries - unlike module system code.

Thank you Vornne.
Just changed for Release untill I give out Module System files (if I do).
I would like first to verify stuff before doing anything.

AleksanderTheGreat said:
Well if I ask about "Why didn't you put it under OSP" Then it's logical that I know what it is. And yea, for sure it's only based on PW system so it can't go further for other mods, if it isn't modified though.

And nope, if the Module Would be released, it could easily be ported to any other mod (of course, it would need a lot more work if it's not PW based).
Also, people might want to do their own edit to the code wich is pretty understandable and justify the need of having the Module System code.

Thanks people.
 
Ra'Jiska said:
And nope, if the Module Would be released, it could easily be ported to any other mod (of course, it would need a lot more work if it's not PW based).
Also, people might want to do their own edit to the code wich is pretty understandable and justify the need of having the Module System code.
Thanks people

Exactly "it would need a lot more work if it's not PW based", that was what I were referring to, but maybe not literally, but it's hell of work just to make it.
 
Hey Again People,

A little update, the punishments manager is now able to handle multiple servers connected.
You are not restricted to only one anymore.

Also, the PW Modified Module System has been released.
Happy Modding !
 
I had time to take a quick look at the module system today: well done, the code is quite well integrated with existing systems in PW, rather than the common messy beginner hacks.

A couple of small notes, though (having a perfectionist attention to detail I will have opinions about basically any PW based code, so don't take it the wrong way):

You have defined a bunch of slot_player_admin_temp_ban_* in module_constants, but numerically after slot_player_admin_end, so they will not be included in the permissions feature of standard PW. Note that the design packs all the permission flags into one network "int" which is signed 32 bit, so there should only be 31 different admin permissions unless the code is changed to pack the flags into two values, or something else; 17 are currently used by official PW, which leaves 14, so I would suggest just using the existing "temporary_ban" and "permanent_ban" permissions, using one for bans less than a certain time, and the other for longer bans. But you could split each ban duration into a different permission if you think that would be necessary; just remember to add the columns to the "admin_permissions" database field. The other permission slots are named slot_player_admin_no_*, since they are only set to 1, or true, when the name server denies the permission, defaulting to 0 ("not no permission") with no name server.

I discourage the practice of distinguishing web server replies by the number of parameters, i.e. the (eq, ":integer_count", 2), (eq, ":string_count", 1) added in the first else_try block of script game_receive_url_response. It has somehow become popular with people writing simple guides for web servers with Warband, but it is a bad idea: no other message types can then use 2 integers and 1 string, having to add useless extra parameters to avoid conflicting, confusing anyone trying to merge different features that use a web server. You have a "status" value in reg0, which is very close to the right idea: it should be a unique "return code" to work in with the official name server and any other web server feature desired, so like the slots in module_constants, people only need to check one place for conflicts when merging code (that all the "return code" / "message type" numbers are unique). I didn't define the return code constants in the module system, because the languages of the module system and web server are different (Python, PHP) making it seemingly impractical to try use the same list; so the return codes are only named in the web server configuration, manually using the same numbers in script game_receive_url_response (you might have a better idea).

Aside from my usual nit picking about the use of mixed tabs and spaces for indentation (makes the code look wrong to anyone using different settings), the code looks nice. I didn't check the PHP code very deeply though, since I don't really know it very well (the name server was basically my first time learning a bit of PHP, HTML, CSS, so it might not be ideal).

I have created a new sticky topic linking to this thread, also for any useful and well written code posted by other people.
 
Vornne said:
I had time to take a quick look at the module system today: well done, the code is quite well integrated with existing systems in PW, rather than the common messy beginner hacks.

A couple of small notes, though (having a perfectionist attention to detail I will have opinions about basically any PW based code, so don't take it the wrong way):

Thank you a lot. Of course not, anything you or someone else say aiming to improve code stability wouldn't be take the wrong way.

Vornne said:
You have defined a bunch of slot_player_admin_temp_ban_* in module_constants, but numerically after slot_player_admin_end, so they will not be included in the permissions feature of standard PW. Note that the design packs all the permission flags into one network "int" which is signed 32 bit, so there should only be 31 different admin permissions unless the code is changed to pack the flags into two values, or something else; 17 are currently used by official PW, which leaves 14, so I would suggest just using the existing "temporary_ban" and "permanent_ban" permissions, using one for bans less than a certain time, and the other for longer bans. But you could split each ban duration into a different permission if you think that would be necessary; just remember to add the columns to the "admin_permissions" database field. The other permission slots are named slot_player_admin_no_*, since they are only set to 1, or true, when the name server denies the permission, defaulting to 0 ("not no permission") with no name server.

Effectively, I putted them for some reason, unfortunately can't clearly remember, but as it was set, it was simply useless.
So, as you said, I putted it on the regular temp ban slot, there is no point in putting a permission for each single temp bans possible.

Vornne said:
I discourage the practice of distinguishing web server replies by the number of parameters, i.e. the (eq, ":integer_count", 2), (eq, ":string_count", 1) added in the first else_try block of script game_receive_url_response. It has somehow become popular with people writing simple guides for web servers with Warband, but it is a bad idea: no other message types can then use 2 integers and 1 string, having to add useless extra parameters to avoid conflicting, confusing anyone trying to merge different features that use a web server. You have a "status" value in reg0, which is very close to the right idea: it should be a unique "return code" to work in with the official name server and any other web server feature desired, so like the slots in module_constants, people only need to check one place for conflicts when merging code (that all the "return code" / "message type" numbers are unique). I didn't define the return code constants in the module system, because the languages of the module system and web server are different (Python, PHP) making it seemingly impractical to try use the same list; so the return codes are only named in the web server configuration, manually using the same numbers in script game_receive_url_response (you might have a better idea).

Yup', totally right. I was always putting it like that since I learnt it this way and never taken the time to thought about another way.
Doing this is effectively a lot better, it has been set by adding a constant PHP side that would take the role of identifier for the Punishments Manager.

Vornne said:
Aside from my usual nit picking about the use of mixed tabs and spaces for indentation (makes the code look wrong to anyone using different settings), the code looks nice. I didn't check the PHP code very deeply though, since I don't really know it very well (the name server was basically my first time learning a bit of PHP, HTML, CSS, so it might not be ideal).

Thanks, however, one thing is sure, you totally overcome me with the design (CSS / HTML).

Vornne said:
I have created a new sticky topic linking to this thread, also for any useful and well written code posted by other people.

I sincerely do hope this thread will get filled with more and more projects.
It's always interesting to learn from other's code.

Anyway, thanks a lot for pointing out pieces in need of fixing.
The code has been updated.
 
I should have explained about the web server return code more specifically: your latest code still uses "1" for that, which conflicts with the standard "name_used_error" (since every connection to a web server must use the same game_receive_url_response script, the return codes need to be unique). I would suggest replacing with something like this in config.php:
Code:
const pm_welcome_message = 50;
const pm_banned_message = 51;
And then in game_receive_url_response, I suggest something like this (compared against the standard PW script):
Code:
diff --git a/module_scripts.py b/module_scripts.py
index 901457f..84567f6 100644
--- a/module_scripts.py
+++ b/module_scripts.py
@@ -375,26 +375,25 @@ scripts.extend([
 
     (assign, "$g_name_server_enabled", 1),
 
+    # Link: http://localhost/pwnameserver/server-request/check-player.php?uid=1000&id=5&name=User | Result: 50|Welcome|5
     (try_begin),
       (ge, ":integer_count", 1),
       (assign, ":return_code", reg0),
-      (try_begin), # negative return codes are internal or configuration errors, not requiring action
+      (try_begin), # Punishments Manager
+        (is_between, ":return_code", 50, 52),
+        (ge, ":integer_count", 2),
+        (ge, ":string_count", 1),
+        (assign, ":player_id", reg1)
+        (player_is_active, ":player_id"),
+        (multiplayer_send_string_to_player, ":player_id", server_event_local_chat, s0),
+        (try_begin),
+          (eq, ":return_code", 51), # banned message, so kick after a delay
+          (store_mission_timer_a, ":time"),
+          (val_add, ":time", name_server_kick_delay_interval),
+          (player_set_slot, ":player_id", slot_player_kick_at_time, ":time"),
+        (try_end),
+
+      (else_try), # negative return codes are internal or configuration errors, not requiring action
         (lt, ":return_code", 0),
         (server_add_message_to_log, "str_name_server_error_code_reg0"),
       (else_try), # return code 0 is success, don't kick the player
Which is adding your handler code as an else_try section with the other name server handlers, and also still checking that the integer and string counts are sufficient. I combined the "return code" and your "status" value into one, which would require tweaking your PHP code; though you could always send something like 50 as the first integer for all punshments manager replies (use any random number that doesn't and isn't likely to conflict with name server return codes), and sending a second integer to distinguish between welcome and banned messages.
 
Ah, thanks, yes, you did not need to reexplain, it was perfectly clear.
I did not have the globality of the block in mind and skipped the NS.

Concerning how you did it, the thing is yes, it uses less lines and avoid reusing things like 'player_is_active', but on the lisibility side, I do prefer how I did in the first place since Name Server & Punishments Manager are clearly separated.

So here is how it has been done:

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),
    (store_script_param, ":string_count", 2),

    (assign, "$g_name_server_enabled", 1),
	
	  # Link: http://localhost/pwnameserver/server-request/check-player.php?uid=1000&id=5&name=User | Result: 1|0|Welcome|5 | Const: reg0{Identifier}
	  (try_begin),
		  (eq, 1, reg0), # Identifier: 1 -> Punishments Manager
	    (assign, ":status", reg1),
	    (assign, ":player_id", reg2),
	    (player_is_active, ":player_id"),
	    (multiplayer_send_string_to_player, ":player_id", server_event_local_chat, s0),
	    (try_begin),
	      (eq, ":status", 1),
		    (store_mission_timer_a, ":time"),
		    (val_add, ":time", name_server_kick_delay_interval),
		    (player_set_slot, ":player_id", slot_player_kick_at_time, ":time"),
	    (try_end),
			
	  (else_try),
		
		  (eq, 2, reg0), # Identifier: 2 -> Names Server
      (ge, ":integer_count", 2),
      (assign, ":return_code", reg1),
      (try_begin), # negative return codes are internal or configuration errors, not requiring action
        (lt, ":return_code", 0),
        (server_add_message_to_log, "str_name_server_error_code_reg0"),
      (else_try), # return code 0 is success, don't kick the player
        (eq, ":return_code", 0),
        (this_or_next|lt, ":integer_count", 4), # admin permissions not received
        (eq, reg4, -1), # admin permissions not set
      (else_try),
        (ge, ":integer_count", 3),
        (ge, ":string_count", 1),
        (assign, ":player_id", reg2),
        (assign, ":unique_id", reg3),
        (player_is_active, ":player_id"),
        (player_get_unique_id, ":player_unique_id", ":player_id"),
        (eq, ":player_unique_id", ":unique_id"),
        (try_begin), # positive return codes are for rejecting the player
          (gt, ":return_code", 0),
          (try_begin),
            (eq, ":return_code", 4),
            (assign, ":rejection_string_id", "str_kicked_not_registered"),
          (else_try),
            (eq, ":return_code", 3),
            (assign, ":rejection_string_id", "str_kicked_using_invalid_name"),
          (else_try),
            (eq, ":return_code", 2),
            (assign, ":rejection_string_id", "str_kicked_using_other_clan_tag"),
          (else_try),
            (assign, ":rejection_string_id", "str_kicked_using_other_players_name"),
          (try_end),
          (multiplayer_send_2_int_to_player, ":player_id", server_event_preset_message, ":rejection_string_id", preset_message_error|preset_message_log),
          (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),
          (player_set_slot, ":player_id", slot_player_kick_at_time, ":time"),
          (str_store_string, s10, ":rejection_string_id"),
          (server_add_message_to_log, "str_name_server_log_s10"),
        (try_end),
        (try_begin), # admin permissions were received
          (ge, ":integer_count", 4),
          (player_is_admin, ":player_id"),
          (assign, ":admin_permissions", reg4),
          (val_max, ":admin_permissions", 0),
          (call_script, "script_player_set_admin_permissions", ":player_id", ":admin_permissions"),
          (multiplayer_send_int_to_player, ":player_id", server_event_admin_set_permissions, ":admin_permissions"),
        (try_end),
      (else_try),
        (server_add_message_to_log, "str_name_server_invalid_response"),
      (try_end),
    (try_end),
    ]),

Vornne said:
though you could always send something like 50 as the first integer for all punshments manager replies (use any random number that doesn't and isn't likely to conflict with name server return codes), and sending a second integer to distinguish between welcome and banned messages.

Yep yep, a same response identifier for each web 'services'.
Anyway, I guess it won't be needed since both NS & PM only send back a response for only one message.

Thanks again for your help.
It has been updated, everything I've been trying worked.
 
Hmm, I would not recommend doing it that way: changing the meaning of the first return value for the name server means you have to change all the registers used in the standard PW part of the game_receive_url_response script, and change every PHP script used, adding a new value in front. In other words, taking over reg0 for your purposes requires incrementing the registers used for all other values in all other handlers, in both the module system and web server code (easy for people to make a mistake with so many scattered changes required). It is much less intrusive to just use "return code" values that will be ignored by the name server reply handlers, and probably any other web server package merged as well (if they happen to conflict, fixing would be as simple as changing return code numbers for one package).

If you want to visually separate the code, it is possible have a new block which deals with your punishments manager, leaving the name server code totally alone, like this:
Code:
     (store_script_param, ":string_count", 2),
 
     (assign, "$g_name_server_enabled", 1),
+
+    # Link: http://localhost/pwnameserver/server-request/check-player.php?uid=1000&id=5&name=User | Result: 50|Welcome|5
+    (try_begin),
+      (ge, ":integer_count", 2),
+      (is_between, reg0, 50, 52), # extend this to cover the range of return codes used by the punishments manager
+      (ge, ":string_count", 1),
+      (assign, ":player_id", reg1),
+      (player_is_active, ":player_id"),
+      (multiplayer_send_string_to_player, ":player_id", server_event_local_chat, s0),
+      (try_begin),
+        (eq, ":return_code", 51),
+        (store_mission_timer_a, ":time"),
+        (val_add, ":time", name_server_kick_delay_interval),
+        (player_set_slot, ":player_id", slot_player_kick_at_time, ":time"),
+      (try_end),
+    (try_end),
+
+    # code below here, for the official name server, is totally unmodified
+
     (try_begin),
       (ge, ":integer_count", 1),
       (assign, ":return_code", reg0),
Remember, even though identifying message types only by the number of their parameters is a bad idea, you should check that the required number of integers and strings were received before using them. Note that if you don't modify any of the name server code, every reply handled will also add an "invalid response" message to the server log; so you could disable that part at the end of the script, or make the minimum changes to work in with the name server handlers, like this:
Code:
     (store_script_param, ":string_count", 2),
 
     (assign, "$g_name_server_enabled", 1),
+
+    # Link: http://localhost/pwnameserver/server-request/check-player.php?uid=1000&id=5&name=User | Result: 50|Welcome|5
     (try_begin),
+      (ge, ":integer_count", 2),
+      (is_between, reg0, 50, 52), # extend this to cover the range of return codes used by the punishments manager
+      (ge, ":string_count", 1),
+      (assign, ":player_id", reg1),
+      (player_is_active, ":player_id"),
+      (multiplayer_send_string_to_player, ":player_id", server_event_local_chat, s0),
+      (try_begin),
+        (eq, ":return_code", 51),
+        (store_mission_timer_a, ":time"),
+        (val_add, ":time", name_server_kick_delay_interval),
+        (player_set_slot, ":player_id", slot_player_kick_at_time, ":time"),
+      (try_end),
+
+      # code below here, for the official name server, is basically unmodified
+
+    (else_try),
       (ge, ":integer_count", 1),
       (assign, ":return_code", reg0),
       (try_begin), # negative return codes are internal or configuration errors, not requiring action
         (lt, ":return_code", 0),
 
Hello',

Sorry for the late answer, I've been quite busy with school due to the end of summer hollidays  :cry:.
I'll put what you suggested, even if I think the replacement I've been doing was correctly done.
It'll be added as soon as possible, thanks for your help.
 
Back
Top Bottom