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; }
stock strsplit(dest[][], string[], const sub[], bool:ignorecase = false, pos = 0, limit = -1, len = sizeof (dest[]))
{
if (pos <= -1)
return 0;
if (limit != -1 && limit <= 0)
return 0;
new sublen = strlen(sub);
new count;
while ((pos = strfind(string, sub, ignorecase, pos)) != -1)
{
strmid((dest[count][0] = EOS, dest[count]), string, 0, (pos + sublen), len);
strdel(string, 0, (pos + sublen));
count++;
if (limit > 0 && count >= limit)
{
break;
}
}
strcat((dest[count][0] = EOS, dest[count]), string, len);
return count;
}
new dest[5][128];
for (new i, j = strsplit(dest, your_string, "|"); i < j; i++)
{
// dest[i] <- is your "i"th part of string
}
Using sscanf.
Or a simple function: pawn Код:
pawn Код:
|