Raised This Month: $ Target: $400
 0% 

include defines from ini file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sparkey
Senior Member
Join Date: May 2010
Old 01-11-2011 , 17:41   include defines from ini file
Reply With Quote #1

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!
sparkey is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-11-2011 , 18:24   Re: include defines from ini file
Reply With Quote #2

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.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 01-11-2011 , 18:27   Re: include defines from ini file
Reply With Quote #3

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.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
sparkey
Senior Member
Join Date: May 2010
Old 01-12-2011 , 17:28   Re: include defines from ini file
Reply With Quote #4

Thx alot guys!!

The long answer solved it!! Thanks man!
sparkey is offline
sparkey
Senior Member
Join Date: May 2010
Old 01-13-2011 , 18:42   Re: include defines from ini file
Reply With Quote #5

Dont know where my head was but now i feel kinda retarded

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!
sparkey is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-13-2011 , 19:03   Re: include defines from ini file
Reply With Quote #6

Just read the file for each line and parse the lines for the data you want.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-13-2011 , 19:07   Re: include defines from ini file
Reply With Quote #7

See the tutorials or any plugin that reads from a file (too many to count).
__________________
fysiks is offline
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 02:06.


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