Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » .ini
.ini [message #447011] Wed, 11 May 2011 07:21 Go to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
goal:
in my server ive made mes for ppl
i would like to be able to add mes with a .ini so i dont have to update my dll for it

how can i read out .ini and is it possible within a function?

ive tried to understand how ssgm did it.


Owner of kambot TT server

kambot.freeforums.org
Re: .ini [message #447019 is a reply to message #447011] Wed, 11 May 2011 08:30 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
What is a mes? Huh

As for reading a dll file... pretty simple to code your own ini class or, if your building an SSGM plugin, use the ini reading class it already contains (don't know the name off the top of my head as I am at work right now... search for header files with ini in the name perhaps?)


Alternatively use the Windows functions;
http://msdn.microsoft.com/en-us/library/ms724353%28v=vs.85%29.aspx


http://steamsignature.com/card/1/76561197975867233.png

[Updated on: Wed, 11 May 2011 08:32]

Report message to a moderator

Re: .ini [message #447020 is a reply to message #447011] Wed, 11 May 2011 09:33 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
a "me" a person you want to have with the weapons you prefer

edit:

This is what ive done now, this get accepted only how do i load it?

Toggle Spoiler


this is the compile error

.\KB_Commands.cpp(60) : error C2352: 'mes::Load' : illegal call of non-static member function
gmmain.h(155) : see declaration of 'mes::Load'


Owner of kambot TT server

kambot.freeforums.org

[Updated on: Wed, 11 May 2011 12:00]

Report message to a moderator

Re: .ini [message #447027 is a reply to message #447011] Wed, 11 May 2011 13:20 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
You would need

Struct mes {
     static Load(GameObject *obj);
};


In the gmmain.h

[Updated on: Wed, 11 May 2011 13:21]

Report message to a moderator

Re: .ini [message #447034 is a reply to message #447011] Wed, 11 May 2011 13:50 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
how can i make it so its not static because now it gives this

.\KB_Functions.cpp(716) : error C2352: 'SettingsLoader::LoadSString' : illegal call of non-static member function
c:\documents and settings\robby\bureaublad\source\gmsettingsclass.h(23) : see declaration of 'SettingsLoader::LoadSString'

plus eleven more compiler errors caused by this one


Owner of kambot TT server

kambot.freeforums.org
Re: .ini [message #447035 is a reply to message #447034] Wed, 11 May 2011 13:53 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
sorry you need

 Static void Load(GameObject *obj)
Re: .ini [message #447036 is a reply to message #447011] Wed, 11 May 2011 13:54 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
i have that now i get those new errors


robbyke wrote on Wed, 11 May 2011 22:50

how can i make it so its not static because now it gives this

.\KB_Functions.cpp(716) : error C2352: 'SettingsLoader::LoadSString' : illegal call of non-static member function
c:\documents and settings\robby\bureaublad\source\gmsettingsclass.h(23) : see declaration of 'SettingsLoader::LoadSString'

plus eleven more compiler errors caused by this one



Owner of kambot TT server

kambot.freeforums.org

[Updated on: Wed, 11 May 2011 13:55]

Report message to a moderator

Re: .ini [message #447046 is a reply to message #447036] Wed, 11 May 2011 14:43 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
void mes::Load(GameObject *obj){
	std::string me;
	const char*name = Get_Player_Name(obj);
	SettingsLoader::Load();
	mes = new mes("***********.ini");
	LoadSString(me,name,"NULL",true,true,false);

	char preset[500];
	char skin[500];
	char shield[500];
	char powerups[500];
	char scripts[500];
	char scriptparam[500];
	float price = 0;
	float hp =0;
	float ap =0;
	for (int z = 1; ; ++z) {

		if (z==1||z==3||z==4)
		{
			switch(z)
			{
			case 1:
				price = INI->Get_Float(me.c_str(),StrFormat("%02d",z).c_str(),0);
			case 3:
				hp = INI->Get_Float(me.c_str(),StrFormat("%02d",z).c_str(),0);
			case 4:
				ap =  INI->Get_Float(me.c_str(),StrFormat("%02d",z).c_str(),0);
			}
		}
		else
		{
			switch(z)
			{
			case 2:
				INI->Get_String(me.c_str(),StrFormat("%02d",z).c_str(),"",preset,500);
			case 5:
				INI->Get_String(me.c_str(),StrFormat("%02d",z).c_str(),"",skin,500);
			case 6:
				INI->Get_String(me.c_str(),StrFormat("%02d",z).c_str(),"",shield,500);
			case 7:
				INI->Get_String(me.c_str(),StrFormat("%02d",z).c_str(),"",powerups,500);
			case 8:
				INI->Get_String(me.c_str(),StrFormat("%02d",z).c_str(),"",scripts,500);
			case 9:
				INI->Get_String(me.c_str(),StrFormat("%02d",z).c_str(),"",scriptparam,500);
			}
		}
	}
	if (price==0)
	{
		int pID = Get_Player_ID(obj);
		Console_Input(StrFormat("CMSGP %d 255,0,0 Request your me on the forums.",pID).c_str());
	}
	else
	{
		//KB_Purchase_Char(obj,"me",2,price,preset,hp,ap,skin,shield,powerups,scripts,scriptparam);
	}
};



struct mes: public virtual SettingsLoader{
	mes(const char *ININame) : SettingsLoader(ININame){}
	void Load(GameObject *obj);
};


Compiles fine for me.


[Updated on: Thu, 12 May 2011 00:27]

Report message to a moderator

Re: .ini [message #447086 is a reply to message #447011] Wed, 11 May 2011 22:37 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
class KB_Purchase_Char_Me : public ChatCommandClass
{
	void Triggered(int ID,const TokenClass &Text,int ChatType)
	{
		GameObject *obj = Get_GameObj(ID);
		mes::Load(obj);
	}
};
ChatCommandRegistrant<KB_Purchase_Char_Me> KB_Purchase_Char_Me_Reg("!me",CHATTYPE_ALL,0,GAMEMODE_ALL);


i need it as some sort of a function it has to be read as someone requests its me


Owner of kambot TT server

kambot.freeforums.org
Re: .ini [message #447093 is a reply to message #447086] Thu, 12 May 2011 00:28 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
Use the code above i edited it again should work how you want it to just make sure you enter the ini file name in at the top of the code Wink



Im guessing the ini file should be

[NickName]
1=price
2=preset
3=hp
4=ap
5=skin
6=shield
7=powerups
8=screips
9=scriptparam


??

[Updated on: Thu, 12 May 2011 00:30]

Report message to a moderator

Re: .ini [message #447136 is a reply to message #447011] Thu, 12 May 2011 08:51 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
yea the ini is indeed like that

.\KB_Functions.cpp(717) : error C2513: 'mes' : no variable declared before '='
KB_Commands.cpp
.\KB_Commands.cpp(60) : error C2352: 'mes::Load' : illegal call of non-static member function
c:\documents and settings\robby\bureaublad\source\gmmain.h(154) : see declaration of 'mes::Load'

still have these erros

however if i dont call

mes::load(obj)

i can compile so i have to call it some other way, don't I?


Owner of kambot TT server

kambot.freeforums.org

[Updated on: Thu, 12 May 2011 10:54]

Report message to a moderator

Re: .ini [message #447143 is a reply to message #447011] Thu, 12 May 2011 11:20 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
put this under the struct in .h
extern mes *KB_ME;


then put this in .cpp file

mes *KB_ME = 0;


Then do


KB_ME::Load(obj)



Hope this helps
Re: .ini [message #447144 is a reply to message #447011] Thu, 12 May 2011 11:31 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
ok ive done this

gmmain.cpp:
Toggle Spoiler


under gmmain.he

struct mes: public virtual SettingsLoader{
	mes(const char *ININame) : SettingsLoader(ININame){}
	std::string me;
	void Load(GameObject *obj);
	extern mes *KB_ME;

};


however i dont even have the slightest clue why Sad


Owner of kambot TT server

kambot.freeforums.org

[Updated on: Thu, 12 May 2011 11:31]

Report message to a moderator

Re: .ini [message #447146 is a reply to message #447144] Thu, 12 May 2011 11:52 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
struct mes: public virtual SettingsLoader{
	mes(const char *ININame) : SettingsLoader(ININame){}
	std::string me;
	void Load(GameObject *obj);
};

extern mes *KB_ME;


If you get an error double click the error and it will go to the line that the error is at copy the error and the line of code which has the error and i will try and help you out
Re: .ini [message #447147 is a reply to message #447011] Thu, 12 May 2011 12:00 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
.\KB_Commands.cpp(60) : error C2825: 'KB_ME': must be a class or namespace when followed by '::'
.\KB_Commands.cpp(60) : error C2039: 'Load' : is not a member of '`global namespace''
.\KB_Commands.cpp(60) : error C2146: syntax error : missing ';' before identifier 'Load'
.\KB_Commands.cpp(60) : error C3861: 'Load': identifier not found

KB_ME::Load(obj);


Owner of kambot TT server

kambot.freeforums.org
Re: .ini [message #447152 is a reply to message #447147] Thu, 12 May 2011 13:54 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
Suger sorry my mistake

it should be

KB_ME->Load(obj);


Hope this works
Re: .ini [message #447172 is a reply to message #447011] Sat, 14 May 2011 05:24 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
ive got it to compile however server crashes when call upon it Sad so i guess im back to the start Sad


Owner of kambot TT server

kambot.freeforums.org
Re: .ini [message #447174 is a reply to message #447172] Sat, 14 May 2011 05:58 Go to previous messageGo to next message
saberhawk
Messages: 1068
Registered: January 2006
Location: ::1
Karma: 0
General (1 Star)
Why not just use INIClass directly, instead of SettingsLoader? It's inside engine_io.h and it's pretty simple to use. If you'd like to load lists of objects, let me know and I'll upload a modified engine_io with two extra INIClass functions that make it alot easier to do so.

/*
; lolhax.ini
[Section]
IntegerValue=42
FloatValue=13.37
BooleanValue=yes
StringValue=Can you hear me now?
*/

int integer_value = 42;
float float_value = 13.37f;
bool boolean_value = true;
char string_value[128] = "Can you hear me now?";

INIClass* ini = Get_INI("lolhax.ini");
if (ini)
{
	integer_value = ini->Get_Int("Section", "IntegerValue", 42);
	float_value = ini->Get_Float("Section", "FloatValue", 13.37f);
	boolean_value = ini->Get_Bool("Section", "BooleanValue", true);
	ini->Get_String("Section", "StringValue", "Can you hear me now?", string_value, sizeof(string_value)); 
	Release_INI(ini);
}

[Updated on: Sat, 14 May 2011 06:00]

Report message to a moderator

Re: .ini [message #447178 is a reply to message #447011] Sat, 14 May 2011 06:31 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
that narrowed my crash error down to reading the ini, thnx ^^

edit:

the server crashes when it opens the .ini :s

ive been checkin its really weird but it cant open the .ini without crashing


Owner of kambot TT server

kambot.freeforums.org

[Updated on: Sat, 14 May 2011 13:59]

Report message to a moderator

Re: .ini [message #447223 is a reply to message #447178] Sat, 14 May 2011 14:10 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
Have you for the ini file in the renegade server dir. make sure its not in the data folder

Re: .ini [message #447238 is a reply to message #447223] Sat, 14 May 2011 22:32 Go to previous messageGo to next message
saberhawk
Messages: 1068
Registered: January 2006
Location: ::1
Karma: 0
General (1 Star)
snazy2000 wrote on Sat, 14 May 2011 17:10

Have you for the ini file in the renegade server dir. make sure its not in the data folder




If you use INIClass (like you should), make sure it's in the Data folder...
Re: .ini [message #447245 is a reply to message #447011] Sat, 14 May 2011 23:59 Go to previous message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
if it cant open the ini it works but it doesnt when it tries to open the ini

i had placed the ini in both dirs

ive tried to send messages to pinpoint where exactly that the program crashes and as soon as it needs to open the .ini it crashes

OMG OMG i fixed it =D

Toggle Spoiler


if i implemented it as a normal function it stopped crashing =D final test was worth it thanks for all the help ^^


Owner of kambot TT server

kambot.freeforums.org

[Updated on: Mon, 16 May 2011 13:45]

Report message to a moderator

Previous Topic: Veh Bots.
Next Topic: Rp2's Zombie Assault
Goto Forum:
  


Current Time: Thu Nov 28 22:32:46 MST 2024

Total time taken to generate the page: 0.01199 seconds