SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 16/07/2020, 06:08 PM   #11
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: 🇩🇪
Posts: 1,800
Reputation: 635
Default Re: Saving&Loading 100 Variables

You are not using the INI_Int and INI_WriteInt functions correctly.

The string you are formatting is the name of the entry in the INI file. However, you include both the index and value in it and pass the index to the value argument.

INI_Int expects these arguments:

- Name (string)
- value (int)

The name in this case should be the index of the array, so you must format it similar to this:

Code:
new zone[16];
format(zone, sizeof(zone), "Zone%d", id);
The second argument is the variable you want to store the value in. In this case it's one index of the DAZoneCheck array:

Code:
INI_Int(Zone, DAZoneCheck[id]);
This will load the entry named "Zone3" into the Array (DAZoneCheck[3]).


The same goes for INI_WriteInt. It expects a string for the name (ID of the zone) and the value you want to assign to it.

See algorhitmically's reply for an example (INI_Bool was used, however the arguments are exactly the same).
NaS is offline   Reply With Quote
Old 17/07/2020, 09:09 AM   #12
LowIQ
Little Clucker
 
Join Date: May 2019
Posts: 41
Reputation: 5
Default Re: Saving&Loading 100 Variables

Ok, so i tried to fix it and saving works well now.

But i still have problem with loading

1. I use cmd to load zones

Code:
CMD:loadzones(playerid, params[])
{
        for(new i = 0; i < sizeof(DAZoneCheck); i++)
	{
        new zone[16];
	format(zone, sizeof(zone), "Zone%d", i);
	LoadZones(i,zone,DAZoneCheck[i]); //THIS IS BAD, IDK HOW TO MAKE IT SO IT MATCH 
                                                                                           LoadZones(id,name[], value[]);
	}
	return 1;
}
2. public LoadZones

Code:
forward LoadZones(id, name[], value[]);
public LoadZones(id, name[], value[])
{
	new zone[8];
	format(zone, sizeof(zone), "Zone%d", id);
	INI_Int(zone, DAZoneCheck[id]);
	printf("Zone %d loaded on: %d", id, DAZoneCheck[id]);
	return 1;
}
I think i have a problem in the command but iam not sure how to fix that..
LowIQ is offline   Reply With Quote
Old 18/07/2020, 03:34 PM   #13
LowIQ
Little Clucker
 
Join Date: May 2019
Posts: 41
Reputation: 5
Default Re: Saving&Loading 100 Variables

I dont know how can i fix this :/
LowIQ is offline   Reply With Quote
Old 24/07/2020, 01:54 AM   #14
LowIQ
Little Clucker
 
Join Date: May 2019
Posts: 41
Reputation: 5
Default Re: Saving&Loading 100 Variables

BUMP
LowIQ is offline   Reply With Quote
Old 03/08/2020, 03:22 PM   #15
LowIQ
Little Clucker
 
Join Date: May 2019
Posts: 41
Reputation: 5
Default Re: Saving&Loading 100 Variables

Quote:
Originally Posted by NaS View Post
You are not using the INI_Int and INI_WriteInt functions correctly.

The string you are formatting is the name of the entry in the INI file. However, you include both the index and value in it and pass the index to the value argument.

INI_Int expects these arguments:

- Name (string)
- value (int)

The name in this case should be the index of the array, so you must format it similar to this:

Code:
new zone[16];
format(zone, sizeof(zone), "Zone%d", id);
The second argument is the variable you want to store the value in. In this case it's one index of the DAZoneCheck array:

Code:
INI_Int(Zone, DAZoneCheck[id]);
This will load the entry named "Zone3" into the Array (DAZoneCheck[3]).


The same goes for INI_WriteInt. It expects a string for the name (ID of the zone) and the value you want to assign to it.

See algorhitmically's reply for an example (INI_Bool was used, however the arguments are exactly the same).
I tried many things but the variables saves good, but i cant load it at all...
NaS can you help please ..
LowIQ is offline   Reply With Quote
Old 03/08/2020, 05:49 PM   #16
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,843
Reputation: 1693
Default Re: Saving&Loading 100 Variables

See this topic for some info on Y_INI (including how to load things); https://forum.sa-mp.com/showthread.php?t=570957
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Old 11/08/2020, 04:27 AM   #17
LowIQ
Little Clucker
 
Join Date: May 2019
Posts: 41
Reputation: 5
Default Re: Saving&Loading 100 Variables

Quote:
Originally Posted by Kwarde View Post
See this topic for some info on Y_INI (including how to load things); https://forum.sa-mp.com/showthread.php?t=570957
I saw this thread like 1000x and tried to do it with this tutorial but it still does not work properly.
Iam sure iam close, see my post above i just need help becasue iam stuck and no thread helps me...


I just need to load this:

Code:
CMD:savezones(playerid, params[])
{
        for(new i = 0; i < sizeof(DAZoneCheck); i++)
	SaveZones(i);
	return 1;

}

stock SaveZones(id)
{
	new INI:File = INI_Open("Zones.ini");
	INI_SetTag(File, "Zones");

	new Zone[8];
	format(Zone, sizeof Zone, "Zone%d", id);
	INI_WriteInt(File, Zone, DAZoneCheck[id]);
	INI_Close(File);
	return 1;
}
LowIQ 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving variables is saving under wrong car id's GunZ75 Scripting Help 0 07/08/2017 06:19 PM
Saving/Loading Variables hossam22 Scripting Help 0 10/07/2014 06:57 PM
Saving/Loading Variables hossam22 Server Support 1 10/07/2014 10:25 AM
Not loading all variables BlackRaven Scripting Help 3 13/02/2013 02:10 PM
Loading variables Antonio [G-RP] Help Archive 9 13/08/2011 09:00 AM


All times are GMT. The time now is 08:00 AM.


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