Raised This Month: $ Target: $400
 0% 

CFG and INI files


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[cTs] Strake*ROC*
Member
Join Date: Mar 2004
Old 07-03-2004 , 00:44   CFG and INI files
Reply With Quote #1

I am read tons of amx plugins, yet i still cant figgure out how to make a plugin to read a CFG or INI file!

Can anyone help me with the basics for making a plugin read a file?

Thanks,
[cTs] Strake*ROC*
__________________
[cTs] Strake*ROC* is offline
kingpin
Veteran Member
Join Date: Apr 2004
Location: kpsforum.com
Old 07-03-2004 , 00:55  
Reply With Quote #2

u want to know how to read and write to one so like a kinda vault file maybe? or just a pre made cfg?
__________________
kingpin is offline
Send a message via ICQ to kingpin Send a message via AIM to kingpin Send a message via MSN to kingpin Send a message via Yahoo to kingpin Send a message via Skype™ to kingpin
[cTs] Strake*ROC*
Member
Join Date: Mar 2004
Old 07-03-2004 , 01:00  
Reply With Quote #3

i wana be able to make a plugin, that read an INI file,
for plugins like one i am working on, that tells clan members if they have been promoted or not to a new rank, so when they log on, it checks the INI file, and if their Steam ID is in the file, then it tells them GRATZ you been Promoted!
__________________
[cTs] Strake*ROC* is offline
kingpin
Veteran Member
Join Date: Apr 2004
Location: kpsforum.com
Old 07-03-2004 , 01:01  
Reply With Quote #4

yeah but is it writeable from inside the server? becuase then its a vault type file thats what meant is it writeable from inside server or no?
__________________
kingpin is offline
Send a message via ICQ to kingpin Send a message via AIM to kingpin Send a message via MSN to kingpin Send a message via Yahoo to kingpin Send a message via Skype™ to kingpin
[cTs] Strake*ROC*
Member
Join Date: Mar 2004
Old 07-03-2004 , 01:02  
Reply With Quote #5

as in command like

amx_newpromo "steam ID"

?

No, i want it so i can write a file, and the server uses it...

the
Users.ini
and amx mod X
__________________
[cTs] Strake*ROC* is offline
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 07-03-2004 , 11:41  
Reply With Quote #6

I want to read from an INI file, like a list of clan tags (ya know what i mean).
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
kingpin
Veteran Member
Join Date: Apr 2004
Location: kpsforum.com
Old 07-03-2004 , 11:54  
Reply With Quote #7

well I have been trying to write good examples of how u can use a cfg file but I think best would be if u see an actually example so without further ado here is a small place from Lud's map cvar plugin :
Code:
if(file_exists("addons/amxx/custom/map_cvars.txt") == 1){         new line = 0         new data[128]         new stextsize = 0         new type[4]         new map_or_lock[32]         new map_cvar[64]         new value[32]         log_message("[AMXX][MAPCVARS] Cvar exec / plugin pause-unpause begin")         while((line=read_file("addons/amxx/custom/map_cvars.txt",line,data,128,stextsize))!=0){             parse(data,type,4,map_or_lock,32,map_cvar,64,value,32)             if(equali(type,"M",1)){                 if(map_on == true){                     map_on = false                 }                 if( (equali(map_or_lock,ThisMap)) || (equali(map_or_lock,"*allmaps")) ){                     map_on = true                 }             }             else if(equali(type,"C",1)){                 if(map_on == true){                     copy(locked_cvar[inum_cvars],64,map_cvar)                     copy(locked_value[inum_cvars],32,value)                     if(equal(map_or_lock,"1"))                         locked_yn[inum_cvars] = 1                     if(cvar_exists(map_cvar)){                         server_cmd("%s %s",map_cvar,value)                         log_message("[AMXX][MAPCVARS] Executed:  %s %s",map_cvar,value)                         inum_cvars +=1                         if(inum_cvars >= 25){                             map_on = false                             log_message("[AMXX][MAPCVARS] Warning:   Limit of 25 special cvars reached.")                         }                     }else{                         invalid = 1                         log_message("[AMXX][MAPCVARS] Warning:   Cvar ^"%s^" does not exist.", map_cvar)                     }                 }             }             else if(equali(type,"P",1)){                 if(map_on == true){                     if(equali(map_or_lock,"P",1))                         do_pplugin(0,map_cvar)                     else if(equali(map_or_lock,"U",1))                         do_pplugin(1,map_cvar)                 }             }         }

just gotta let the plugin read specific "words/cvars" in the file and then place a
Attached Files
File Type: sma Get Plugin or Get Source (map_cvars.sma - 1036 views - 10.4 KB)
__________________
kingpin is offline
Send a message via ICQ to kingpin Send a message via AIM to kingpin Send a message via MSN to kingpin Send a message via Yahoo to kingpin Send a message via Skype™ to kingpin
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 07-03-2004 , 12:16  
Reply With Quote #8

Luds huh, will I talk with him on a regular basis, everyday in fact, usefull isent he.
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
kingpin
Veteran Member
Join Date: Apr 2004
Location: kpsforum.com
Old 07-03-2004 , 12:22  
Reply With Quote #9

lol well im certain my views on Mr. lidman are well known. but yeah I generally refrence his plguin library when I need help.
__________________
kingpin is offline
Send a message via ICQ to kingpin Send a message via AIM to kingpin Send a message via MSN to kingpin Send a message via Yahoo to kingpin Send a message via Skype™ to kingpin
Zor
Veteran Member
Join Date: Mar 2004
Location: Toronto, ON
Old 07-03-2004 , 15:05  
Reply With Quote #10

Ok I just threw this together and compiled it. The compile works but I'm not sure if it does:

Code:
/*
*	All rights reserved BlackWatch Clan
*	Author:		|BW|.Zor
*	Version:	0.1
*	Description:
*		Check an ini file for a user and tell them they are promoted
*/

#include <amxmodx>

//////////////////////////////////////////////
// Version Control
//
new AUTH[] = "|BW|.Zor"
new PLUGIN_NAME[] = "Promotion"
new VERSION[] = "0.1"
new ACCESS = ADMIN_LEVEL_A
//
//////////////////////////////////////////////

//////////////////////////////////////////////
// Globals
//
new fileName[] = "addons/amxx/custom/promotion.ini"
//
//////////////////////////////////////////////

public plugin_init()
{ 
	// Register the plugin
	register_plugin(PLUGIN_NAME,VERSION,AUTH) 

	// Register the console commands
	register_concmd("amx_newpromo", "input", ACCESS, "- adds someone to the promotion list")
}

public client_putinserver(id)
{
	new steam[2][32], promotion[64], lineIn[96], counter = 0, a = 0, placeToRemove = 0
	
	get_user_authid(id, steam[0], 31)
	
	while( read_file(fileName, counter, lineIn, 95, a) != 0 )
	{
		// Parse the line out.  If you manually input a promotion make sure its at the
		//end of the file and looks like the following:
		// "STEAM_0:0:123456" "Killer"
		
		parse(lineIn, steam[1], 31, promotion, 63)
		
		// Are the 2 steam ids equal?
		if(equal(steam[0], steam[1]))
		{
			client_print( id, print_console, "You have been promoted to %s, congrats, change your name!", promotion)
			placeToRemove = counter
		}
		
		counter++	
	}
	
	// Remove that entry so It wont tell em again
	if( placeToRemove > 0)
	{
		counter = placeToRemove + 1
		while( read_file(fileName, counter++, lineIn, 95, a) != 0 )
		{
			write_file(fileName, lineIn, placeToRemove++)
		}
		
		write_file(fileName, "", counter)
	}
	
	return PLUGIN_CONTINUE
}

public input(id)
{
	if(read_argc() < 2)
	{
		client_print(id, print_console, "[AMXX] Usage: amx_newpromo STEAM_0:0:123456 PromotionName")
		return PLUGIN_HANDLED
	}
	
	new fileLength = file_size(fileName, 1)
	new command[2][64], temp[128]
	read_argv(1, command[0], 63)
	read_argv(2, command[1], 63)
	

	format(temp, 127, "^"%s^" ^"%s^"", command[0], command[1])
	write_file(fileName, temp, fileLength)
	
	return PLUGIN_CONTINUE
}
Cheers! And good luck with it!
Zor
Attached Files
File Type: sma Get Plugin or Get Source (amx_promotion.sma - 939 views - 2.2 KB)
__________________
Zor is offline
Send a message via AIM to Zor Send a message via MSN to Zor Send a message via Yahoo to Zor
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 14:57.


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