Gamemode efficiency
#1

Hello samp forums! My name is Max and i'd like to have some help with making my script faster.
Loading houses/businesses/factions/families/objects/gates was a really pain for me lately.
Heres my method to load & save.

Saving:
Код:
forward SaveHousesFunction();
public SaveHousesFunction()
{
        //Creates a loop, that goes through all of the files.
	for(new idx = 1; idx < sizeof(HouseInfo); idx++) //Loops through the houses.
	{
		if(!HouseInfo[idx][hLevel]) // If the house level is 0 this means it doesn't exist. (house must have level)
		{
			print("Houses saved successfully."); // If look broke we found all existed houses.
			break;//Breaks the loop if the price is 0(Meaning it doesn't exist)
		}
		SaveHouses(idx); // going to another function that saves houses by y_ini into specific house file.
	}
	return 1;
}
And the loading:
Код:
stock LoadHouses()
{
	new string[256];
	//Creates a loop, that goes through all of the files.
	for(new idx = 1; idx < sizeof(HouseInfo); idx++)
	{
		format(string, sizeof(string), hPATH, idx);//formats the file path, with the house ID
		INI_ParseFile(string, "loadhouse_%s", .bExtra = true, .extra = idx );
		HouseInfo[idx][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ], 0);
		if(!strcmp("The State", HouseInfo[idx][hOwner])) format(string, sizeof(string), "{00BC2E}[House]{FFFFFF}\n{00BC2E}Owner{FFFFFF}: %s\n{00BC2E}Type{FFFFFF}: %s\n{00BC2E}Status{FFFFFF}: For Sale\n{00BC2E}Price{FFFFFF}: $%d", HouseInfo[idx][hOwner], HT(idx), HouseInfo[idx][hPrice]);
		else format(string, sizeof(string), "{00BC2E}[House]{FFFFFF}\n{00BC2E}Owner{FFFFFF}: %s\n{00BC2E}Type{FFFFFF}: %s\n{00BC2E}Status{FFFFFF}: %s", HouseInfo[idx][hOwner], HT(idx), RHS(idx));
		HouseInfo[idx][hText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, HouseInfo[idx][hX], HouseInfo[idx][hY], HouseInfo[idx][hZ]+0.3,  20, INVALID_PLAYER_ID, INVALID_VEHICLE_ID);
		if(HouseInfo[idx][hLevel])
		{
			HouseInfo[idx][hOwned] = 1;
		}
	}
	return 1;
}
Is there any more efficent way you guys know to do this? If there is, it will help me with all the systems in the mod. all of them are saved and loaded the same way.

Thanks, Max.
Reply


Messages In This Thread
Gamemode efficiency - by maximthepain - 17.08.2017, 13:37
Re: Gamemode efficiency - by JesterlJoker - 17.08.2017, 14:19
Re: Gamemode efficiency - by maximthepain - 17.08.2017, 15:00
Re: Gamemode efficiency - by Vince - 17.08.2017, 15:34
Re: Gamemode efficiency - by maximthepain - 17.08.2017, 15:58
Re: Gamemode efficiency - by 10MIN - 17.08.2017, 16:35
Re: Gamemode efficiency - by maximthepain - 17.08.2017, 16:43
Re: Gamemode efficiency - by maximthepain - 28.08.2017, 17:11

Forum Jump:


Users browsing this thread: 3 Guest(s)