AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to Read Ini File and Hold Values (https://forums.alliedmods.net/showthread.php?t=136281)

TheKidz 08-24-2010 19:27

How to Read Ini File and Hold Values
 
Im kinda newbie with ini files thing, and i need some help here.
the thing is:
1) Read the File
2) Hold some Lines Readed
3) Cut Something From the Lines Readed
4) Transform it into a Vote

if its possible i wish u guys could explain those things and how to do.. :D

fysiks 08-24-2010 20:16

Re: How to Read Ini File and Hold Values
 
For reading a .ini file see my Bot Apology plugin (in my signature).

1,2. You can use parse() on a line to break it up into variables. To use parse the line would need to look like this:

3.
Code:

"thing1" "thing2" "thing3"
4. See the "New Menus Tutorial" in the Code Snippets/Tutorials section.

TheKidz 08-24-2010 20:29

Re: How to Read Ini File and Hold Values
 
can you make an example of parse() with your example ? =S

Bugsy 08-24-2010 20:39

Re: How to Read Ini File and Hold Values
 
Quote:

Originally Posted by TheKidz (Post 1280988)
can you make an example of parse() with your example ? =S

PHP Code:

new szTest[] = "hello my friend";
new 
szHello] , szMy] , szFriend];

parseszTest szHello charsmaxszHello ) , szMy charsmaxszMy ) , szFriend charsmaxszFriend ) );

//Each variable now holds each respective word.

//Or
new szTest[] = "^"hello my^" friend";
new 
szHelloMy] , szFriend];

parseszTest szHelloMy charsmaxszHelloMy ) ,  szFriend charsmaxszFriend ) ); 


TheKidz 08-25-2010 14:58

Re: How to Read Ini File and Hold Values
 
and there is anyway to change set_task time based on cvar number from config file ? =o

nikhilgupta345 08-25-2010 15:11

Re: How to Read Ini File and Hold Values
 
Code:

new cvarTime = register_cvar("Time", 10")

new pcvarTime = get_pcvar_num(cvarTime)

set_task(pcvarTime, .....)


TheKidz 08-25-2010 15:50

Re: How to Read Ini File and Hold Values
 
i mean take the number from the file, and set_task(thenumber, ...)

nikhilgupta345 08-25-2010 16:06

Re: How to Read Ini File and Hold Values
 
you could, or you could just put the code i told you in ur code, and then put time "whatever number" here and then it would work.

Bugsy 08-25-2010 16:20

Re: How to Read Ini File and Hold Values
 
Read the value from the file then do:

set_task( str_to_float( szValFromFile ) , ... );


All times are GMT -4. The time now is 21:51.

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