Raised This Month: $ Target: $400
 0% 

Ad Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 06-03-2007 , 23:25   Ad Help
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Random Ads"
#define VERSION "1.0"
#define AUTHOR "Styles"

#define maxstuff 256
new g_adAmount 0
new filename[256]

new 
g_AdList[maxstuff]


public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
get_configsdir(filename,255)
    
format(filename,255,"%s/adlist.txt",filename)
    
register_cvar("sv_adtime""120")
    
register_clcmd("amx_reloadads""load"ADMIN_KICK"Reload ad list")
    
set_task(20.0"load")
    
set_task(get_cvar_float("sv_adtime"), "printAd"0""0"b")
    
}

public 
load()
{
    new 
readdata[128], txtlenparsedad[256]
    
g_adAmount 0
    
while(read_file(filename,g_adAmount++,readdata,127,txtlen))
    {
        
parse(filename,parsedad,sizeof(parsedad))
        
formatexg_AdList[g_adAmount], maxstuff 1parsedad )
    }
    
client_print(0print_chat"[Advertisement Mod] %i ad(s) loaded."g_adAmount)
}

public 
printAd()
{
    new 
num random_num(1g_adAmount)
    
client_print(0print_chat"%s"g_AdList[num])

This isan't working for some reason. 1) If you have 3 lines it is adding an extra. 2) Sometimes it prints out the directory of the ad instead of the actual ad. 3) Sometimes... it doesn't even print out anything.. it doesn't work.
Styles is offline
Send a message via AIM to Styles
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-04-2007 , 00:47   Re: Ad Help
Reply With Quote #2

I think I would do like this :

Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Random Ads" #define VERSION "1.0" #define AUTHOR "Styles" #define MAX_STUFF 50 #define MAX_LENGTH 191 new         configsdir[256],     filename[256],     g_AdList[MAX_STUFF][128], //  -------------     g_adAmount,     g_adtime;     public plugin_init()   {     register_plugin( PLUGIN, VERSION, AUTHOR );         g_adtime = register_cvar( "sv_adtime", "15" );     register_clcmd( "amx_reloadads", "load", ADMIN_KICK, "Reload ad list" );           get_configsdir( configsdir, sizeof( configsdir ) - 1 );     formatex( filename, sizeof( filename ) - 1, "%s/adlist.txt", configsdir );           set_task( get_pcvar_float( g_adtime ), "printAd", 0, _, _, "b" );     load(); } public load() {     // -- read the file     new fp = fopen( filename, "rt" );         // -- if the file doesn't exist     if( !fp )     {         server_print( "Inexistent file: ^"%s^"", filename );         return;     }         static buffer[MAX_LENGTH];         while( !feof( fp ) )     {         // -- get a line         fgets( fp, buffer, MAX_LENGTH - 1 );                 // -- clean spaces         trim( buffer );                 // -- empty line or comment > ignore         if( !buffer[0] || buffer[0] == ';' )             continue;                 // -- clean all '"'         replace_all( buffer, MAX_LENGTH - 1, "^"", "" );                 // -- save in array         formatex( g_AdList[g_adAmount++], MAX_STUFF - 1, buffer );     }     fclose( fp );     server_print( "[Advertisement Mod] %i ad%s loaded.", g_adAmount, g_adAmount < 2 ? "" : "s" ); } public printAd() {     new num = random( g_adAmount );     client_print( 0, print_chat, "%s", g_AdList[num] ) ; }

And in adlist.txt file, I will put lines like this :

Quote:
"Hello world!"
"Welcome on my server!"
"Hi here. Woot, woot"
__________________

Last edited by Arkshine; 06-04-2007 at 00:57.
Arkshine is offline
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 06-04-2007 , 17:04   Re: Ad Help
Reply With Quote #3

Thanks
Styles is offline
Send a message via AIM to Styles
-=[SD]=-Turkey
Member
Join Date: Jul 2006
Location: Ohio, United States of A
Old 06-04-2007 , 20:31   Re: Ad Help
Reply With Quote #4

I just made something like this, except mine is hardcoded.
__________________
If you thought my post was helpful, please add karma
-=[SD]=-Turkey is offline
Send a message via AIM to -=[SD]=-Turkey
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 06-04-2007 , 20:34   Re: Ad Help
Reply With Quote #5

ima pimp it out and release it ;)
Styles is offline
Send a message via AIM to Styles
-=[SD]=-Turkey
Member
Join Date: Jul 2006
Location: Ohio, United States of A
Old 06-04-2007 , 20:35   Re: Ad Help
Reply With Quote #6

Sweet. Look at my post and see if you cant help me
__________________
If you thought my post was helpful, please add karma
-=[SD]=-Turkey is offline
Send a message via AIM to -=[SD]=-Turkey
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 06-04-2007 , 21:35   Re: Ad Help
Reply With Quote #7

he already got to it Mines/arkshine text file based
Styles is offline
Send a message via AIM to Styles
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:33.


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