Raised This Month: $ Target: $400
 0% 

Advertisements - MySQL Updated 2/5/09


Post New Thread Reply   
 
Thread Tools Display Modes
Svpernaut
Junior Member
Join Date: Apr 2007
Old 01-17-2011 , 20:32   Re: Advertisements - MySQL Updated 2/5/09
Reply With Quote #421

@Laplace & Cadav0r

have you recentally installed this plugin?
Im a server tech for torchservers.com so im not a noob or anything
Svpernaut is offline
Cadav0r
Senior Member
Join Date: Jan 2006
Location: France
Old 01-18-2011 , 08:00   Re: Advertisements - MySQL Updated 2/5/09
Reply With Quote #422

This plugin runs prefectly since I reinstalled my servers in December and January...

Have you got errors in your log error file?
__________________
P.S : Sorry for my english but I'm French

My plugins : Admin Sounds




Cadav0r is offline
Dagunchi
Member
Join Date: Sep 2009
Old 01-18-2011 , 17:38   Re: Advertisements - MySQL Updated 2/5/09
Reply With Quote #423

It runs perfectly, but i suggest to use with Sourcemod webadmin!
Dagunchi is offline
Svpernaut
Junior Member
Join Date: Apr 2007
Old 01-24-2011 , 17:29   Re: Advertisements - MySQL Updated 2/5/09
Reply With Quote #424

Well now its not even compiling?
Svpernaut is offline
Svpernaut
Junior Member
Join Date: Apr 2007
Old 01-24-2011 , 18:21   Re: Advertisements - MySQL Updated 2/5/09
Reply With Quote #425

Even when I install sourcemod webadmin I still get the same error
Svpernaut is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 02-02-2011 , 02:53   Re: Advertisements - MySQL Updated 2/5/09
Reply With Quote #426

Compiled.
Attached Files
File Type: smx sm_adsmysql.smx (18.7 KB, 123 views)
Drixevel is offline
PharaohsPaw
Senior Member
Join Date: Dec 2008
Old 02-14-2011 , 21:44   MAJOR PLUGIN AND WEB INTERFACE UPDATE
Reply With Quote #427

Hello everyone,

I've been using this plugin myself for quite some time and have seen the same problems or "wishes for features" many others out there have brought up over the last year and a half or so. Things like editing an existing ad messing up which game the ad works for after you save it, wishing it were possible to define which server(s) an ad runs on, doing better SELECT's so only ads you want on that gameserver instance get fetched from the DB, etc.

For everyone else out there who has been hoping to see someone finally (and actually) release an update to this plugin that addresses a lot of the issues and requests, I have good news for you today.

I spent much of the past weekend working on this plugin and its original web interface, and have managed to get some substantial extensions made as well as incorporating a couple of fixes described by others previously in this thread.

I will not try to take exclusive credit for everything I did here. Without other examples of plugin code to go by, other people's work, and the sourcemod coding docs at sourcemod.net, most of this would not have happened.


BEAR WITH ME
This is a long post. It is both a description of the changes I have made to this plugin, as well as some documentation of how to use the new features.

NEW FEATURES IN THE PLUGIN AND WEB INTERFACE

1 - SERVER ID'S FOR ADS
Ability to optionally define a unique server ID for each gameserver, and define which server ID's a particular ad should run on if you don't want it to run on all servers of that game type.

2 - NEW PLUGIN CVAR FOR SERVERID: sm_adsmysql_serverid
I've also created a new cvar to go along with the serverid, sm_adsmysql_serverid. The value of this cvar is initially set at plugin load by the serverid.txt file if a valid one is created. If no serverid.txt is found or it isn't a valid file, etc. the value of this cvar will be "" (undefined).

If you change the value of this cvar after plugin load, it automatically reloads the ads database 2 seconds later (since the new ID will likely affect which ads the server is supposed to run).

Please see the USAGE section below for more important information about using this CVAR.

3 - UPDATED *ORIGINAL* WEB INTERFACE TO DEFINE THE SERVER ID'S AN AD RUNS ON
Updated the ORIGINAL web interface to add a Server ID's column in the ads display page, and a text input field in the add/edit section to let you type in either "All" or a comma-separated list of "Gameserver ID's" that an ad should run on.

4 - DEFINE MORE THAN ONE GAME TYPE AN AD CAN RUN ON
The ability to define more than one GAME TYPE in the web interface that an ad should run on. The web interface has been changed to use a "select" listbox rather than radio buttons to pick which game(s) an ad should run on, in order to facilitate this change.

This is useful because of the differences (and similarities) in colors that games can display. You can define one ad that looks good with the colors TF2 and CS:S can do, for example, and define another ad with the same text but which uses different color tags for your L4D servers. etc., etc.

5. PLUGIN UPDATE/FIX - ONLY SELECT/LOAD THE ADS WE WANT ON THIS SERVER
Rikaelus's changes to the SQL SELECT queries and then some. I actually added to those to get the functionality described above, however only the ads that are supposed to be running on the gameserver in question will be fetched from the database and still offers the extended configurability described above.

There is one remaining "to-do" item on this related to left4dead2 ads on left4dead servers, see below...


INSTALL INSTRUCTIONS

Most important - make sure you are working with *MY* .zip file before you proceed, not the one in the original post in this thread! Mine have a "pp" version, like "pp1.4.3a" as part of the .zip filename!

Otherwise you can/should for the most part follow Strontium Dog's original instructions except for what is here below.

STEP 1 - DO THIS FIRST!!!
ANOTHER FIELD/COLUMN IS NEEDED IN YOUR ADSMYSQL TABLE FOR SERVER ID'S TO WORK


For existing plugin users:
It will be necessary to add another column/field to the adsmysql table for the server ID feature to work. your databases.cfg file should help you figure out which database you need to modify if you're not sure.

For the MySQL cmdline junkies, you can manually add the gamesrvid field (without tearing up your existing adsmysql table) as I did.

The column/field name you need to add is 'gamesrvid'. It needs to be a text type field, not NULL, with no default value or extra attributes.

Assuming you have the the right database active already from the command line or phpmyadmin interface (or whatever else blows your skirt), the following SQL query will add the table for you:

Code:
ALTER TABLE `adsmysql` ADD `gamesrvid` TEXT NOT NULL AFTER `game` ;
Of course I'll have to recommend you back up your existing database before making any changes. If you mess up your database I won't able to help you with that.

For new/fresh plugin users/installers:
The adsmysql.sql file I've included in the top directory of the unpacked .zip file is modified from the original in the first post to add the extra table as part of the setup, and the sample ads in the file are also updated to include the new field/column. Other than this you can/should basically follow Strontium Dog's original instructions about setting up the database, adding it to databases.cfg, etc.


STEP 2 - INSTALL UPDATED WEB INTERFACE

The .zip file contains a complete set of install files of the web interface with my updates to it - this is the web/adsmysql folder in the unpacked zip.

FOR EXISTING PLUGIN USERS:
If you already have the web interface installed/running, then you only
absolutely HAVE to replace these 3 files from the web/adsmysql/ folder in the .zip:

ads.php
ads_edit.php
ads_process_data.php

though I would appreciate it if you would also replace:

about.php
since it adds me to the credits for my work.

Copy them to wherever the existing ones are on your web host, replacing them. You can back up your originals first if you want to... but I don't think you'll ever use them again...

Also see the TOP LOGO ISSUES section below.

Or, just keep it simple... back up your existing adsmysql folder tree on
the web server somewhere, then replace the entire new tree. More details about this in the "FIRST TIME INSTALLERS" section below.

FIRST TIME INSTALLERS:
The web interface is the directory "adsmysql" underneath web/ in the .zip file. You will want to copy/FTP/scp this adsmysql directory tree in its recursive entirety to your web host. You will find the index.php pretty much everything else runs off of in the web/adsmysql directory, if that helps.

In Linux, you could 'cp -av web/adsmysql /var/www/html/' if you were setting Apache up with /var/www/html/adsmysql as your DocumentRoot.

TOP LOGO ISSUES - ALL USERS
ads.php
has been modified to load an 800x100 top logo named logo03.jpg rather than logo02.jpg that the rest of the web pages in the interface use. Samples of both files are included in the .zip file with our community logo. This is because the ads page uses a "background fill" to the left of the logo image and it looked better to use a different logo image that right-aligns the text rather than centers it.

You will need to decide what you want to do about this - you can either:

- Create an 800x100 logo03.jpg of your own and put it in adsmysql/images (where you will also find logo02.jpg);

- Edit ads.php to use images/logo02.jpg instead of images/logo03.jpg (it's about 10 lines down from the top of ads.php)

- Copy adsmysql/images/logo02.jpg to adsmysql/images/logo03.jpg if you don't want to try editing the img filename ads.php looks for;

or whatever...

Top Logo "Left Fill" Background Color For ads.php
Also note that if you are going to put your own logo on your web interface, you will want to edit the background-color:#000000; line in the td.imgbg style definition in style.css to a color that "works well" with the background color of your logo. #000000 is black.


STEP 3 - INSTALL UPDATED SOURCEMOD PLUGIN

I've included both the "source" .sp file in the .zip's sourcemod/scripting/ directory, and a pre-compiled .smx file in the .zip's sourcemod/plugins/ directory. The pre-compiled one was built on sourcemod 1.3.6.

I will also continue posting updated .sp file's separately with any further updates I make so that if you want to use the web compiler built into the forums, you can do that as well.

Use whichever method you want, but you need to put the sm_adsmysql.smx file in addons/sourcemod/plugins/ -- unless you have multiple sourcemod dirs under addons -- if you do and you have working servers, you don't need my help with where to put the .smx file LOL


STEP 4 - (OPTIONAL) DEFINE THE SERVER ID

The serverid is stored in the special file (sourcemod base dir)/configs/adsmysql/serverid.txt, which the plugin checks for at plugin load.

Defining a server ID is optional -- it doesn't HAVE to be defined -- but not defining a server ID means the server will only load ads defined for All game types, or for games of the same type which have "All" set in the gamesrvid field in the database.

The proper location of this file should be (gameserver root)/addons/sourcemod/configs/adsmysql/serverid.txt for people who do not have multiple sourcemod dirs under addons/.

1. To define the server ID string in serverid.txt, create the directory adsmysql under your sourcemod/configs directory. It won't exist already.

2. Inside this directory, create the file serverid.txt. A sample one is provided in the .zip file which you would only need to add a server ID string to.

In this file, type the unique ID string you wish to define for this server as the *ONLY* uncommented line in the file. Do not enclose the ID in quotes or anything else. The plugin will tolerate lines commented using "//" that are ahead/on top of the uncommented line, however only the first uncommented line will even be read. Therefore, the following would be a valid serverid.txt file:

Code:
 // this is a comment
 css35
whereas if you had this instead:
Code:
 // this is a comment
 css35
 css26
It would be valid, but the server would still set "css35" as its serverid. As I said, only the first uncommented line gets read. which also means this example file:
Code:
   
 // blank line above
would most likely result in an undefined serverid.

WHY DID I DEFINE THIS TO BE UNDER (sourcemod base dir)/configs/adsmysql/ ?
I deliberately coded putting the serverid.txt file under (sourcemod base dir)/addons/sourcemod because I run multiple gameserver instances off of one tree with multiple sourcemod dirs under addons/ (ie, sourcemod1, sourcemod2, etc.). The serverid is supposed to be unique so it doesn't do you much good to code it where you have to define the serverid in sourcemod.cfg or to autoexec the config from a custom plugin .cfg file under cfg/ - since *ALL* of the servers are going to read these, you would't get a per-server unique ID.


USAGE

1. SELECTING WHICH GAME TYPE(S) AN AD SHOULD RUN ON

In the Game Type section at the bottom left of the add/edit screen, click the game type you want the ad to run for. If you want the ad to run on ALL game types, select All Games.

To select multiple game types, Ctrl-click multiple games in the select box.

The web interface already says it, but I'll say it again here anyway:
DO NOT select All Games together with other game types for an ad. The web interface will LET you do it, but it won't work. The plugin's SQL SELECT functions that search for ads to load ONLY do "equal to" searches for All, not substring searches. Keep it simple, "all means All." If you want the ad to run on all games, select All Games and nothing else. If you only want to run the ad on certain game types, only select the game type(s) you want it to run on.


2. DEFINING THE SERVER(S) AN AD SHOULD RUN ON BY SERVER ID IN THE WEB INTERFACE
If you wish an ad to run on ALL servers of the selected game type(s), you need to type All in the Server ID's text input box in the bottom right area of the web interface. This is the default contents of the input box.

You must define a server ID on a gameserver which matches the server ID's defined for the ad before that server will display an ad that is only set to run with specific server ID's!

If you only want the ad to run on certain servers of that game type but not all of them -- for example, only 3 of the 5 CS:S servers you have running this plugin -- then you would select Counterstrike Source for the game type, then type the server ID's for these 3 servers in the Server ID text input box of the web interface. To specify multiple server ID's, separate them with commas.

Here's a valid example for the Server ID's text input box in the web interface:

Code:
css01,iceworld,gungame1
Tip: I'm not 100% sure whether it would be a problem or not, but you probably don't want to use spaces in your server ID's. Also, in case it matters, don't use spaces to pad/separate server ID's. Separate them (ONLY) with commas like the example above shows.

The web interface already says this, but I'll say it again here:
DO NOT use All together with other server ID strings for an ad. The web interface will LET you do it, but it won't work. The plugin's SQL SELECT functions that search for ads to load ONLY do "equal to" searches for All, not substring searches. Keep it simple, "all means All." If you want the ad to run on all servers of that game type, type All and nothing else. If you only want to run the ad on certain servers, only specify the server ID's you want it to run on.

Also, I am pretty sure that if you have All Games set for the Game Type, the server ID field will be ignored and you will see the ad on all the servers. Again, think "all means ALL". Don't use it if you don't mean it.


3. Further Info About Defining the Server ID on the Gameserver
The installation section above gives you the "nuts and bolts" of how to define the server ID for each server. This section gives a little more info.

USER TIP: DONT USE SERVER ID'S THAT WOULD BE A SUBSTRING MATCH FOR ANOTHER SERVER'S ID
The SQL queries performed by the plugin use "simple" LIKE queries to match gameserver ID field values other than "All". You do not want to have two server ID's defined where the entire ID of one server is also a substring match for another. For example, setting one server's ID to css1, and setting another's to css13, would violate this and cause you problems I am not going to try to fix. Specifically, an SQL LIKE query searching for "css1" would retrieve results for both. "css001" and "css013" would be much better choices. MAKE THE SERVER ID'S UNIQUE.

CAUTION ABOUT CHANGING THE sm_adsmysql_serverid CVAR IN MID-GAME
Note that if you change sm_adsmysql_serverid it will NOT update serverid.txt -- so at next map change, server restart, etc. it will very likely revert the value of sm_adsmysql_serverid to what is in serverid.txt. If you want the serverid change to "stick", you need to update serverid.txt as well. Think of the ability to change the cvar while the server is running, at least for now, as a convenient way to change the ID and reload the ads (based on that new ID) without having to change the map or restart the server.

I have not tested yet what happens if you only define sm_adsmysql_serverid in a server's server.cfg file (or whatever servercfgfile is (re)defined as) - ie, if you do not define it in serverid.txt at all. It may work fine, but I am not sure if the plugin is loaded early enough to "see" the cvar being set. There could conceivably be problems with (for example) the first map on a server start, and maybe even problems after a map change. I do know for sure that storing the value in configs/mysqlads/serverid.txt works. Since I am hooking changes to this cvar I am not 100% confident in suggesting anyone try defining sm_adsmysql_serverid in a server .cfg file until I have tested it out myself. I'll get rid of the serverid.txt file if it can be done, but I suspect we will have to keep it.

TROUBLESHOOTING SERVER ID ISSUES
There are two different log messages defined in the plugin to warn you if the serverid is undefined:

1. If no serverid.txt file is found at plugin startup (because one hasn't been created, or it was created in the wrong place), you'll see a log message like this:
Code:
L 02/16/2011 - 06:51:26: [sm_adsmysql.smx] adsmysql: configs/adsmysql/serverid.txt not read - file not found.
2. When the plugin is about to fetch ads from the database, it checks if the server id is undefined (because if it is, using it in a LIKE query causes problems...). If it is undefined, you will see a log message like this:

Code:
L 02/14/2011 - 14:31:32: [sm_adsmysql.smx] adsmysql: sm_adsmysql_serverid is undefined


SCREENSHOTS

Here is what the "top part" of the updated ads list web interface looks like, note there is now a Server ID(s) field:




Here's the bottom section, showing the updated Game Type selector and the the Server ID's text input area:




CONCLUSION

In all of my work/testing, adding new ads and editing existing ones both work properly, including "pre selecting" the game types that were originally defined for the ad when you edit it in the web interface.

The ads are properly "fetched" from the database and display according to how they have been configured to do so, except the one problem with left4dead2-specific ads being fetched from the DB on left4dead servers (see to-do list below). Other than that, everything I am claiming works does to the best of my ability to test it on all our different servers.

Support
I can't commit myself to providing a lot of ongoing support for what I'm posting here. The code changes are pretty well documented with comments. I'm not saying I will not do anything else on this plugin and won't answer ANY questions about what I did, but if the answer to your question is already in the documentation above or already in comments in the web or plugin source code, there's a really good chance I'm not going to respond.

Also I won't have time to answer questions like how to set up a server, how to set up sourcemod, how to install PHPMyAdmin, etc. Google is your friend.

I changed the plugin info (authors, version, and website URL), the top logos, and added myself into the about.php credits to reflect that I have put considerable work into this plugin which has been to a large degree unmaintained for quite some time now. I'm sorry if that offends anyone, I don't mean to. You can always edit the .sp and css/php code and compile your own. It is open-source.


TO-DO LIST

There are a few other things I would like to fix, or would appreciate if someone more experienced could fix, with this plugin.

1. ADS DISPLAY TWO AT A TIME SOMETIMES (priority)
This is a problem that has existed with this plugin for some time. I believe Rikaelus was on the right track with his observation that two timers may be inadvertently getting created and both firing at the same (relative) time. This happens pretty consistently for our L4D and L4D2 servers, but I don't really see it happening so much (or at all) on our CS:S or TF2 servers.

I will *TRY* to fix this or at least look at it in some depth/detail, but I am not an experienced sourcemod coder and I am sure someone who is could spot the problem very quickly and know the proper way to address it. If someone who knows WTF they are doing with timers in Sourcemod could look at this it would probably save me a lot of time and I know a lot of other server operators would appreciate it.

2. TEACH THE PLUGIN HOW TO TELL THE DIFFERENCE BETWEEN left4dead AND left4dead2 WHEN LOADING ADS (priority)

The web interface can tell the difference between left4dead and left4dead2 when editing existing ads, and when you create new ones, it will properly set the fields in the database according to what you selected for the ad. This may not sound like much, but it took hours of my weekend to get right.

Unfortunately I have not gotten the corresponding work done in the SQL select/fetch/etc code in the plugin yet (the code that loads ads for "this" server). However if you edit an existing ad in the web interface, it will/should properly figure out whether it was originally created for left4dead or left4dead2 (or both), pre-select the appropriate field(s), and update it properly when you commit the changes.

PS: DAMN YOU VALVE for naming the game directory of one as a substring of the other!!!

Right now if you have ads defined that have "left4dead2" in the gameserver ID field in the database, the plugin's SQL SELECT's will find these and load them if it is running on a left4dead server, even if the game ID *ONLY* defines left4dead2. The web interface ad edit page can tell the difference, but until the plugin has similar code added to handle this properly, left4dead servers are going to find ads that are defined for your left4dead2 servers.

I'll get to it as soon as I can. Or if someone else wants to do it, you can look at the isgamelisted() PHP function I added to ads_edit.php for some pointers (or laughs). I won't say that function is the best or most efficient way to do it, but it works the best I can tell.

3. GAME TYPE COLUMN DOESNT SHOW ICONS WHEN MORE THAN ONE GAME IS SET (lower priority)
Again, it's cosmetics. Since the PHP code uses the game folder name as the filename base for the .gif file it should be fairly easy to fix/extend for my >1 game per ad mod, but it's not a big priority for me right now. If more than one game type is defined for an ad, it displays in the column from the SQL row's field basically as-is, for example "tf,cstrike". What's really important is that the add/edit functions of the web interface and the plugin's SQL SELECT calls can deal with the field correctly, and except for the left4dead/left4dead2 problem with the plugin, I've already taken care of that.


APPRECIATION
Karma is cool and all, but if you want to thank me in a meaningful way, send some decent people over to play on our servers. They sit empty a lot of the time, even though the server hardware and internet pipe are top quality. You can see a list of our servers on our HLStatsX:CE main page.

cheers,


PharaohsPaw

Penguins With Nerf Guns gaming community

HLStatsX:CE: http://stats.pwng.net
Website/Forums: http://forums.pwng.net
Steam Community: http://steamcommunity.com/groups/pwng

PS: The sm_adsmysql.sp file is posted separately here for review purposes and for the convenient web-based plugin compiler. If you intend to use this modded plugin, make sure you grab the .ZIP file -- you'll need it for the updated web interface that works with the changes I've made to the plugin.


Last edited by PharaohsPaw; 02-19-2011 at 10:34. Reason: couple minor fixes to web interface
PharaohsPaw is offline
PharaohsPaw
Senior Member
Join Date: Dec 2008
Old 02-15-2011 , 13:07   Re: Advertisements - MySQL Updated 2/5/09
Reply With Quote #428

OK fixed the run-on text under Game Type: with some br tags. It looked great on the other (non-widescreen) monitor but I noticed the problem on the widescreen monitor while doing the screenshots. This is fixed now in the ads.php and ads_edit.php in the pp1.4.3a zip.

EDIT: Updated the screenshots in post above ^^^

Last edited by PharaohsPaw; 02-15-2011 at 13:21.
PharaohsPaw is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 02-16-2011 , 00:28   Re: Advertisements - MySQL Updated 2/5/09
Reply With Quote #429

Thanks PharaohsPaw, I'll be testing out the new version and i'll give you any bug reports if i find any. i did a few changes to it to make it an advertisements plugin instead of sm_adsmysql plugin.
Drixevel is offline
Nomarky
SourceMod Donor
Join Date: Sep 2007
Old 02-16-2011 , 05:48   Re: Advertisements - MySQL Updated 2/5/09
Reply With Quote #430

At last, been waiting for this for years! Now I can finally use this plugin to admin ads on our servers. Great work, will test today
Nomarky is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode