Explode mysql string
#1

Hello, I'm currently revamping the furniture system on my gamemode. So, first of all, I would like that the players will be able to texture these furnitures. I understood that there are a maximum of 5 indexes (for some objects) available.

Now, I would like that every index to be textured like modelid|txdname|texturename|matcolor (e.g. 18202|w_towncs_t|hatwall256hi|0) but I can't seem to understand how to explode these "|".

Current furniture loading system:
Код:
stock LoadHouseFurnitures(houseid)
{
	format(query, sizeof(query), "SELECT * FROM `furnitures` WHERE `houseid` = %d", HouseInfo[houseid][hID]);
	mysql_function_query(MO_ROLEPLAY_DB_HANDLE, query, true, "OnFurnituresLoad", "i", houseid);
	return 1;
}

....after hundreds of lines

public OnFurnituresLoad(houseid)
{
    new rows, fields;
	new total = 0;
    cache_get_data(rows, fields);
    if(rows)
    {
		while(total < rows)
		{
			FurnitureInfo[houseid][total][fID] = cache_get_row_int(total, 0);
			FurnitureInfo[houseid][total][fModel] = cache_get_row_int(total, 1);
			cache_get_row(total, 2, FurnitureInfo[houseid][total][fName], MODERN_ROLEPLAY_DB_HANDLE, 128);
			FurnitureInfo[houseid][total][fHouseID] = houseid;
			FurnitureInfo[houseid][total][fInterior] = cache_get_row_int(total, 4);
			FurnitureInfo[houseid][total][fVirtualWorld] = cache_get_row_int(total, 5);
			FurnitureInfo[houseid][total][fMarketPrice] = cache_get_row_int(total, 6);
			FurnitureInfo[houseid][total][fPosX] = cache_get_row_float(total, 7);
			FurnitureInfo[houseid][total][fPosY] = cache_get_row_float(total, 8);
			FurnitureInfo[houseid][total][fPosZ] = cache_get_row_float(total, 9);
			FurnitureInfo[houseid][total][fPosRX] = cache_get_row_float(total, 10);
			FurnitureInfo[houseid][total][fPosRY] = cache_get_row_float(total, 11);
			FurnitureInfo[houseid][total][fPosRZ] = cache_get_row_float(total, 12);
			FurnitureInfo[houseid][total][fOn] = 1;
			FurnitureInfo[houseid][total][fObject] = CreateDynamicObject(FurnitureInfo[houseid][total][fModel], FurnitureInfo[houseid][total][fPosX], FurnitureInfo[houseid][total][fPosY], FurnitureInfo[houseid][total][fPosZ], FurnitureInfo[houseid][total][fPosRX], FurnitureInfo[houseid][total][fPosRY], FurnitureInfo[houseid][total][fPosRZ], FurnitureInfo[houseid][total][fVirtualWorld], FurnitureInfo[houseid][total][fInterior], -1, 200.0);
			if(isHouseDoor(FurnitureInfo[houseid][total][fModel]))
			{
				FurnitureInfo[houseid][total][fLocked] = 1;
				FurnitureInfo[houseid][total][fOpened] = 0;
			}
			total++;
		}
    }
    return 1;
}
Reply


Messages In This Thread
Explode mysql string - by AidanRO - 16.04.2016, 22:49
Re: Explode mysql string - by AidanRO - 18.04.2016, 19:25
Re: Explode mysql string - by Gammix - 18.04.2016, 19:36
Re: Explode mysql string - by AidanRO - 20.04.2016, 05:49

Forum Jump:


Users browsing this thread: 1 Guest(s)