View Single Post
Rikaelus
Junior Member
Join Date: Aug 2004
Old 05-08-2010 , 20:20   Re: Advertisements - MySQL Updated 2/5/09
Reply With Quote #308

Awesome plugin, this is.
I made a couple small improvements to it and I can share them with the author if he'd like to merge it in with the official package.

Addition:
Basically I added another field named "servers" that, through the GUI, you can specify server IPort(s) you'd specifically like the advertisement for. So, for instance, one TF2 server can advertise another but would never advertise itself. If left blank then there's no filtering.

Bug fix/optimization:
Through testing my addition I discovered that the ad displaying function runs at whatever increment is set (such as 30 seconds) but if the next ad up doesn't qualify (different game, different server) then no ad will show that round, and it doesn't try the next ad for another increment. This effectively means you might not get an ad at the schedule you want.

My fix and optimization was to have it only load the ads that are valid for the server. While technically this could maybe be done in the MySQL query itself, I opted to have the logic run as it iterates through the MySQL response. This way there's output to the console of which were accepted and which were rejected.

With only valid ads being added to the array, the array doesn't store unneeded data (optimization) and only valid ads would come up in the display function, removing the need for the conditional that was there and ensuring there's an ad every X seconds (bug fix).


P.S. Also just found a bug in the GUI in which text strings aren't run through any special character escaping, which lead to failed MySQL calls when using apostrophes.

Last edited by Rikaelus; 05-08-2010 at 20:31.
Rikaelus is offline