Home » Renegade Discussions » Mod Forum » .ini
.ini [message #447011] |
Wed, 11 May 2011 07:21 |
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 #447020 is a reply to message #447011] |
Wed, 11 May 2011 09:33 |
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
void mes::Load(GameObject *obj){
std::string me;
const char*name = Get_Player_Name(obj);
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);
}
};
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 #447034 is a reply to message #447011] |
Wed, 11 May 2011 13:50 |
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 #447036 is a reply to message #447011] |
Wed, 11 May 2011 13:54 |
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 |
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 |
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 |
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
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 |
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 #447144 is a reply to message #447011] |
Thu, 12 May 2011 11:31 |
robbyke
Messages: 348 Registered: September 2010 Location: Belgium
Karma: 0
|
Recruit |
|
|
ok ive done this
gmmain.cpp:
Toggle Spoiler
/* Renegade Scripts.dll
SSGM main functions and classes
Copyright 2007 Vloktboky, Whitedragon(MDB), Mac, Jonathan Wilson
This file is part of the Renegade scripts.dll
The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version. See the file COPYING for more details.
In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
Only the source code to the module(s) containing the licenced code has to be released.
*/
#include "scripts.h"
#include "engine.h"
#include "gmmain.h"
//Yep, a file just for this.
SettingsStruct *Settings = 0;
DataStruct *Data = 0;
mes *KB_ME = 0;
void mes::Load(GameObject *obj){
std::string me;
const char*name = Get_Player_Name(obj);
SettingsLoader::Load();
new mes("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);
}
};
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
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 |
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 |
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 #447174 is a reply to message #447172] |
Sat, 14 May 2011 05:58 |
|
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 |
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 |
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 |
|
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 |
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
void KB_Purchase_Me(GameObject *obj)
{
const char*name = Get_Player_Name(obj);
int pID = Get_Player_ID(obj);
Console_Input(StrFormat("CMSGP %d 255,0,0 test0",pID).c_str());
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;
INIClass* ini = Get_INI("mes.txt");
if (ini)
{
Console_Input(StrFormat("CMSGP %d 255,0,0 test1",pID).c_str());
price =ini->Get_Float(name,"01",0);
ini->Get_String(name,"02","",preset,500);
hp =ini->Get_Float(name,"03",0);
ap =ini->Get_Float(name,"04",0);
ini->Get_String(name,"05","",skin,500);
ini->Get_String(name,"06","",shield,500);
ini->Get_String(name,"07","",powerups,500);
ini->Get_String(name,"08","",scripts,500);
ini->Get_String(name,"09","",scriptparam,500);
}
if (price==0)
{
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);
}
}
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
|
|
|
Goto Forum:
Current Time: Thu Nov 28 22:49:56 MST 2024
Total time taken to generate the page: 0.02115 seconds
|