Thread: [Solved] Dhud compile error
View Single Post
Author Message
luciaus18
Senior Member
Join Date: Dec 2014
Old 08-28-2022 , 09:37   Dhud compile error
Reply With Quote #1

Hi! I want to install this plugin to my server but I get this error when I want to compile:
Code:
//// amx_ads.sma
// cstrike\addons\amxmodx\scripting\amx_ads.sma(80) : error 088: number of arguments does not match definition
//
// 1 Error.
// Could not locate output file compiled\amx_ads.amx (compile failed).
//
// Compilation Time: 0.22 sec
// ----------------------------------------
Plugin:
Code:
/*
	Created in: 4/3/2019 - 12:07 (GMT+1)
	(https://forums.alliedmods.net/showthread.php?t=314756)

	Feel free to submit any request or idea :) 
	|
	|
	|-->		https://forums.alliedmods.net/showthread.php?t=314756
	
	Changelog: 
		v1.0 - Initial release
		v1.1 - Completely recoded, added new adverbs, added new STYLES et cetera.
		v1.2 - Added new styles, fixed a small bug.
	
	       tttttt hh     EEEEEE ssssss pppppp
		tt   hh     E      ss     pp  pp
	         tt   hhhhhh EEEEEE ssssss pppppp
		tt   hh  hh E          ss pp
		tt   hh  hh EEEEEE ssssss pp
		
	(https://forums.alliedmods.net/member.php?u=281156)
	(https://www.github.com/4D1G06/)
*/

#include <amxmodx>
#include <amxmisc>
#include <cromchat>
#include <dhudmessage>

#define MAX_AD_LENGTH 256
#define starts_with(%1,%2) equali(%1,%2,strlen(%2))

#define STYLE_CHAT 0
#define STYLE_HUD 1
#define STYLE_CENTER 2
#define STYLE_NOTIFY 3
#define STYLE_DHUD 4
#define STYLE_DEFAULT STYLE_CHAT // (0)

#define plugin_name "Advertisment System"
#define plugin_version "1.2"
#define plugin_author "thEsp (4D1)"

#define MAX_ADS 256 // Ehh

new ads_path[88]
new ads[MAX_ADS][MAX_AD_LENGTH]
new ad[MAX_AD_LENGTH]
new pcvar_delay,pcvar_staytime,pcvar_red,pcvar_green,pcvar_blue,ads_count,current_adnum = 0
new players_num[32],maxplayers_num[32],server_name[32],server_ip[32],map[32],game_map[32],map_type[32]
new min_players[32],iplayers,imin_players
new max_players[32],imax_players
new user_deaths[32],user_name[32],user_frags[32]
new min_frags[32],ifrags,imin_frags
new max_frags[32],imax_frags
new team[32],iteam,iplayer_team
new status[32],player_status[32]
new style = STYLE_DEFAULT
new ad_fixed[MAX_AD_LENGTH]
	
public plugin_init()
{
	register_plugin(plugin_name,plugin_version,plugin_author)
	
	pcvar_delay = register_cvar("amx_ads_delay","30")
	pcvar_staytime = register_cvar("amx_ads_hudstaytime","5")
	pcvar_red = register_cvar("amx_ads_red","0")
	pcvar_green = register_cvar("amx_ads_green","255")
	pcvar_blue = register_cvar("amx_ads_blue","0")
	
	get_configsdir(ads_path,charsmax(ads_path))
	format(ads_path,charsmax(ads_path),"%s/ads.txt",ads_path)
	
//	if(!file_exists(ads_path)) write_file(ads_path,"; This is a comment line")
	


	for(new i=0;i<get_file_lines(ads_path);i++)
	{
		read_file(ads_path,i,ads[ads_count],charsmax(ads))
		ads_count++
	}

	if(ads_count != 0) set_task(get_pcvar_float(pcvar_delay),"ShowNextAd")
}

public ShowNextAd(server)
{
check_line:
	copy(ad,charsmax(ad),ads[current_adnum]);
	
	style = STYLE_DEFAULT
	
	if(starts_with(ad,";") || starts_with(ad,"//") || equal(ad,"")) 
	{
		if(current_adnum==ads_count) 
		{
			current_adnum=0
		}else{
			current_adnum++
		}
		goto check_line
	}
		
	/* Conditions */
	
	new bool:can_continue = true

condition_checker:

	/* Map */
	
	if(starts_with(ad,"[map="))
	{
		get_mapname(game_map,charsmax(game_map))
		replace(ad,charsmax(ad),"[map=","")
		split(ad,map,charsmax(map),ad,charsmax(ad),"]")
		if(equal(game_map,map))
		{
			can_continue=true
			goto condition_checker
		}else{
			can_continue=false
		}
	}

	/* Map type */

	if(starts_with(ad,"[map_type="))
	{
		get_mapname(game_map,charsmax(game_map))
		replace(ad,charsmax(ad),"[map_type=","")
		split(ad,map_type,charsmax(map_type),ad,charsmax(ad),"]")
		if(starts_with(game_map,map_type))
		{
			can_continue=true
			goto condition_checker
		}else{
			can_continue=false
		}
	}
	
	/* Min Players */
	
	if(starts_with(ad,"[min_players="))
	{
		replace(ad,charsmax(ad),"[min_players=","")
		split(ad,min_players,charsmax(min_players),ad,charsmax(ad),"]")
		iplayers = get_playersnum()
		imin_players = str_to_num(min_players)
		if(imin_players<=iplayers)
		{
			can_continue=true
			goto condition_checker
		}else{
			can_continue=false
		}
	}

	/* Max Players */
	
	if(starts_with(ad,"[max_players="))
	{
		replace(ad,charsmax(ad),"[max_players=","")
		split(ad,max_players,charsmax(max_players),ad,charsmax(ad),"]")
		iplayers = get_playersnum()
		imax_players = str_to_num(max_players)
		if(imax_players>=iplayers)
		{
			can_continue=true
			goto condition_checker
		}else{
			can_continue=false
		}
	}


	if(can_continue!=true)
	{
		if(current_adnum==ads_count) 
		{
			current_adnum=0
		} else {
			current_adnum++
		}
		set_task(get_pcvar_float(pcvar_delay),"ShowNextAd")
		return
	}

	format(players_num,charsmax(players_num),"%i",get_playersnum())
	format(maxplayers_num,charsmax(players_num),"%i",get_maxplayers())
	
	get_mapname(map,charsmax(map))
	get_user_ip(server,server_ip,charsmax(server_ip))
	get_cvar_string("hostname",server_name,charsmax(server_name))
	
	replace_all(ad,charsmax(ad),"%players%",players_num)
	replace_all(ad,charsmax(ad),"%maxplayers%",maxplayers_num)
	replace_all(ad,charsmax(ad),"%map%",map)
	replace_all(ad,charsmax(ad),"%srvip%",server_ip)
	replace_all(ad,charsmax(ad),"%srvname%",server_name)

	format(ad_fixed,charsmax(ad_fixed),"%s",ad)
		
	for(new i=0;i<33;i++) if(is_user_connected(i))
	{
		format(ad,charsmax(ad),"%s",ad_fixed)
		
		/* ADVANCED Conditions */

adv_condition_checker:

		/* Minimum frags */

		if(starts_with(ad,"[min_frags="))
		{
			replace(ad,charsmax(ad),"[min_frags=","")
			split(ad,min_frags,charsmax(min_frags),ad,charsmax(ad),"]")
			ifrags = get_user_frags(i)
			imin_frags = str_to_num(min_frags)
		
			if(imin_frags<=ifrags)
			{
				can_continue = true
				goto adv_condition_checker
			}else{
				continue
			}	
		}

		/* Maximum frags */

		if(starts_with(ad,"[max_frags="))
		{
			replace(ad,charsmax(ad),"[max_frags=","")
			split(ad,max_frags,charsmax(max_frags),ad,charsmax(ad),"]")
			ifrags = get_user_frags(i)
			imax_frags = str_to_num(max_frags)
	
			if(imax_frags>=ifrags)
			{
				can_continue = true
				goto adv_condition_checker
			}else{
				continue
			}
		}

		/* Team */

		if(starts_with(ad,"[team="))
		{
			iplayer_team = get_user_team(i)
			replace(ad,charsmax(ad),"[team=","")
			split(ad,team,charsmax(team),ad,charsmax(ad),"]")
			iteam = str_to_num(team)
			if(iteam==iplayer_team)
			{
				can_continue = true
				goto adv_condition_checker
			}else{
				continue
			}
		}	

		/* Alive [or dead] */

		if(starts_with(ad,"[life="))
		{
			format(player_status,charsmax(player_status),"%s",is_user_alive(i) ? "alive" : "dead")
			replace(ad,charsmax(ad),"[life=","")
			split(ad,status,charsmax(status),ad,charsmax(ad),"]")
			if(equal(status,player_status))
			{	
				can_continue = true
				goto adv_condition_checker
			}else{
				continue
			}
		}
				
		style = STYLE_DEFAULT
		if(starts_with(ad,"[chat]")) style = STYLE_CHAT
		if(starts_with(ad,"[hud]")) style = STYLE_HUD
		if(starts_with(ad,"[dhud]")) style = STYLE_DHUD
		if(starts_with(ad,"[center]")) style = STYLE_CENTER
		if(starts_with(ad,"[notify]")) style = STYLE_NOTIFY
	
		switch(style) // To replace things
		{
			case STYLE_HUD || STYLE_CENTER || STYLE_NOTIFY || STYLE_DHUD:
			{
				replace_all(ad,charsmax(ad),"&x01","")
				replace_all(ad,charsmax(ad),"&x03","")
				replace_all(ad,charsmax(ad),"&x04","")
				replace_all(ad,charsmax(ad),"&x05","")			
				replace_all(ad,charsmax(ad),"&x06","")
				replace_all(ad,charsmax(ad),"&x07","")
			}
		}
	
		get_user_name(i,user_name,charsmax(user_name))
		format(user_deaths,charsmax(user_deaths),"%i",get_user_deaths(i))
		format(user_frags,charsmax(user_frags),"%i",get_user_frags(i))
		replace_all(ad,charsmax(ad),"%name%",user_name)
		replace_all(ad,charsmax(ad),"%deaths%",user_deaths)
		replace_all(ad,charsmax(ad),"%kills%",user_frags)
		replace_all(ad,charsmax(ad),"%frags%",user_frags)
	
		switch(style)
		{				
			case STYLE_HUD:
			{
				replace(ad,charsmax(ad),"[hud]","")
				set_hudmessage(get_pcvar_num(pcvar_red),get_pcvar_num(pcvar_green),get_pcvar_num(pcvar_blue),-1.0,0.83,0,6.0,get_pcvar_float(pcvar_staytime))
				show_hudmessage(i,"%s",ad)		
			}
			case STYLE_DHUD:
			{
				replace(ad,charsmax(ad),"[dhud]","")
				set_dhudmessage(get_pcvar_num(pcvar_red),get_pcvar_num(pcvar_green),get_pcvar_num(pcvar_blue),-1.0,0.83,0,6.0,get_pcvar_float(pcvar_staytime))
				show_dhudmessage(i,"%s",ad)		
			}
			case STYLE_CHAT:
			{
				replace(ad,charsmax(ad),"[chat]","")
				CC_SendMessage(i,ad)
			}
			case STYLE_CENTER:
			{
				replace(ad,charsmax(ad),"[center]","")
				client_print(i,print_center,ad)
			}
			case STYLE_NOTIFY:
			{
				replace(ad,charsmax(ad),"[notify]","")
				client_print(i,print_notify,ad)
			}
		}
	}
	if(current_adnum==ads_count) 
	{
		current_adnum=0
	} else {
		current_adnum++
	}
	set_task(get_pcvar_float(pcvar_delay),"ShowNextAd")
}

stock get_file_lines(const filename[])
{
	if(!file_exists(filename)) return PLUGIN_CONTINUE
	new temp[3]
	new lines,file_reader = fopen(filename,"rt")
	if(!file_reader) return PLUGIN_CONTINUE
	while(!feof(file_reader))
	{
		fgets(file_reader,temp,charsmax(temp)) // Even tho is not needed, without this server/client will freeze...
		lines++
	}
	fclose(file_reader)
	return lines
}
I need some help

Last edited by luciaus18; 09-02-2022 at 10:21.
luciaus18 is offline