SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 08/12/2018, 03:28 PM   #1
GameOvr
Big Clucker
 
Join Date: Jun 2018
Posts: 135
Reputation: 0
Default A little help! (Y_INI not saving properly)

Hello I made a Zone capture system it's also saving zone data on gamemode exit. But the problem is it's not saving the correct data on the file at gamemode exit plz someone help me here's the code

pawn Code:
//OnGameModeInit
new fstr[50];
    for(new i = 0; i < sizeof(ZONEINFO); i++)
    {
        ZONEID[i] = GangZoneCreate( ZONEINFO[i][zminx], ZONEINFO[i][zminy], ZONEINFO[i][zmaxx], ZONEINFO[i][zmaxy]);
        DZONEID[i] = CreateDynamicRectangle( ZONEINFO[i][zminx], ZONEINFO[i][zminy], ZONEINFO[i][zmaxx], ZONEINFO[i][zmaxy]);
        format(fstr, sizeof(fstr), ZONEPATH, i + 1);
        if(!fexist(fstr))
        {
            new INI:zfile = INI_Open(fstr);
            INI_SetTag(zfile, "Zone data");
            INI_WriteString(zfile, "Zone_Name", ZONEINFO[i][zname]);
            INI_WriteBool(zfile, "Zone_Owned", false);
            INI_WriteHex(zfile, "Zone_Color", 0xC0C0C066);
            INI_WriteInt(zfile, "Zone_Owned_Team_ID", -1);
            INI_WriteString(zfile, "Zone_Owned_Team", "No_Team");
            INI_Close(zfile);

            INI_ParseFile(fstr, "LoadZoneData", .bExtra = true, .extra = i);
        }
        else
        {
            INI_ParseFile(fstr, "LoadZoneData", .bExtra = true, .extra = i);
        }
    }

//loading data from file (Im not loading zone name because it's not changing [Zone names are in the script])
forward LoadZoneData(i, name[], value[]);
public LoadZoneData(i, name[], value[])
{
    INI_Bool("Zone_Owned", ZONEINFO[i][zowned]);
    INI_Hex("Zone_Color", ZONEINFO[i][zcolor]);
    INI_Int("Zone_Owned_Team_ID", ZONEINFO[i][zteamid]);
    INI_String("Zone_Owned_Team", ZONEINFO[i][zteam], 45);
    return 1;
}

//When someone captured the zone
    ZONEINFO[i][zteamid] = ZoneAttacker[i];
    ZONEINFO[i][zcolor] = GetTeamZoneColor(ZoneAttacker[i]);
    ZONEINFO[i][zteam] = GetTeamName(ZoneAttacker[i]);
    ZONEINFO[i][zowned] = true;

//and when exiting gamemode
new fstr[128];
    for(new i = 0; i < sizeof(ZONEINFO); i++)
    {
        format(fstr, sizeof(fstr), ZONEPATH, i + 1);

        new INI:zfile = INI_Open(fstr);
        INI_SetTag(zfile, "Zone data");
        INI_WriteBool(zfile, "Zone_Owned", ZONEINFO[i][zowned]);
        INI_WriteHex(zfile, "Zone_Color", ZONEINFO[i][zcolor]);
        INI_WriteInt(zfile, "Zone_Owned_Team_ID", ZONEINFO[i][zteamid]);
        INI_WriteString(zfile, "Zone_Owned_Team", ZONEINFO[i][zteam]);
        INI_Close(zfile);
    }

I can't find anything wrong it save all zones like this(in default way)

Code:
[Zone data]
Zone_Name = //Zone name is here
Zone_Owned = false
Zone_Color = 0xC0C0C066
Zone_Owned_Team_ID = -1
Zone_Owned_Team = No_Team
__________________
GameOvr is offline   Reply With Quote
Old 09/12/2018, 08:38 AM   #2
GameOvr
Big Clucker
 
Join Date: Jun 2018
Posts: 135
Reputation: 0
Default Re: A little help! (Y_INI not saving properly)

Bump..
Plz help
__________________
GameOvr is offline   Reply With Quote
Old 09/12/2018, 09:32 AM   #3
Logic_
High-roller
 
Logic_'s Avatar
 
Join Date: Jun 2015
Location: Pakistan
Posts: 1,545
Reputation: 283
Default Re: A little help! (Y_INI not saving properly)

Why do still people use INI - just make use of SQLite here.
__________________
Cheap game-host (SA-MP, SA-MP Hosted tab, G-MOD etc) @ www.prestigesteve.com
Developer @ Nevada State Prison RP/ CookieDM/ COD:IW; Former developer of NSP:RP, COD:BO3, COD:AW, I:RP, PC:RP, NEG, ZL TDM.
  • You can't forcefully correct someone and you shouldn't waste your time on it because you can bring a horse to water but can't force it to drink.
  • Please don't message me asking for help, because by doing that, you're only limiting your support to one person when the whole community can help you here. Refer to scripting help section instead.
Logic_ is offline   Reply With Quote
Old 09/12/2018, 04:20 PM   #4
GameOvr
Big Clucker
 
Join Date: Jun 2018
Posts: 135
Reputation: 0
Default Re: A little help! (Y_INI not saving properly)

Thanks,
And yes if I won't able to figure out what is the error
I will change it to sqlite
__________________
GameOvr is offline   Reply With Quote
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



All times are GMT. The time now is 09:09 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.