SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 12/06/2019, 07:21 PM   #1
TheLeech
Big Clucker
 
Join Date: Aug 2015
Location: Under your bed
Posts: 149
Reputation: 5
Default Only changing database object 1's material

Fixed



So, When I go into game after saving the object materials / server restarts, it only sets the first object in the database material's to the one thats saved.

As you can see in the first screen shot I set the material of the bed to be red, but on restart it changes to white, this happens for all other objects but the first.



Code:
forward LoadBizzFurn(id);
public LoadBizzFurn(id)
{
	static
	    rows,
	    fields,
	    found,
	    found2,
		string[128];

	cache_get_data(rows, fields, g_iHandle);
	found = -1;
	found2 = -1;
	for (new i = 0; i < rows; i ++) if (i < MAX_HOUSE_OBJ)
	{
	    BusinessInfo[id][boDBID][i] = cache_get_field_int(i, "ID");
		BusinessInfo[id][boID][i] = cache_get_field_int(i, "Model");
		BusinessInfo[id][boX][i] = cache_get_field_float(i, "PosX");
		BusinessInfo[id][boY][i] = cache_get_field_float(i, "PosY");
		BusinessInfo[id][boZ][i] = cache_get_field_float(i, "PosZ");
		BusinessInfo[id][borX][i] = cache_get_field_float(i, "AngX");
		BusinessInfo[id][borY][i] = cache_get_field_float(i, "AngY");
		BusinessInfo[id][borZ][i] = cache_get_field_float(i, "AngZ");
		BusinessInfo[id][boInt][i] = cache_get_field_int(i, "Interior");
		BusinessInfo[id][bLocked][i] = cache_get_field_int(i, "Locked");
        BusinessInfo[id][bObject][i] = CreateDynamicObject(BusinessInfo[id][boID][i], BusinessInfo[id][boX][i], BusinessInfo[id][boY][i], BusinessInfo[id][boZ][i], BusinessInfo[id][borX][i], BusinessInfo[id][borY][i], BusinessInfo[id][borZ][i], BusinessInfo[id][VW], BusinessInfo[id][boInt][i], -1, 100);
        found++;
        new toget[7];
		for(new v=0; v < 13; v++) {
			format(toget,7,"Layer%d",v);
			new res = cache_get_field_content_int(i, toget);
			BizMInfo[id][i][v] = res;
			if(res != 0) {
				ChangeDynamicObjectMaterial(BusinessInfo[i][bObject][i], v, res);
				found2++;
			}
		}
	}
	if(found >= 0)
	{
		format(string, sizeof(string), "%s furniture loaded successfully (Objects: %d)", BusinessInfo[id][Name], found+1);
		print(string);
	}
	if(found2 >= 0)
	{
		format(string, sizeof(string), "%s furniture materials loaded successfully (Materials Changed: %d)", BusinessInfo[id][Name], found2+1);
		print(string);
	}
}

forward ChangeDynamicObjectMaterial(obj, idx, mat);
public ChangeDynamicObjectMaterial(obj, idx, mat)
{
	SetDynamicObjectMaterial(obj, idx, ObjectTextures[mat][TModel], ObjectTextures[mat][TXDName], ObjectTextures[mat][TextureName], 0);
}
fixed.
__________________
The sa-mp server 2Real Roleplay is being re-made from the ground up, Join in on development progress and request features on the discord channel. https://discord.gg/cgtttkD

Last edited by TheLeech; 12/06/2019 at 08:00 PM.
TheLeech 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
Object Material Help TheLeech Scripting Help 1 10/06/2019 06:09 PM
Why is the object material not changing help please? CobraWoW Scripting Help 1 23/02/2019 09:16 PM
need material object id Ronen12 Scripting Help 4 10/10/2017 07:11 PM
Set Object Material Ph0eniX Scripting Help 2 14/10/2014 01:00 PM
Material bug (object's material was never set!) MP2 Scripting Help 0 23/01/2013 01:35 PM


All times are GMT. The time now is 06:32 AM.


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