In-Game Advertisement System
by stupok, with many thanks to 10stars
This plugin allows you to use a menu to place an entity flush with any wall, ceiling, floor, or entity. You can then modify the texture of your own model or use a fixed sprite (not rotating) or regular sprite to contain an image or advertisement. You can save ads into a .txt file. These ads will automatically load.
Download .sma, compile, put .amxx in your plugins folder. Now, restart your server so the plugin can run once. The first time it runs, it will create all of the necessary directories and files.
You won't see any items in the menu when you use +place_ad
, because there are no entries in the file "precache_list.cfg"
during the first run. You must add entries to this file to see them in the menu.
Bind a key to +place_ad
and hold down the key to place the entity flush with another surface. Let go of the key when the entity becomes flush with the surface. When you let go of the key, a menu will come up letting you choose a model/sprite and scale up/down the sprite.
For animated sprites, place the sprite on a wall just like any other sprite, save it, and then edit the mapname.txt
to include frames
Menu items 1-4 are precached models listed in
. Add items to the list if you'd like to see them in the menu.
If you select save, the coordinates, angles, and scale will be saved into a .txt file located in
- hold down to place an ad flush with a wall.
- move the ad closer to you.
- move the ad away from you.
- move the ad away from you.
- delete ads. This command will show a menu with all ads on the map.
I would NOT suggest creating a directory and files. Just run your server with the plugin installed and the proper files and directory will be created automatically.
This is where all of the entities are saved. The plugin later reads this file to load the entities.
(Do not place more than one "thing" on one line. Model/sprite, origin, angles, scale should each have their own line.)
//this is a comment, the plugin will ignore this line
origin -1635.000000 703.000000 254.000000
angles 0.000000 90.000000 0.000000
//this is an animated sprite
origin 907.000000 2078.000000 87.000000
angles 0.000000 990.000000 0.000000
//how many frames per second?
//framerate MUST be the last item
//this is a model
origin -1441.000000 -8.000000 173.000000
angles 0.000000 180.000000 0.000000
If you want to see your model or sprite in the menu, add it to this file. The plugin precaches or "loads" the entities in this file so you can view them in-game.
How to make a sprite or model with your logo/advertisement
//If you would like to choose which model/sprite to place when placing an ad, add the item to the list below.
- To change the texture of a model, you can use Jed's Half-Life Model Viewer.
1. Open the model, select the "Texture" tab, choose the correct texture file from the list-box, select "Export".
2. Use an image editor to change the texture. Remember, your final product will not have exactly the same colors as you want, because of the texture's original index of colors. Save the file.
3. Open the model, select the "Texture" tab, choose the correct texture file from the list-box, select "Import", select "Save Model".
Sprite:[LIST][*]Convert a bitmap to a sprite.
1. Make a .bmp file, preferably with width and length that are multiples of 8. Remember, the width * height must not exceed 10752.
1. Make a .bmp file, with whatever dimensions you want! Sprite Explorer gave me warnings with oddly sized sprites
but they work just fine.
If the width * height of the sprite exceeds 10752, or if the width or height of the sprite is not a multiple of 8, you may encounter the error below:
Fatal Error GL_Upload16: s&3
To resolve the problem, recreate the sprite and try again. There is no definite solution that I am aware of.
2. You must save the .bmp in Indexed Mode, NOT RGB Mode. RGB will work, but the sprite will have odd colors.
3. Open a sprite creator like Sprite Explorer
. Select "File>New Sprite", add your .bmp file(s), and save your sprite. To make an animated sprite just add all the frames during this step.
4. To make the sprite stop rotating, use ORIENTED rather than VP_PARALLEL.
5. To make a sprite with an invisible background, use a solid color background in your bmp and use AlphaTest when creating the sprite.
NOTE: This video shows version 1.44, last updated 02/10/07.
a1uqfk47 - Original idea
12/10/08 - v1.83 - Now the engine handles animated sprites.
- Removed "frames" property, now you only define framerate.
- Several variables removed, more comments.
11/08/08 - v1.82 - Fixed delete bug. Previously, deleting the last entry in
the file would cause an infinite loop. Oops!
- More efficient. Prethink is only hooked while placing ad.
06/22/08 - v1.71 - Small bugfix. Thanks, connorr.
05/17/08 - v1.70 - Added ability to delete adverts in-game.
- Advert placement function optimized, better functionality.
- Added command iga_further.
- Cleaned up code a bit.
05/22/07 - v1.60 - Added compatibility for animated sprites. Woohoo!!
05/10/07 - v1.50 - Small adjustment in distance from wall.
05/08/07 - v1.49 - Fixed newline character error in v1.48.
05/07/07 - v1.48 - Fixed issue with Linux compatibility.
- Added two commands for moving the advertisement.
04/21/07 - v1.47 - Overlooked ability for other users to control ad
02/10/07 - v1.44 - More optimization. Switched to new file natives.
02/06/07 - v1.43 - Fixed saving incorrect sprite angles.
02/03/07 - v1.42 - More optimization, and some comments.
02/01/07 - v1.41 - Small optimization and minor changes.
01/30/07 - v1.40 - Overlooked client prethink when converting to FM.
Now it's fixed.
01/28/07 - v1.39 - Converted to FakeMeta for precision. Now entities will
be exactly flush with any wall, rather than almost flush.
-Fixed saving incomplete filename.
-No more pressing menu option 2 times to flip sprite, now
the sprite is ALWAYS angeled correctly while placing. Move
toward client if sprite is invisible.
01/20/07 - v1.38 - Fixed a bug, thanks Ramono :)
01/19/07 - v1.37 - More optimization.
01/18/07 - v1.36 - OPTIMIZATION!!! Hopefully more to come...
01/16/07 - v1.35 - Added MAX_MODEL_NAMELEN to prevent crashes due to
model's filename length.
01/16/07 - v1.34 - Odd angles during placement should be eliminated
completely (unless during movement from one to another
01/14/07 - v1.33 - More error reporting, no more wall.mdl requirement, fixed
01/14/07 - v1.32 - Server will report error instead of crashing
upon failed precache.
01/13/07 - v1.31 - Fixed menu size.
01/13/07 - v1.3 - Added:
-New menu and menu options.
-Loading saved ads.
-Saving scale of sprites
-Entity having odd angles while placing.
01/07/07 - v1.2 - Changed way of placing advertisement, should be simpler.
01/07/07 - v1.1 - Slight optimization, removed unnecessary function.
01/07/07 - v1.0 - Initial release
Errors / Bugs
- If you write entries in the mapname.txt that are not formatted correctly, the server may crash/explode and your sprites or models may spontaneously combust.
- I recommend using sprites whose width * height does not exceed 10752 to avoid the "Fatal Error GL_Upload16: s&3" error. Please read above for more details.
v1.71 - 927 downloads
v1.82 - 251 downloads