Raised This Month: $ Target: $400
 0% 

hostname changer


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 04-25-2007 , 09:12   Re: hostname changer
Reply With Quote #12

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

#define Plugin "Server Name Changer"
#define Version "1.0"
#define Author "Doombringer"

new time_to_change
new const name_file[] = "server_names.ini"
new server_names[100][180], num_of_names, current_name

public plugin_init()
{
	register_plugin(Plugin, Version, Author)
	time_to_change = register_cvar("NC_change_time", "120")
	
	read_names()
	set_task(get_pcvar_float(time_to_change), "change_name",_,_,_, "b")
}

public read_names()
{
	new configsdir[64], dir[132]
	get_configsdir(configsdir, 63)
	
	format(dir, 131, "%s/%s", configsdir, name_file)
	new file = fopen(dir, "rt")
	
	if(!file)
	{
		server_print("Could not find the %s file", name_file)
		return PLUGIN_CONTINUE
	}
	
	new text[180]
	
	while(!feof(file))
	{
		fgets(file, text, 179)
		
		if( (strlen(text) < 2) || (equal(text, "//", 2)) )
		continue;
		
		num_of_names++
		server_names[num_of_names] = text
		
		server_print("%s", server_names[num_of_names])
	}
	
	fclose(file)
	server_print("Successfully added %d server names", num_of_names)
	
	return PLUGIN_CONTINUE
}

public change_name()
{
	if(current_name + 1 > num_of_names)
		current_name = 0
	
	current_name++
	server_cmd("hostname ^"%s^"", server_names[current_name])
}
Make a file named server_names.ini and put it in the configs folder.
Change NC_change_time to when it will change name (in seconds)
Deviance is offline
 



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 20:51.


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