This plugin now requires a SM 1.1 Snapshot version! Get the proper snapshot for your server here: http://www.sourcemod.net/snapshots.php
There are many changes, please see the changelog below!
This is my first plugin! First off, credit to graczu
for his original plugin (sm_rules). Someone in his/this thread (http://forums.alliedmods.net/showthread.php?t=60338
) put in a request to have the rules automatically appear on connect. I've been wanting to get into writing plugins, so I used his ideas as a basis.
I took no code from anyone (except some panel stuff from the sourcemod tutorial). Also, the reference site could probably use a good scrubbing down. I was there quite a bit. =/
Additional Credits to Kigen, I looked at your code to learn various things regarding convar usage, seeing as how I've been using your plugin extensively within our community!
This plugin will automatically display a list of rules in a menu panel to all connecting clients. It also has a command line option for admins to display the rules to an individual user (or group, @all etc..). Clients then have the choice of either agreeing, or disagreeing to the rules and conditions presented to them. If they agree, they recieve a nice message. If they disagree, they get kicked (also with a nice message). This plugin now also supports playing a welcome sound to all connecting clients. The sound will not play on map change.
- Copy showrules.smx to addons/sourcemod/plugins/
- Copy showrules.sp to addons/sourcemod/scripting/
- Copy showrules.phrases.txt to addons/sourcemod/translations/
- Copy showrulesdata.phrases.txt to addons/sourcemod/translations/
The rules are now defined in showrulesdata.phrases.txt! This gives you the ability to have multi-lingual rules! Showrules.ini is deprecated! There are 10 rule lines available. If you don't need 10, simply leave the unused ones blank. Do not REMOVE the unused lines, it will cause errors.
- sm_showrules_menutime - How long the rules menu should be displayed. Default: 120 (seconds). NOTE: If the menu dissolves or gets cancelled, the user WILL get kicked after menutime expires! This prevents people from cancelling the menu with another menu, or ignoring it all together.
- sm_showrules_showonjoin - Display the rules menu automatically when a user connects. Default: 1
- sm_showrules_showtoadmins - When sm_showrules_showonjoin is true (1), also display rules to admins. Default: 0
- sm_showrules_expiration - Number of hours before previous terms agreement expires and rules are displayed again. Default: 24
- sm_showrules_displayattempts - Number of times to attempt to to display the rules menu. (3 second intervals) Default: 20
- sm_showrules_displayfailurekick - Kick client if the rules cannot be displayed after defined display attempts. Default: 1
- sm_showrules_showmenuoptions - Display agree/disagree menu options. Setting to false will display a simple 1. Close Window option. Clients will not be kicked. Default: 1
- sm_showrules_joinsound - Sound file to play to connecting clients. Relative to the sound/ folder. Example: 'welcome.mp3' or 'mysounds/welcome.mp3'.
Custom Admin Menu:
"cmd" "sm_showrules #1"
You have a MAXIMUM of 511 characters which can be used within the menu panel.
Change of heart, moved the rules out of showrules.phrases.txt and into showrulesdata.phrases.txt. This way if I update the primary translation file with new entries, you don't have to re-do your rules each time.
This version now automatically creates a config file in cfg/sourcemod/.
Please utilize this file and remove sm_showrules cvars from other config files.
Added convar sm_showrules_expiration.
This plugin now makes use of the clientprefs extension in the SM 1.1 snapshots. When players agree to the rules, a cookie will be stored with a timestamp. The next time they connect, if the time period has been greater than sm_showrules_expiration, the rules will be displayed to them again.
Added convar sm_showrules_joinsound
. This allows you to specify a sound to be played to connecting clients. The sound will not be played on map change.
has been deprecated. This cvar will no longer do anything!
Fixed some bugs in the translations.
Added log message when clients get kicked.
Rewrote the command function using ProcessTargetString instead of FindTarget to support multiple targets as well as #userid as a target.
Added convar sm_showrules_showmenuoptions
When set to false, clients will see a simple 1) Close Window option. Since there is no disagree option, clients will not be kicked.
Added New Translations - If you update to 1.3, you must use the new translations file, sorry! This was a new feature only release, if the 1.2 is working fine for you, there's no reason to upgrade unless you want one of the new features.
Added extensive code to check for other types of menus before displaying the rules menu. If the client has another menu open, the rules menu will wait patiently for 60 seconds (default) to display it's menu. Additionally, if another mod or plugin opens a window which cancels the rules menu, it will again wait 60 seconds to redisplay the rules menu. These changes should make this plugin 100% friendly with mods such as GunGame, CSSDM, etc, which open menus on team selection and other various locations.
Added Convar: sm_showrules_displayattempts
The menu re-display code is hardcoded using a 3 second repeating timer. This value is the number of times the timer will repeat. The default value is 20, which would be 60 seconds. The reasons a menu can not be displayed are limited. Client timing out, another window already open, or some sort of general client error.
Added Convar: sm_showrules_displayfailurekick.
After the repeating timer has hit the maximum number of attempts to display the menu, should we kick the client? Default is yes. If they leave a menu open for 60 seconds, they're either blocking the rules menu, timing out, or afk.
Added Convar: sm_showrules_showonmapchange
Hooked scoreboard on map end. Store a complete list of steam id's currently on the server into an array. When clients reconnect after map change, the connecting client ids are compared to the values within the array to determine if they were on the server previously. If they were, we assume they already agreed to the rules and don't show them the menu again. Obviously, setting this to 1 (true) will continue to display the rules to all clients on map change.
Fixed a rare issue where PostAdminCheck was returning client not connected error messages. Assume it was due to the timing of clients disconnecting, or timing out. Fixed by issuing a isClientConnected check.
Requires at least Sourcemod 1.0.4
None with TF2, CS:S, DOD:S
Various issues with Insurgency mod.
This has turned into the rules menu on steriods! I really don't see any way to update this with any more features short of bugfixes etc.. If you have any ideas, suggestions, or problems, please post them up. Thanks!
Thanks to Carn for helping test for errors!
Thanks to Zuko for providing a polish translation
Thanks to Mordekay for providing a german translation