Raised This Month: $ Target: $400
 0% 

Get value from ini file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-03-2017 , 02:58   Get value from ini file
Reply With Quote #1

Hello. So I made an ini file where all the models are stored, it looks like that "model" "skin" .
For each model, a skin value is assigned. 0 means it has no skins, 1 means it has skins. What's the easiest way to check if the current g_skins , depending on the menu item that was selected, has the value 0 or 1? If the value is 0, I will make it change the player model and assign the skin 0, if it is 1, it will open up a new menu where u can select the skin that u want for the model. I will do all of this, I jsut need a way to easely get the value. Thanks!
DarthMan is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-03-2017 , 03:18   Re: Get value from ini file
Reply With Quote #2

Depends on your current code.
klippy is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-03-2017 , 03:29   Re: Get value from ini file
Reply With Quote #3

Quote:
Originally Posted by KliPPy View Post
Depends on your current code.
I use that code to read the file:

Code:
read_file(conffile_model, item, file_model, 127, leng)
parse(file_model,g_models, 127, g_skins, 127)
It uses pare to separate them, and I want to get the value of g_skins.
I want tor ead the num

Last edited by DarthMan; 03-03-2017 at 03:57.
DarthMan is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 03-03-2017 , 10:49   Re: Get value from ini file
Reply With Quote #4

PHP Code:
new file fopen(conffile_model"r")
while(!
feof(file))
{
    
// Transfer all lines values from file to szBuffer
    
new szBuffer[32]
    
fgets(fileszBuffercharsmax(szBuffer)) 

    
// Separate they
    
parse(szBufferg_modelscharsmax (g_models), g_skinscharsmax(g_skins))

    
// Remove quites
    
trim(g_models)
    
trim(g_skins)

    return 
fclose(file)

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 03-03-2017 at 10:54.
EFFx is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-03-2017 , 11:15   Re: Get value from ini file
Reply With Quote #5

Quote:
Originally Posted by EFFx View Post
PHP Code:
new file fopen(conffile_model"r")
while(!
feof(file))
{
    
// Transfer all lines values from file to szBuffer
    
new szBuffer[32]
    
fgets(fileszBuffercharsmax(szBuffer)) 

    
// Separate they
    
parse(szBufferg_modelscharsmax (g_models), g_skinscharsmax(g_skins))

    
// Remove quites
    
trim(g_models)
    
trim(g_skins)

    return 
fclose(file)

Thanks, but how do I then do it? Will I just use if (g_skins)==0) etc ?
DarthMan is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-03-2017 , 12:45   Re: Get value from ini file
Reply With Quote #6

g_skins is the skin...
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-03-2017 , 12:46   Re: Get value from ini file
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
g_skins is the skin...
g_skins is the value of the skin, 0 or 1 from the ini file. The problem is that doing it this way won't check for the value from the ini, but for the value from the sma file, where he var was set to 0.
DarthMan is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-03-2017 , 18:39   Re: Get value from ini file
Reply With Quote #8

How is the ini formatted?

Like this? If so, take a loot at this
Code:
[GROUP1]
Item1=value1
Item2=value2

[GROUP2]
Item1=value1
Item2=value2
__________________

Last edited by Bugsy; 03-03-2017 at 20:48.
Bugsy is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 03-04-2017 , 09:26   Re: Get value from ini file
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
How is the ini formatted?

Like this? If so, take a loot at this
Code:
[GROUP1]
Item1=value1
Item2=value2

[GROUP2]
Item1=value1
Item2=value2
It's like Item=Value of the item, the value is set in teh ini file. I did it by using str_to_num from the g_skins variable.
DarthMan is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-04-2017 , 11:27   Re: Get value from ini file
Reply With Quote #10

Is there a grouping, or just a list of item=value?

Disregard if you've figured it out
__________________
Bugsy is offline
Reply


Thread Tools
Display Modes

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 21:00.


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