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(PLUGIN, VERSION, AUTHOR)
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], txtlen, parsedad[256]
g_adAmount = 0
while(read_file(filename,g_adAmount++,readdata,127,txtlen))
{
parse(filename,parsedad,sizeof(parsedad))
formatex( g_AdList[g_adAmount], maxstuff - 1, parsedad )
}
client_print(0, print_chat, "[Advertisement Mod] %i ad(s) loaded.", g_adAmount)
}
public printAd()
{
new num = random_num(1, g_adAmount)
client_print(0, print_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.