Problem loops.
#1

xddd
Reply
#2

Can you provide the full code, so we can assist you fully?
Reply
#3

xxxx
Reply
#4

So what are you trying to do? (Load objects from the database, and then create them 'dynamically' in-game)?

If this doesn't 'float your boat' then feel free to use this as an example and create your own using this if you need.

pawn Код:
enum objInfo
{
    ObjectID,
    ObjectSlotUsed,
    ObjectGroup,
    ObjectModel,
    Float: POS[3],
    Float: ROT[3],
    ObjectRef
};
new ObjectInfo[MAX_OBJECTS][objInfo];

forward LoadObjects();
public LoadObjects()
{
    if(mysql_num_rows() != 0)
    {
        new fields, rows, fetch[256], totalf = 0, vname[100];
        cache_get_data(rows, fields, MySQL_Connection);

        new Cur_Time = tickcount();
        for(new i = 0; i < rows; i++)
        {
            new tmpid = i;
            tmpid ++;

            cache_get_field_content(i, "ObjectID", fetch, MySQL_Connection);
            ObjectInfo[tmpid][ObjectID] = strval(fetch);
            cache_get_field_content(i, "ObjectSlotUsed", fetch, MySQL_Connection);
            ObjectInfo[tmpid][ObjectSlotUsed] = strval(fetch);
            cache_get_field_content(i, "ObjectGroup", fetch, MySQL_Connection);
            ObjectInfo[tmpid][ObjectGroup] = strval(fetch);
            cache_get_field_content(i, "ObjectModel", fetch, MySQL_Connection);
            ObjectInfo[tmpid][ObjectModel] = strval(fetch);

            cache_get_field_content(i, "Object_Pos_X", fetch, MySQL_Connection);
            ObjectInfo[tmpid][POS][0] = floatstr(fetch);
            cache_get_field_content(i, "Object_Pos_Y", fetch, MySQL_Connection);
            ObjectInfo[tmpid][POS][1] = floatstr(fetch);
            cache_get_field_content(i, "Object_Pos_Z", fetch, MySQL_Connection);
            ObjectInfo[tmpid][POS][2] = floatstr(fetch);      
            cache_get_field_content(i, "Object_Rot_X", fetch, MySQL_Connection);
            ObjectInfo[tmpid][ROT][0] = floatstr(fetch);
            cache_get_field_content(i, "Object_Rot_Y", fetch, MySQL_Connection);
            ObjectInfo[tmpid][ROT][1] = floatstr(fetch);
            cache_get_field_content(i, "Object_Rot_Z", fetch, MySQL_Connection);
            ObjectInfo[tmpid][ROT][2] = floatstr(fetch);

            if(ObjectInfo[tmpid][ObjectSlotUsed])
            {
                ObjectInfo[tmpid][ObjectRef] = CreateDynamicObject(ObjectInfo[tmpid][ObjectModel], ObjectInfo[tmpid][POS][0], ObjectInfo[tmpid][POS][1],ObjectInfo[tmpid][POS][2], ObjectInfo[tmpid][ROT][0], ObjectInfo[tmpid][ROT][1],ObjectInfo[tmpid][ROT][2]);
               
                if(MYSQL_DEBUG_STATUS)
                {
                    printf("Object Loaded (DB ID: %d", ObjectInfo[tmpid][ObjectID]);
                }
            }
        }
    }      
}

// Example code to re-load (something i did for my script a while back).

COMMAND:reloadmapbygroup(playerid, params[], groupid)
{
    if(IsPlayerConnected(playerid))
    {
        if(AccountInfo[playerid][AccountStaffLevel] > 0)
        {
            if(sscanf(params, "d", groupid)) return CreateUsageMessage(playerid, "/reloadmap [groupid]");

            for(new mid = 0; mid < MAX_OBJECTS; mid ++)
            {
                if(ObjectInfo[mid][ObjectSlotUsed])
                {
                    if(ObjectInfo[mid][ObjectGroup] == groupid)
                    {
                        DestroyDynamicObject(ObjectInfo[mid][ObjectRef]);
                        ObjectInfo[mid][ObjectRef] = CreateDynamicObject(ObjectInfo[mid][ObjectModel], ObjectInfo[mid][POS][0], ObjectInfo[mid][POS][1],ObjectInfo[mid][POS][2], ObjectInfo[mid][ROT][0], ObjectInfo[mid][ROT][1],ObjectInfo[mid][ROT][2]);
                    }
                }
            }
            CreateInfoMessage(playerid, "Dynamic Mapping has successfully been reloaded.");
        }
    }
    return true;
}

COMMAND:reloadallmaps(playerid, params[], confirm[])
{
    if(IsPlayerConnected(playerid))
    {
        if(AccountInfo[playerid][AccountStaffLevel] > 0)
        {
            if(sscanf(params, "s", confirm)) return CreateUsageMessage(playerid, "/reloadmap confirm");
            if(!strcmp(confirm, "confirm", true))
            {
                for(new mid = 0; mid < MAX_OBJECTS; mid ++)
                {
                    if(ObjectInfo[mid][ObjectSlotUsed])
                    {
                        DestroyDynamicObject(ObjectInfo[mid][ObjectRef]);
                        ObjectInfo[mid][ObjectRef] = CreateDynamicObject(ObjectInfo[mid][ObjectModel], ObjectInfo[mid][POS][0], ObjectInfo[mid][POS][1],ObjectInfo[mid][POS][2], ObjectInfo[mid][ROT][0], ObjectInfo[mid][ROT][1],ObjectInfo[mid][ROT][2]);
                    }
                }
                CreateInfoMessage(playerid, "All Dynamic Mapping has successfully been reloaded.");          
            }
        }
    }
    return true;
}
Reply
#5

blabla
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)