AlliedModders

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

DarthMan 03-03-2017 02:58

Get value from ini file
 
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!

klippy 03-03-2017 03:18

Re: Get value from ini file
 
Depends on your current code.

DarthMan 03-03-2017 03:29

Re: Get value from ini file
 
Quote:

Originally Posted by KliPPy (Post 2500311)
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 :)

EFFx 03-03-2017 10:49

Re: Get value from ini file
 
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)



DarthMan 03-03-2017 11:15

Re: Get value from ini file
 
Quote:

Originally Posted by EFFx (Post 2500414)
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 ?

OciXCrom 03-03-2017 12:45

Re: Get value from ini file
 
g_skins is the skin...

DarthMan 03-03-2017 12:46

Re: Get value from ini file
 
Quote:

Originally Posted by OciXCrom (Post 2500454)
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.

Bugsy 03-03-2017 18:39

Re: Get value from ini file
 
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


DarthMan 03-04-2017 09:26

Re: Get value from ini file
 
Quote:

Originally Posted by Bugsy (Post 2500547)
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.

Bugsy 03-04-2017 11:27

Re: Get value from ini file
 
Is there a grouping, or just a list of item=value?

Disregard if you've figured it out


All times are GMT -4. The time now is 21:00.

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