Saving and loading y_iterator/foreach
#1

Hello everyone,

I am a bit stuck on how i should save these things.
I know how to save normal arrays but how does it work with these?
Can someone give me an example on saving these in dini or y_ini?

I did try saving them such as but got already stuck there:
dini_IntSet(file, "?", SeedInformation[i][SeedName]);


There are 3 different kind weed species.
How to make it save the correct specie etc?
Код:
new SeedInformation[][seedpacks] =
{
    {0, "White Widow", 50, 4, 600},
    {1, "Purple Haze", 100, 3, 600},
    {2, "Choco Kush", 150, 4, 600}
};
Thanks in advance
Код:
new Iterator:Weeds<MAX_WEEDS>;
new Iterator:Loots<MAX_LOOTS>;

enum weedinfo {
	wProgress,
	wObjectID,
	Float:wLocation[3],
	Float:oPosition[3],
	Text3D:wLabel,
	Timer,
	Timer:x,
	wSeed
}
new WeedInfo[MAX_WEEDS][weedinfo];

enum pweedinfo {
	pSelection,
	Seeds[5],
	Weed[5]
}
new PlayerWeedInfo[MAX_PLAYERS][pweedinfo];

enum lootinfo {
	Text3D:lLabel,
 	Float:lLocation[3],
	wType,
	wGrams,
	lObjectID
}
new LootInfo[MAX_LOOTS][lootinfo];

enum seedpacks {
	id,
	SeedName[36],
	SeedPrice,
	GpS,
	time
}
Reply
#2

You should read this https://sampforum.blast.hk/showthread.php?tid=570957 or be more explicit !
Reply
#3

Thank you for your response, but i know how to save.
The thing i don't know is how to save three different weed species:


format(templates, sizeof templates, "{FFFFFF}[{E1E858}Slot: %i{FFFFFF}] %i grams of %s{FFFFFF}.\n", i, PlayerWeedInfo[playerid][Weed][i], SeedInformation[i][SeedName]);

The following thing does not work:
INI_IntSet(WeedData(playerid),"SeedName",SeedInfor mation[i][SeedName]);
INI_IntSet(WeedData(playerid),"Weed",PlayerWeedInf o[playerid][Weed][i]);

I mean the saving works, but not correctly. How to make it save according the following:
new SeedInformation[][seedpacks] =
{
{0, "White Widow", 50, 4, 600},
{1, "Purple Haze", 100, 3, 600},
{2, "Choco Kush", 150, 4, 600}
};

It has to use their name and ID etc etc..
Reply
#4

I did try something on saving dropped weed packs but i get this error in console when starting server.
YSI Warning: y_malloc set up via "CallLocalFunction", memory corruption is a remote possibility

What am i doing wrong?

saving:
Код:
if(strval(inputtext) > PlayerWeedInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]] || strval(inputtext) <= 0) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You do not have that amount of drugs.");
			new lootID = Iter_Free(Loots), Float:PPosX,Float:PPosY,Float:PPosZ, file[64];
			new slot = DrugsList[playerid][ListChoice[playerid]];
			GetPlayerPos(playerid, PPosX, PPosY, PPosZ);
			
			PlayerWeedInfo[playerid][Weed][slot] -= strval(inputtext);
			
			LootInfo[lootID][LootX] = PPosX;
			LootInfo[lootID][LootY] = PPosY-0.1060;
			LootInfo[lootID][LootZ] = PPosZ-1;
			
			LootInfo[lootID][lObjectID] = CreateDynamicObject(1575, PPosX, PPosY-0.1060, PPosZ-1, 0, 0, 0);
			new title[124];
        	format(title, sizeof title, "{E1E858}[%i grams of %s] Press 'C' to pickup", strval(inputtext), SeedInformation[slot][SeedName]);

			new string[128];
	        format(string, sizeof string, "* {E1E858}You have packed and dropped %i grams of %s; %i left.", strval(inputtext), SeedInformation[slot][SeedName], PlayerWeedInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]]);
			SendClientMessage(playerid, -1, string);
			
			LootInfo[lootID][lLabel] = CreateDynamic3DTextLabel(title, -1, PPosX, PPosY-0.1060, PPosZ-0.8, 5);
			LootInfo[lootID][wGrams] = strval(inputtext);
			LootInfo[lootID][wType] = slot;

			Iter_Add(Loots, lootID);
			
         	foreach(new i : Loots)
			{
				format(file, sizeof(file), "Loot/weed/%d.ini", i);
				INI_Create(file);
				INI_IntSet(file,"LootX",floatround(LootInfo[i][LootX]));
				INI_IntSet(file,"LootY",floatround(LootInfo[i][LootY]));
				INI_IntSet(file,"LootZ",floatround(LootInfo[i][LootY]));
				INI_IntSet(file,"lObjectID",LootInfo[i][lObjectID]);
				INI_IntSet(file,"wGrams", LootInfo[i][wGrams]);
	   			INI_IntSet(file,"wType", LootInfo[i][wType]);
	   		}
loading:
Код:
stock LoadDroppedWeedPacks( )
{
  	new file[25], count = 0;
    for(new i=1; i < MAX_LOOTS; i++)
	{
		format(file, sizeof(file), "Loot/weed/%d.ini", i);
  		if(!fexist(file))return 0;
  		count ++;
		LootInfo[i][LootX]=INI_Int(file,"LootX");
		LootInfo[i][LootY]=INI_Int(file,"LootY");
		LootInfo[i][LootZ]=INI_Int(file,"LootZ");
		LootInfo[i][lObjectID]=INI_Int(file,"lObjectID");
		LootInfo[i][wGrams]=INI_Int(file,"wGrams");
		LootInfo[i][wType]=INI_Int(file,"wType");
		new lootID = Iter_Free(Loots);

		LootInfo[i][lObjectID] = CreateDynamicObject(1575, LootInfo[i][LootX], LootInfo[i][LootY]-0.1060, LootInfo[i][LootZ]-1, 0, 0, 0);
		new title[124], weedname[25];
		if(LootInfo[i][wType]==0){weedname="White Widow";}
 		if(LootInfo[i][wType]==1){weedname="Purple Haze";}
		if(LootInfo[i][wType]==2){weedname="Choco Kush";}
		format(title, sizeof title, "{E1E858}[%i grams of %s] Press 'C' to pickup", LootInfo[i][wGrams], weedname);

		LootInfo[i][lLabel] = CreateDynamic3DTextLabel(title, -1, LootInfo[i][LootX], LootInfo[i][LootY]-0.1060, LootInfo[i][LootZ]-0.8, 5);

		Iter_Add(Loots, lootID);
		LoadDroppedWeedPacks( );
	}
	printf("  Loaded %d dropped weed packs", count);
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)