Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Loading .ini files

 
  • 0 Vote(s) - 0 Average
Pawn Loading .ini files
[bC].Thef
Offline

Burgershot Member
Posts: 2
Threads: 1
Joined: Jan 2021
Reputation: 0
Location: Austria
#1
2021-01-04, 02:15 PM (This post was last modified: 2021-01-04, 02:52 PM by [bC].Thef.)
Hello there!
I am working on House System and i am using ini to store data.
The problem is, that the data does not load.



Code:
#define PATH3 "/Houses/%s.ini"
#define MAX_HOUSES 308

public OnGameModeInit()
{
     for(new i = 0; i < MAX_HOUSES; i++)
     {
            INI_ParseFile(House(i), "LoadHouses_%s", .bExtra = true, .extra = i);
     }
    return 1;
}

forward LoadHouses_data(houseid, name[], value[]);
public LoadHouses_data(houseid, name[], value[])
{
    if(fexist(House(houseid)))
    {    
       INI_String("HouseOwner",HI[houseid][hHouseOwner],24);
       INI_Int("HouseOwned",HI[houseid][hHouseOwned]);
       printf("House: %i / HouseOwned = %i",houseid,HI[houseid][hHouseOwned]);
}

stock House(Houseid)
{
new string[128],HouseName[24];
format(HouseName,sizeof(HouseName), "House_ID_%i",Houseid);
format(string,sizeof(string),PATH3,HouseName);
return string;
}

Each of 307 houses is printed, so it looks like file name is loading correctly, but not HI[houseid][hHouseOwned].
Because in the file, HI[houseid][hHouseOwned] = 666, but it prints 0 wich is not correct.

Code:
House: 0 / HouseOwned = 0
House: 1 / HouseOwned = 0

What am i doing bad?
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#2
2021-01-05, 09:08 AM (This post was last modified: 2021-01-05, 09:12 AM by Pinch.)
This might sound silly but leave only INI_Function(s) inside of the callback, do the fexist outside of it (inside the first loop).

I think I had similar issues where only INI_F were executed in a _data callbacks

EDIT: And are you sure that your houses have [data] as a header of each INI file?
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
[bC].Thef
Offline

Burgershot Member
Posts: 2
Threads: 1
Joined: Jan 2021
Reputation: 0
Location: Austria
#3
2021-01-12, 02:20 AM
(2021-01-05, 09:08 AM)Pinch Wrote: This might sound silly but leave only INI_Function(s) inside of the callback, do the fexist outside of it (inside the first loop).

I think I had similar issues where only INI_F were executed in a _data callbacks

EDIT: And are you sure that your houses have [data] as a header of each INI file?

Hello, thanks for you answer. The problem was really that i have to use other functions outside of the callback.
And yes, having [data] in every ini. Working fine now :)
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#4
2021-01-12, 02:50 AM
No problem, I've reported the bug, should've done it before, sorry :')
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode