AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   include defines from ini file (https://forums.alliedmods.net/showthread.php?t=147625)

sparkey 01-11-2011 17:41

include defines from ini file
 
Hi there,

Is it possible to include define values from a ini file into the plugin itself?

example

plugin.ini
Code:

#define GAME_TYPE            1
plugin.cpp
Code:

server_print("Value: %d",GAME_TYPE);
Thx!

ConnorMcLeod 01-11-2011 18:24

Re: include defines from ini file
 
defines are use at compile time.

You can read some values from .ini files but then you have to assign them to vars in the plugin.

Emp` 01-11-2011 18:27

Re: include defines from ini file
 
Short Answer: No

Middle Answer: You could read a file (eg. a .ini file) and use the value that is read.

Long Answer: Yes, just include the file, but it would have to be in the same format as a .sma or .inc and it would need to be where it was compiled. So if you were to change the .ini file, you would still need to recompile the script.

sparkey 01-12-2011 17:28

Re: include defines from ini file
 
Thx alot guys!! :)

The long answer solved it!! Thanks man!

sparkey 01-13-2011 18:42

Re: include defines from ini file
 
Dont know where my head was but now i feel kinda retarded :P

I know that it reads the include at compile so i dont know how i got it so wrong in my head. It should read the file at startup :)

Would you mind giving me an example of the middle answer?

Thx!

Exolent[jNr] 01-13-2011 19:03

Re: include defines from ini file
 
Just read the file for each line and parse the lines for the data you want.

fysiks 01-13-2011 19:07

Re: include defines from ini file
 
See the tutorials or any plugin that reads from a file (too many to count).


All times are GMT -4. The time now is 02:06.

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