Загрузка объектов
#1

Здравствуйте! Сегодня сделал систему сохранение объектов, столкнулся с такой проблемой, из бд загружается только один объект! самый первый.
Вот код
PHP Code:
fpub:LoadObjects()
{
    new 
temp[30], rowsfields;
    
cache_get_data(rowsfields);
    if(
rows)
    {
        for(new 
idxidx rowsidx++)
        {
            
O[Model] = cache_get_field_content_int(idx"Model");
            
cache_get_field_content(idx"O[foX]"temp); O[foX] = floatstr(temp);
            
cache_get_field_content(idx"O[foY]"temp); O[foY] = floatstr(temp);
            
cache_get_field_content(idx"O[foZ]"temp); O[foZ] = floatstr(temp);
            
cache_get_field_content(idx"O[roX]"temp); O[roX] = floatstr(temp);
            
cache_get_field_content(idx"O[roY]"temp); O[roY] = floatstr(temp);
            
cache_get_field_content(idx"O[roZ]"temp); O[roZ] = floatstr(temp);
            
CreateObject(O[Model], O[foX], O[foY], O[foZ], O[roX], O[roY], O[roZ], 500000.0);
            return 
1;
        }
    }
    return 
1;

MySQL R9
Reply
#2

return убрать надо первый.
Reply
#3

Не вижу смысла узнавать количество столбцов не используя переменную fields

замени
pawn Code:
new temp[30], rows, fields;
cache_get_data(rows, fields);
на
pawn Code:
new temp[30], rows = cache_get_row_count();
:

Либо вовсе так:
pawn Code:
fpub:LoadObjects()
{
    new idx = cache_get_row_count();
    while(idx--)
    {
        O[Model] = cache_get_field_content_int(idx, "Model");
        O[foX] = cache_get_field_content_float(idx, "O[foX]");
        O[foY] = cache_get_field_content_float(idx, "O[foY]");
        O[foZ] = cache_get_field_content_float(idx, "O[foZ]");
        O[roX] = cache_get_field_content_float(idx, "O[roX]");
        O[roY] = cache_get_field_content_float(idx, "O[roY]");
        O[roZ] = cache_get_field_content_float(idx, "O[roZ]");
        CreateObject(O[Model], O[foX], O[foY], O[foZ], O[roX], O[roY], O[roZ]);
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)