Addon Details

Watch - Add Favorite


Does this version work for you?
3
w00ts
w00t!2

MySQL Advertisements - Version 1.02.000

posted on 2010-09-04 20:36:45
by Omega_K2

Requires: [list] [*][url=http://addons.eventscripts.com/addons/view/pubcvarlib]pubcvarlib[/url] [*][url=http://sourceforge.net/projects/mysql-python/]MySQLdb[/url] or [url=http://code.google.com/p/pymysql/]pymsql[/url] [*][url=http://www.mysql.de/downloads/mysql/]MySQL Server[/url] (tested with 5.1) [/list]


Description

[size=150][color=blue][b]MySQL Advertisements - Version 1.02.000[/b][/color][/size] Posted by: [color=green]Omega_K2[/color] on [color=purple]21st October 2010[/color]. [size=150][color=blue][b]Requirements:[/b][/color][/size] [list][b][*][url=http://mattie.info/cs]EventScripts 2.1 or higher[/url] [*][url=http://addons.eventscripts.com/addons/view/pubcvarlib]pubcvarlib[/url] [*][url=http://sourceforge.net/projects/mysql-python/]MySQLdb[/url] or [url=http://code.google.com/p/pymysql/]pymsql[/url] (SVN Revision 35 or higher) [*][url=http://www.mysql.de/downloads/mysql/]MySQL Server[/url] (Tested with 5.1) [/b][/list] [size=150][color=blue][b]Description:[/b] [/color] [/size] [list]MySQL Advertisements - Version 1.02.000 [b]What is MySQL Advertisements?:[/b] It allows you to share ingame advertisements accross many game servers. It can be configured in a very flexible way (settings for each message and server) and supports translations for multilingual servers. However, due to the nature of this script, I recommend it for advanced users only, since error checking and enduser interface is kept to a minimum. [b]Does it support variables inbetween the messages?:[/b] Yes! The current possible variables are currentmap, time, date and any cvar. The variables can be set in the messages itself, allowing different positioning according to language. If you feel some variables are missing, let me know and I can add them (as long it's possible). For details, see the Configuration section below. [b]What kind of broadcasting does it support?:[/b] Currently MySQL Advertisements supports advertisements in the text, popup, center and hint area. These modes can be used at once or seperatly. [b]How is the advertisement order defined?:[/b] The advertisement order is determined as the ads are fetched from the database. However, a special order value can be assigned to the advertisement, allowing you to specify your own order. In addition, MySQL Advertisements supports randomizing the messages. [b]Live Examples:[/b] Either connect to one of these servers: [list] [*][url=steam://connect/78.46.45.5:27015]78.46.45.5:27015[/url] CS:S - http://www.german-slaughterhouse.de ZombieMod [*][url=steam://connect/78.46.45.5:27050]78.46.45.5:27050[/url] CS:S - http://www.german-slaughterhouse.de RpgMod [*][url=steam://connect/78.46.45.5:27100]78.46.45.5:27100[/url] CS:S - http://www.german-slaughterhouse.de GunGame [*][url=steam://connect/78.46.45.5:27150]78.46.45.5:27150[/url] CS:S - http://www.german-slaughterhouse.de Stock [*][url=steam://connect/78.46.45.5:28000]78.46.45.5:28000[/url] Left 4 Dead 2 - http://www.german-slaughterhouse.de Stock or select one from grametracker: http://www.game-monitor.com/search.php?search=mysqlads_ver&type=variable[/list][/list] [size=150][color=blue][b]Installation:[/b] [/color][/size] This only covers the very basic installation of mysqlads. You have to proceed with the configuration afterwards. [list][b]Database:[/b] [list=1] [*]Create a new database user (make sure to renember username and password, I recommend restricting access to your server ip (or localhost if the server is on the same machine), don't give this user any global permissions) [*]Create a new database [*]Give the user you've created full access to the database.[/list] [b]Server:[/b] [list=1] [*]Install pymysql or MySQLdb (make sure it loads!) [*]Install pubcvarlib [*]Install mysqlads [*]Open addons/eventscripts/mysqlads/config.ini [*]Replace the defaults with the data you used upon creation of the database (username, password, database) [*]Set the host properly. It accepts a hostname or ip address - for a local server use localhost (or try 127.0.0.1 if that doesn't work) [*]Set a table prefix if you want or leave it empty (this is useful if you only have one database available and other scripts/programms use it aswell) [*]Load the script once - tables will be created (and the script unloaded)[/list] Now proceed with the Configuration Section below.[/list] [size=150][color=blue][b]Update:[/b][/color][/size] If you are upgrading from an older version, please follow these steps: [list=1] [*]Upload all files from the package except config.ini [*]Type the following in console: [b]es_load mysqlads/updater[/b] [*]Run this command: [b]mysqlads_update[/b] [*]Reload mysqlads: [b]es_reload mysqlads[/b] [*]Incase new features have been added, proceed with the Configuration section (and reload script once you're done)[/list] [size=150][color=blue][b]Configuration:[/b] [/color] [/size] [list]I recommend using a GUI tool like phpmyadmin, howver, you can do this with queries directly aswell. [color=blue][b]Adding Server(s)[/b][/color] [list] [*]Set the fields [b]port[/b] and [b]ip[/b] according to the public server ip and port. Make sure this info is correct, it will be used to identify your server by the script [*]Set the field [b]interval[/b] to how often you want the advertisements to appear on the server per seconds. If left empty, it will use 30 seconds [*]Set the fields [b]dateformat[/b] and [b]timeformat[/b] to the format you want to use respectivitly. If left empty, it will use [b]%d.%m.%Y[/b] and [b]%H:%M:%S[/b]. Refer to the [url=http://docs.python.org/library/time.html#time.strftime]python documention[/url] for valid values. [*]Set the field [b]random[/b] to either [b]true[/b] or [b]false[/b] depending on whether you want to have ads randomized on that serve. If left empty it defaults to False. [*][b]DO NOT set a value for sid, it will automatically determined![/b][/list] [color=blue][b]Advertisements[/b][/color] [b]Step 1: Adding Advertisements[/b] [list] [*]Set the field [b]display[/b] to any value from [b]0 to 15[/b]. Each display mode adds up, valid display modes are: 1 - Text Area 2 - Popup Area 4 - Hint Area 8 - Center Area If you leave this empty, it will default to 1. [*]Set the field [b]servers[/b] to a comma-sperated list of ServerIDs you wish the advertisement to be displayed on. You can specify [b]-1,[/b] if you want the advertisements on all servers. You must have a comma on the end (for example [b]1,2,3,[/b]). As of version 1.01.000 you can also start the entry with an exclamation mark ([b]![/b]). This means all following ServerIDs will be excluded ([b]!1,2,[/b] would exclude server 1 and 2, but still show the advertisement on all other servers) [*]Set the field [b]order[/b] to any value from [b]0 to 255[/b] depending on when you want the advertisement to be displayed. If left empty, it will use 128. [*][b]DO NOT set a value for aid, it will automatically determined![/b][/list] [b]Step 2: Adding Advertisement Translations[/b] [list] [*]Set the field [b]aid[/b] to the advertisement id [*]Set the field [b]language[/b] to the 2 char language identifier (for example [b]en[/b] or [b]de[/b]). (You can look up the language identifiers used by eventscripts in [b]addons/eventscripts/_libs/python/deflangs.ini[/b] If you leave this empty, it will default to [b]en[/b]. [*]Set the field [b]text[/b] to the string you want to show up ingame. You may use special variables inside of that string that will be replaced on run time: [b]{CURRENTMAP}[/b] - Current map [b]{TIME}[/b] - Time as set for your server [b]{DATE}[/b] - Data as set for your server [b]{CVAR:[i]my_cvar[/i]}[/b] - current value of [i]my_cvar[/i] (any cvar may be used) Additionally, for text area messages you can use [b]#green #lightgreen[/b] and [b]#default[/b] to change the colour of the messages. These tags will not show up in future messages [*][b]DO NOT create double entries for the same language and aid![/b][/list] [color=blue][b]Event Messages (added in 1.02.000)[/b][/color] [b]Step 1: Adding Events[/b] [list] [*]Do not set the field[b]id[/b]. It will be automatically determined [*]Set the field [b]eid[/b] to the id of event. This will be used later to determine which events the messages are displayed on. You can have double entries here, but this only makes sense if you run several different game servers (eg. TF2 and CS:S) and want to set one eventid for roundend in both (the actual game events are different of course) [*]Set the field [b]event[/b] to the name of event as defined in the resource files ([b]<gamedir>/resource/modevents.res[/b] or [b]hl2/resource/serverevents.res[/b]). Make sure the event exists. [*]Set the field [b]game[/b] to the foldername of your current gamemod or set it to [b]NULL[/b] if you want the event available in all games. For example, CS:S would use [b]cstrike[/b], Team Fortress 2 would use [b]tf[/b]. [*]Set the field [b]delay[/b] to any value you wish the messages for that certain event to be delayed for (in seconds). This delay will be added to the delay of the individual messages.[/list] [b]Step 2: Adding Event Messages[/b] [list] [*]Do not set a value for the field [b]id[/b], it will automatically determined! [*]Set the field [b]display[/b] to any value from [b]0 to 15[/b]. Each display mode adds up, valid display modes are: 1 - Text Area 2 - Popup Area 4 - Hint Area 8 - Center Area If you leave this empty, it will default to 1. [*]Set the field [b]servers[/b] to a comma-sperated list of ServerIDs you wish the advertisement to be displayed on. You can specify [b]-1,[/b] if you want the advertisements on all servers. You must have a comma on the end (for example [b]1,2,3,[/b]). You can also start the entry with an exclamation mark ([b]![/b]). This means all following ServerIDs will be excluded ([b]!1,2,[/b] would exclude server 1 and 2, but still show the advertisement on all other servers) [*]Set the field [b]order[/b] to any value from [b]0 to 255[/b] depending on when you want the event message to be displayed. If left empty, it will use 128. [*]Set the field [b]delay[/b] to any value you wish the messages for that certain event to be delayed for (in seconds). This delay will be added to the delay of the event. [*]Set the field [b]type[/b] to a integer value according to the eventids. You need to add the 2 ^ eventid to this field to have the message displayed for this event. For example, if you have player_connect with eventid 1, player_activate with eventid 2 and player_death with eventid 3 and you want the message to be shown on player_connect and player_death events, you need to add [b]2^1 + 2^3 = 2 + 8 = 10[/b] here.[/list] [b]Step 3: Adding Advertisement Translations[/b] [list] [*]Do not set the field [b]id[/b], it will be automatically determined [*]Set the field [b]emid[/b] to the id of the event message [*]Set the field [b]language[/b] to the 2 char language identifier (for example [b]en[/b] or [b]de[/b]). (You can look up the language identifiers used by eventscripts in [b]addons/eventscripts/_libs/python/deflangs.ini[/b] If you leave this empty, it will default to [b]en[/b]. [*]Set the field [b]text[/b] to the string you want to show up ingame. You may use special variables inside of that string that will be replaced on run time: [b]{CURRENTMAP}[/b] - Current map [b]{TIME}[/b] - Time as set for your server [b]{DATE}[/b] - Data as set for your server [b]{CVAR:[i]my_cvar[/i]}[/b] - current value of [i]my_cvar[/i] (any cvar may be used) Additionally, for text area messages you can use [b]#green #lightgreen[/b] and [b]#default[/b] to change the colour of the messages. These tags will not show up in future messages [*][b]DO NOT create double entries for the same language and aid![/b][/list] [color=blue][b]Webshortcuts (added in 1.02.000)[/b][/color] [list] [*]Leave the field [b]id[/b] empty. It will be automatically determined [*]Set the field [b]command[/b] to the command to be used for the webshortcut; it can also be a comma-sperated list of commands [*]Set the field [b]title[/b] to the title of the webpage (will be displayed ontop of the ingame browser) [*]Set the field [b]url[/b] to the string you want to show up ingame. You may use special variables inside of that string that will be replaced on run time: [b]{NAME}[/b] - Name of the user opening the webshortcut [b]{STEAMID}[/b] - Complete Steamid of the user opening the webshortcut [b]{USERID}[/b] - Current Userid of the user opening the webshortcut [b]{IP}[/b] - Current IP-Address of the user opening the webshortcut [b]{SERVER_IP}[/b] - Server IP Adress (as defined in the db or automatically retrieved) [b]{SERVER_PORT}[/b] - Server Port (as defined in the db or automatically retrieved) [b]{LANG}[/b] - Language of the user opening the webshortcut [*]Set the field servers to a comma-sperated list of ServerIDs you wish the webshortcut to be available on. You can specify -1, if you want the webshortcut on all servers. You must have a comma on the end (for example 1,2,3,). You can also start the entry with an exclamation mark (!). This means all following ServerIDs will be excluded (!1,2, would exclude server 1 and 2, but still show the advertisement on all other servers)[/list] Proceed these steps as often as necessary. Once you're done, load the script on the server again with es_load mysqlads. If you wish to determine the server by sid instead of ip and port, edit config.ini and set the sid accordinly (and reload the script).[/list] [size=150][color=blue][b]Troubleshooting:[/b] [/color] [/size] [list][color=blue][b]Plugin throws up an ImportError upon trying to load it (Failed to import MySQLdb or pymysql)[/b][/color]: There are 2 possible reasons for this error: [b]1. You don't have MySQLdb or pymysql installed (properply)[/b] [list]Please reinstall the the plugin. The files have to be in the eventscripts/_engines/python/Lib/site-packages/ folder to be loaded properly. As for MySQLdb, simply downloading from the website will not be suffient for an installation. You need to compile the c code included within the download yourself first. [WINDOWS] To solve this, you can install python 2.5 (32bit) on your computer, download [url=http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.win32-py2.5.exe/download]MySQL-python-1.2.2.win32-py2.5.exe[/url], install it on your python installation and copy the files over from site-packages in the python directory.[/list] [b]2. MySQLdb or pymysql doesn't load properly[/b] [list]To further verifiy this issue, you can create a simple script in [b]eventscripts/test/test.py[/b]. Add into the file [b]import MySQLdb[/b] or [b]import pymysql[/b][/list] [color=blue][b]Plugin unloads itself (Server not found in database. Unloading.)[/b][/color] This can have possible reasons aswell. [b]1. Server IP and Port is set incorrectly (with autodection enabled - sid = -1)[/b] [list]Doublecheck the settings in your database. The IP and port must exactly match the Port and IP on your Server - make sure that no whitespaces are included.[/list] [b]2. Server IP is failing to be determined (with autodection enabled - sid = -1)[/b] [list]This can be an issue within the script itself (since it fetches the IP from a website). This may be temporary, but if it persists, disable the autodection feature and set the sid manually[/list] [b]3. Server Port is not the same like specified on launch parameters (with autodection enabled - sid = -1)[/b] [list]This can happen easily if the server crashes a lot. Source sometimes tries it to run it on the next port if you have other servers running in that port range. To solve this, either set the sid manually, or make sure there is at least 5 port difference between your server ports.[/list] [color=blue][b]Plugin unloads itself (No advertisements found for this server. Unloading.)[/b][/color] There are only few possible reasons for this issue: [b]1. You forgot the trailing comma ( , ) in the sid colomn of the advertisements table[/b] [list]The comma must be included or the servers (/ the last one) won't be fetched properly from the database. Doublecheck whether you are missing any trailing commas[/list] [b]2. You don't have any advertisements defined for this server[/b] [list]Make sure that there is an advertisement defined for this server (either explecitly, or though -1, for example.[/list] [/list] [size=150][color=blue][b]Download:[/b] [/color] [/size] [list][b][url]http://addons.eventscripts.com/addons/view/mysqlads[/url][/b][/list] [color=blue][size=150][b]Version Notes:[/b][/size][/color] [list][b]1.02.000:[/b] [list] [*]Option to automatically reconnect to MySQL Server incase it crashes added [*]Updater (Sub-)Script added [*]Support for MySQL Webshortcuts added [*]Support for MySQL Event based messages/advertisements added [*]Some additonal quotes upon table creation [*]Internal db structure sightly changed (Each entry has an unique id now)[/list] [b]1.01.002:[/b] [list] [*]Enforced UTF8 Connection to the MySQL Server[/list] [b]1.01.001:[/b] [list] [*]Added error incase no advertisements were loaded from the database [*]Made errors more accurate incase no matching server was found in the database[/list] [b]1.01.000:[/b] [list] [*]Support for pymysql added (untested) [*]Changed tables to be created with utf8 charset [*]Support for server exclusion (entries starting with !) added[/list] [b]1.00.000:[/b] [list] [*]Public Release[/list][/list] [size=150][color=blue][b]Credits:[/b][/color][/size] [list]The following people are honoured to receive special thanks: [list] [*]Some in #eventscripts channel (freddukes? I think) for pointing out that a certain bin() function was rather useless :P [/list][/list]

Installation

See description.

Version Notes For 1.02.000

Updated on: 2010-10-21 17:51:39 EST by Omega_K2 (View Zip Contents)
[b]1.02.000:[/b] [list] [*]Option to automatically reconnect to MySQL Server incase it crashes added [*]Updater (Sub-)Script added [*]Support for MySQL Webshortcuts added [*]Support for MySQL Event based messages/advertisements added [*]Some additonal quotes upon table creation [*]Internal db structure sightly changed (Each entry has an unique id now) [/list]

( Previous Versions )