View Single Post
Author Message
Ahmad12
New Member
Join Date: Aug 2021
Old 08-06-2021 , 00:50   error with compiling a plugin
Reply With Quote #1

Code:
/*   	Anti Reklama v3.0 © 2010, ->UrOS<-
	Contact e-mail [email protected]
	
	Formatright
    
	*English*
	This plugin is free software;
	you can modify it under the terms of the
	GNU General Public License as published by the Free Software Foundation.
    
	*Serbian* 
	Ovaj plugin je besplatni program;
	mozete ga menjati postujuci prava autora, samo ga ne smete prodavati.
    
*/

#include <amxmodx>
#include <amxmisc>
#include <geoip>
#include <colorchat>

#define SIZE 32 
#define MAX_PLAYERS 32 
#define ACCESS	    ADMIN_RCON

enum {     CHECK_NO,     CHECK_FIRST,     CHECK_CHANGgE }

new pCvar_MaxDigits
new pCvar_Prefix[SIZE]
new pCvar_Status
new pCvar_Punish
new pcvar_Menu[40]
new szMessage[ 194 ]
new g_iCheckStatus[ MAX_PLAYERS + 1 ]
new ON_OFF

new const g_szNameKey[ ] = "37.59.43.196:27018 Swarm"

public plugin_init( ) 
{     

	register_plugin( "Anti Reklama", "3.0c", "Exolent/->UrOS<-" )
	register_cvar("antireklama", "3.0c" , (FCVAR_SERVER|FCVAR_SPONLY))
	register_srvcmd("antireklama_prefix", "prefix")  
	
	register_clcmd( "say", "CmdSay" )
	register_clcmd( "say_team", "CmdSay" )
	
	register_clcmd("say /antireklama", "menuItem")
	register_clcmd("say_team /antireklama", "menuItem")
	
	pCvar_Status = register_cvar("antireklama_status", "1", ADMIN_RCON)  
	pCvar_Punish = register_cvar("antireklama_kazna", "0", ADMIN_RCON)  	
	pCvar_MaxDigits = register_cvar( "antireklama_maxbrojeva", "12", ADMIN_RCON)
} 

public plugin_precache()
{
	precache_sound("vox/access.wav")
	precache_sound("vox/denied.wav")
}

public prefix()
{    
	remove_task(123)
	read_argv(1, pCvar_Prefix, SIZE-1)
}	

public CmdSay( id ) 
{  
	if(get_pcvar_num(pCvar_Status) == 1)
   	{
		read_args( szMessage, charsmax( szMessage ) )
		remove_quotes( szMessage )
	   
		new iCount
		new iMax = get_pcvar_num( pCvar_MaxDigits )
	   
		new i = -1
		while( szMessage[ ++i ] )     
		{         	
			if( '0' <= szMessage[ i ] <= '9' )         
			{        
				if( ++iCount >= iMax )            
				{  				       
					AntiReklamaMotd( id )
					AntiReklamaLog( id, szMessage )	
					AntiReklamaPunish( id )				
					return PLUGIN_HANDLED
				}         
			}     
		}         
	}
	return PLUGIN_CONTINUE
}

public client_putinserver( id ) 
{  
	if(get_pcvar_num(pCvar_Status) == 1)
	{
		g_iCheckStatus[ id ] = CHECK_FIRST
	   
		new szName[ 32 ], text[512]
		get_user_name( id, szName, charsmax( szName ) )
	   
		if( !IsNameValid( szName ) )     
		{
			AntiReklamaLog( id, "Adversting..." )	
			format(text,511,"%s Anti Reklama", pCvar_Prefix)
			AntiReklamaMotd( id )
			set_user_info( id, g_szNameKey, text)	
			AntiReklamaPunish( id )	
		}   
		g_iCheckStatus[ id ] = CHECK_CHANGE
	}
}

public client_disconnected( id )     
	g_iCheckStatus[ id ] = CHECK_NO	
	
public client_infochanged( id ) 
{ 
	if(get_pcvar_num(pCvar_Status) == 1)
	{	    
		if( g_iCheckStatus[ id ] == CHECK_CHANGE )     
		{
			new newname[32],oldname[32], text[512]
			get_user_info(id, "37.59.43.196:27018 Swarm", newname,31)
			get_user_name(id, oldname,31)
		       
			if( !equal( newname, oldname)         &&  !IsNameValid(newname ) )         
			{   
				AntiReklamaLog( id, "Adversting..." )
				format(text,511,"%s Anti ", pCvar_Prefix)
				set_user_info( id, g_szNameKey, text) 
				AntiReklamaPunish( id )
				AntiReklamaMotd( id )
			}     
		}
	}
} 

bool:IsNameValid( const szName[ ] ) 
{     
	new iCount
	new iMax = get_pcvar_num( pCvar_MaxDigits )
   
	new i = -1
	while( szName[ ++i ] )
	
	{         
		if( '0' <= szName[ i ] <= '9' )         
		{            
			if( ++iCount >= iMax )             
			{                 
				return false
			}        
		}     
	}        
	return true
}

public AntiReklamaLog( id, szMessage[] )
{
	new szName[ 32 ], szAuthID[ 32 ], szUserIP[ 32 ], szCountry[ 32 ]

	get_user_name( id, szName, 31 )
	get_user_authid( id, szAuthID, 31 )
	get_user_ip( id, szUserIP, 31, 1 )
	geoip_country( szUserIP, szCountry )
	
	static szLogData[ 200 ]
	formatex( szLogData, sizeof szLogData - 1, "Nick: %s | ID: %s | IP: %s | Zemlja: %s | %s", szName, szAuthID, szUserIP, szCountry, szMessage)
	log_to_file( "antireklama.log", szLogData )
	console_print( id, szLogData )

	return PLUGIN_HANDLED
}

public AntiReklamaPunish(id)
{
	if ( get_pcvar_num(pCvar_Punish) == 2 )
	{
		client_cmd(id, "kill")
	}
	else if ( get_pcvar_num(pCvar_Punish) == 3 )
	{
		server_cmd("amx_kick #%d ^"If this was not an attempt to advertise, we apologize.^"",get_user_userid(id))
	}
	else if ( get_pcvar_num(pCvar_Punish) == 4 )
	{
		client_cmd(id, "quit")
	}
	else if ( get_pcvar_num(pCvar_Punish) == 5 )
	{
		server_cmd("amx_gag #%d 300 abc ",get_user_userid(id))
	}	
	else if ( get_pcvar_num(pCvar_Punish) == 6 )
	{
		server_cmd("amx_ban #%d 5 ^"If this was not an attempt to advertise, we apologize.^"",get_user_userid(id))
	}	
}

public AccessDenied(id)
	client_cmd(id, "spk vox/denied.wav")

public menuItem( id )
{    
	if( !(get_user_flags( id ) & ACCESS ) )
	{
		ColorChat(id, TEAM_COLOR,"^4[%s] ^1You do not have access to this command!", pCvar_Prefix)
		client_cmd(id, "spk vox/access.wav")		
		set_task(0.6, "AccessDenied", id, _, _, "a", 1)
		return PLUGIN_CONTINUE
	}
	
	new status = (get_pcvar_num(pCvar_Status) == 1)
	ON_OFF = status
	
	formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\rAnti Reklama - Menu")
	new menu = menu_create( pcvar_Menu, "menuAction" )
		
	formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\d Status Plugin \r[\d%s\r]", (ON_OFF  & status) ? "On" : "Off")
	menu_additem( menu, pcvar_Menu, "0" )
		
	formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\d Type of punishment \r[\d%i\r]", get_pcvar_num(pCvar_Punish))
	menu_additem( menu, pcvar_Menu, "1" )    
		
	menu_display( id, menu )
		
	return PLUGIN_CONTINUE
}

public menuAction( id, menu, item ) 
{ 
	if( item >= 0 )  
	{ 
		new access, callback, actionString[ 2 ]         
		menu_item_getinfo( menu, item, access, actionString, charsmax( actionString ), _, _, callback )         
         
		new action = str_to_num( actionString ) 
		{ 
			switch( action ) 
			{ 
				case 0: 
				{ 
					formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\rAnti Reklama - Menu")
					new menu = menu_create( pcvar_Menu, "menu1" )
					
					formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\d Turn on Plugin")
					menu_additem( menu, pcvar_Menu, "0" )
					
					formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\d Turn it off Plugin")
					menu_additem( menu, pcvar_Menu, "1" )    
					
					menu_display( id, menu ) 
				} 
			     
				case 1: 
				{ 
					formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\rAnti Reklama - Menu")
					new menu = menu_create( pcvar_Menu, "menu2" )
					
					formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\d Without penalty")
					menu_additem( menu, pcvar_Menu, "0" )
				
					formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\d Kill")
					menu_additem( menu, pcvar_Menu, "1" ) 				
					
					formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\d Kick")
					menu_additem( menu, pcvar_Menu, "2" )    

					formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\d Quit")
					menu_additem( menu, pcvar_Menu, "3" )   
				
					formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\d Gag 5 min")
					menu_additem( menu, pcvar_Menu, "4" ) 				
				
					formatex( pcvar_Menu, charsmax( pcvar_Menu ), "\d Ban 5 min")
					menu_additem( menu, pcvar_Menu, "5" )	
				
					menu_display( id, menu )   
				} 
			} 
		}     
	}    
	menu_destroy( menu ) 
	return PLUGIN_HANDLED 
} 

public menu1( id, menu, item ) 
{ 
	if( item >= 0 )  
	{ 
		new access, callback, actionString[ 2 ]         
		menu_item_getinfo( menu, item, access, actionString, charsmax( actionString ), _, _, callback )         
         
		new action = str_to_num( actionString ) 
		{ 
			switch( action ) 
			{ 
				case 0: 
				{ 
					server_cmd("antireklama_status 1")
					ColorChat(0, TEAM_COLOR,"^4[%s] ^1Anti Advertising plugin is on!", pCvar_Prefix) 
				} 
			     
				case 1: 
				{ 
					server_cmd("antireklama_status 0") 
					ColorChat(0, TEAM_COLOR,"^4[%s] ^1Anti Advertising plugin is off!", pCvar_Prefix) 
				} 
			} 
		}     
	}    
	menu_destroy( menu ) 
	set_task(0.1, "menuItem", id, _, _, "a", 1) 
	return PLUGIN_HANDLED 
} 

public menu2( id, menu, item ) 
{ 
	if( item >= 0 )  
	{ 
		new access, callback, actionString[ 2 ]         
		menu_item_getinfo( menu, item, access, actionString, charsmax( actionString ), _, _, callback )         
         
		new action = str_to_num( actionString ) 
		{ 
			switch( action ) 
			{ 
				case 0: 
				{ 
					server_cmd("antireklama_kazna 1")
				} 
				case 1: 
				{ 
					server_cmd("antireklama_kazna 2")
				} 
				case 2: 
				{ 
					server_cmd("antireklama_kazna 3")
				} 	
				case 3: 
				{ 
					server_cmd("antireklama_kazna 4")
				} 
				case 4: 
				{ 
					server_cmd("antireklama_kazna 5")
				} 
				case 5: 
				{ 
					server_cmd("antireklama_kazna 6")
				} 		
			} 
			ColorChat(id, TEAM_COLOR,"^4[%s] ^1Changes are successfully saved", pCvar_Prefix) 
		}     
	}    
	menu_destroy( menu ) 
	set_task(0.1, "menuItem", id, _, _, "a", 1) 
	return PLUGIN_HANDLED 
} 

public AntiReklamaMotd(id) 
{ 			
	static motd[1501], len
		    
	len = format(motd, 1500,"<body bgcolor=#000000><font color=#87cefa><pre>")
	len += format(motd[len], 1500-len,"<h4 align='center'><font size='6' color='#FF0000'>%s ﺮﺸﻨﻟﺍ ﺩﺎﻀﻣ^n</font>", pCvar_Prefix)
	len += format(motd[len], 1500-len,"<h4 align='center'><font size='4' color='#FFFFFF'>ﺔﻴﺟﺭﺎﺧ ﺕﺍﺮﻓﺮﻴﺳ ﻭﺍ ﻊﻗﺍﻮﻣ ﺮﺸﻧ ﻊﻨﻤﻳ</font>")			
	len += format(motd[len], 1500-len,"<h4 align='center'><font size='4' color='#FFFFFF'>.ﺭﺬﺘﻌﻧ ﻦﺤﻧ ، ﺎﻄﺨﻟﺎﺑ ﺕﺮﻬﻇ ﺓﺬﻓﺎﻨﻟﺍ ﻩﺬﻫ ﻥﺍ ﺪﻘﺘﻌﺗﻭ ﺮﺸﻧ ﻱﺎﺑ ﻢﻘﺗ ﻢﻟ ﺍﺫﺍ^n^n^n</font>")
	len += format(motd[len], 1500-len,"<center><h4><font color=^"white^"><B>-----------------------</B> </font></h4></center>")	
	len += format(motd[len], 1500-len,"<h4 align='center'><font size='1' color='#FF0000'><h4>ﺮﻜﺑ ﻮﺑﺃ</h4></font>")
	len += format(motd[len], 1500-len,"<h4 align='center'><font size='1' color='#FF0000'><h4>ﺱﺪﻘﻟﺍ ﺮﻓﺮﻴﺳ ﺓﺭﺍﺩﺇ</h4></font>") 
	len += format(motd[len], 1500-len,"<center><h4><font color=^"white^"><B>-----------------------</B> </font></h4></center>")	
	
	show_motd(id, motd, "No Adversting 1.0") 
}
when i try to compile it i get :
Error: Undefined symbol "CHECK_CHANGE" on line 114
Error: Undefined symbol "CHECK_CHANGE" on line 125

can any one help me to compile it
thanks
Ahmad12 is offline