Vehicle loading problem!!!
#1

I have dynamic faction vehicle system and the loading is messy..

(the veh_slot is the slot it should load into)
My database looks like this:
http://puu.sh/4x79W/1fddf4f0b5.png

and ingame it looks like this:
http://puu.sh/4x7dP/45ba472afc.jpg

(so that vehicle is supposed to load into vehicle slot 1 but it loads into 1 instead)

MYSQL Loading code:
pawn Код:
case THREAD_LOAD_FACVEHS:
        {
            if(szRows)
            {
                for(new f = 1; f < MAX_FACTION; f++) {
                    cache_get_field_content(0, "fac_id", szResult); FactionVehicleInfo[f][szRows][fVI_facID] = strval(szResult);
                    cache_get_field_content(0, "model_id", szResult); FactionVehicleInfo[f][szRows][fVI_ModelID] = strval(szResult);
                    cache_get_field_content(0, "colour_1", szResult); FactionVehicleInfo[f][szRows][fVI_Colours][0] = strval(szResult);
                    cache_get_field_content(0, "colour_2", szResult); FactionVehicleInfo[f][szRows][fVI_Colours][1] = strval(szResult);
                    cache_get_field_content(0, "upkeep", szResult); FactionVehicleInfo[f][szRows][fVI_upKeep] = strval(szResult);
                    cache_get_field_content(0, "rank_needed", szResult); FactionVehicleInfo[f][szRows][fVI_vehRank] = strval(szResult);
                    cache_get_field_content(0, "posX", szResult); FactionVehicleInfo[f][szRows][fVI_vPos][0] = floatstr(szResult);
                    cache_get_field_content(0, "posY", szResult); FactionVehicleInfo[f][szRows][fVI_vPos][1] = floatstr(szResult);
                    cache_get_field_content(0, "posZ", szResult); FactionVehicleInfo[f][szRows][fVI_vPos][2] = floatstr(szResult);
                    cache_get_field_content(0, "posA", szResult); FactionVehicleInfo[f][szRows][fVI_vPos][3] = floatstr(szResult);

                    FactionVehicleInfo[f][szRows][fVI_vID] = CreateVehicle(FactionVehicleInfo[f][szRows][fVI_ModelID], FactionVehicleInfo[f][szRows][fVI_vPos][0], FactionVehicleInfo[f][szRows][fVI_vPos][1], FactionVehicleInfo[f][szRows][fVI_vPos][2], FactionVehicleInfo[f][szRows][fVI_vPos][3], FactionVehicleInfo[f][szRows][fVI_Colours][0], FactionVehicleInfo[f][szRows][fVI_Colours][1], -1);

                    break;
                }
                printf("[SERVER]: %d faction vehicles were loaded.", szRows);
                szRows++;
            }
            else print("[SERVER]: 0 faction vehicles were loaded.");
        }
And also, if I have more than one vehicle only one of them will load and spawn etc, I tried printing the ID's that load and whatever and only one of them loads?


ALL HELP APPRECIATED <3
Reply
#2

Anyone?
Reply
#3

Does this work? I'm not familiar with using MQSQL with SAMP but by the look of it, break; is what is discontinuing the code.

pawn Код:
case THREAD_LOAD_FACVEHS:
        {
            if(szRows)
            {
                for(new f = 1; f < MAX_FACTION; f++) {
                    cache_get_field_content(0, "fac_id", szResult); FactionVehicleInfo[f][szRows][fVI_facID] = strval(szResult);
                    cache_get_field_content(0, "model_id", szResult); FactionVehicleInfo[f][szRows][fVI_ModelID] = strval(szResult);
                    cache_get_field_content(0, "colour_1", szResult); FactionVehicleInfo[f][szRows][fVI_Colours][0] = strval(szResult);
                    cache_get_field_content(0, "colour_2", szResult); FactionVehicleInfo[f][szRows][fVI_Colours][1] = strval(szResult);
                    cache_get_field_content(0, "upkeep", szResult); FactionVehicleInfo[f][szRows][fVI_upKeep] = strval(szResult);
                    cache_get_field_content(0, "rank_needed", szResult); FactionVehicleInfo[f][szRows][fVI_vehRank] = strval(szResult);
                    cache_get_field_content(0, "posX", szResult); FactionVehicleInfo[f][szRows][fVI_vPos][0] = floatstr(szResult);
                    cache_get_field_content(0, "posY", szResult); FactionVehicleInfo[f][szRows][fVI_vPos][1] = floatstr(szResult);
                    cache_get_field_content(0, "posZ", szResult); FactionVehicleInfo[f][szRows][fVI_vPos][2] = floatstr(szResult);
                    cache_get_field_content(0, "posA", szResult); FactionVehicleInfo[f][szRows][fVI_vPos][3] = floatstr(szResult);

                    FactionVehicleInfo[f][szRows][fVI_vID] = CreateVehicle(FactionVehicleInfo[f][szRows][fVI_ModelID], FactionVehicleInfo[f][szRows][fVI_vPos][0], FactionVehicleInfo[f][szRows][fVI_vPos][1], FactionVehicleInfo[f][szRows][fVI_vPos][2], FactionVehicleInfo[f][szRows][fVI_vPos][3], FactionVehicleInfo[f][szRows][fVI_Colours][0], FactionVehicleInfo[f][szRows][fVI_Colours][1], -1);

                }
                printf("[SERVER]: %d faction vehicles were loaded.", szRows);
                szRows++;
            }
            else print("[SERVER]: 0 faction vehicles were loaded.");
        }
Reply
#4

The vehicle spawns although it duplicates and spawns loads of times?
Reply
#5

Does only 1 vehicle spawn; but spawn many times? As in, is it the same faction vehicle that constantly spawns?

How about something like this; I'm not really sure. You'll probably need someone with the MQSQL experience to help you with this.

Try this though.
pawn Код:
case THREAD_LOAD_FACVEHS:
        {
            for(new szRows=0;szRows<MAX_FVEHICLES;szRows++)
            {
                for(new f = 1; f < MAX_FACTION; f++)
                {
                    cache_get_field_content(0, "fac_id", szResult); FactionVehicleInfo[f][szRows][fVI_facID] = strval(szResult);
                    cache_get_field_content(0, "model_id", szResult); FactionVehicleInfo[f][szRows][fVI_ModelID] = strval(szResult);
                    cache_get_field_content(0, "colour_1", szResult); FactionVehicleInfo[f][szRows][fVI_Colours][0] = strval(szResult);
                    cache_get_field_content(0, "colour_2", szResult); FactionVehicleInfo[f][szRows][fVI_Colours][1] = strval(szResult);
                    cache_get_field_content(0, "upkeep", szResult); FactionVehicleInfo[f][szRows][fVI_upKeep] = strval(szResult);
                    cache_get_field_content(0, "rank_needed", szResult); FactionVehicleInfo[f][szRows][fVI_vehRank] = strval(szResult);
                    cache_get_field_content(0, "posX", szResult); FactionVehicleInfo[f][szRows][fVI_vPos][0] = floatstr(szResult);
                    cache_get_field_content(0, "posY", szResult); FactionVehicleInfo[f][szRows][fVI_vPos][1] = floatstr(szResult);
                    cache_get_field_content(0, "posZ", szResult); FactionVehicleInfo[f][szRows][fVI_vPos][2] = floatstr(szResult);
                    cache_get_field_content(0, "posA", szResult); FactionVehicleInfo[f][szRows][fVI_vPos][3] = floatstr(szResult);

                    FactionVehicleInfo[f][szRows][fVI_vID] = CreateVehicle(FactionVehicleInfo[f][szRows][fVI_ModelID], FactionVehicleInfo[f][szRows][fVI_vPos][0], FactionVehicleInfo[f][szRows][fVI_vPos][1], FactionVehicleInfo[f][szRows][fVI_vPos][2], FactionVehicleInfo[f][szRows][fVI_vPos][3], FactionVehicleInfo[f][szRows][fVI_Colours][0], FactionVehicleInfo[f][szRows][fVI_Colours][1], -1);

                }
                printf("[SERVER]: %d faction vehicles were loaded.", szRows);
            }
            else print("[SERVER]: 0 faction vehicles were loaded.");
        }
Reply
#6

Yes, although that code made the vehicles spawn even more
Reply
#7

Damn :S

Not really sure what to do.

Hopefully someone with MQSQL experience responds.

Though; you maybe could try looping through the factions first; then loop through the rows and then if the row equals the MAX_FactionVehicles; break?

pawn Код:
if(szRow == MAX_FACTIONVEHICLES) break;
Do you know if there is some sort of 'rowexist' that is similar to INI's fexist?
Reply
#8

Not sure, I kinda fixed it.

pawn Код:
case THREAD_LOAD_FACVEHS:
        {
            new rows, iFac = 0;
            for(new row = 0; row < szRows; ++row)
            {
                    cache_get_field_content(0, "fac_id", szResult); iFac = strval(szResult);
                    FactionVehicleInfo[iFac][szRows][fVI_facID] = strval(szResult);
                   
                    cache_get_field_content(row,"model_id", szResult); FactionVehicleInfo[iFac][szRows][fVI_ModelID] = strval(szResult);
                    cache_get_field_content(row,"colour_1", szResult); FactionVehicleInfo[iFac][szRows][fVI_Colours][0] = strval(szResult);
                    cache_get_field_content(row,"colour_2", szResult); FactionVehicleInfo[iFac][szRows][fVI_Colours][1] = strval(szResult);
                    cache_get_field_content(row,"upkeep", szResult); FactionVehicleInfo[iFac][szRows][fVI_upKeep] = strval(szResult);
                    cache_get_field_content(row,"rank_needed", szResult); FactionVehicleInfo[iFac][szRows][fVI_vehRank] = strval(szResult);
                    cache_get_field_content(row,"posX", szResult); FactionVehicleInfo[iFac][szRows][fVI_vPos][0] = floatstr(szResult);
                    cache_get_field_content(row,"posY", szResult); FactionVehicleInfo[iFac][szRows][fVI_vPos][1] = floatstr(szResult);
                    cache_get_field_content(row,"posZ", szResult); FactionVehicleInfo[iFac][szRows][fVI_vPos][2] = floatstr(szResult);
                    cache_get_field_content(row, "posA", szResult); FactionVehicleInfo[iFac][szRows][fVI_vPos][3] = floatstr(szResult);

                    FactionVehicleInfo[iFac][szRows][fVI_vID] = CreateVehicle(FactionVehicleInfo[iFac][szRows][fVI_ModelID], FactionVehicleInfo[iFac][szRows][fVI_vPos][0], FactionVehicleInfo[iFac][szRows][fVI_vPos][1], FactionVehicleInfo[iFac][szRows][fVI_vPos][2], FactionVehicleInfo[iFac][szRows][fVI_vPos][3], FactionVehicleInfo[iFac][szRows][fVI_Colours][0], FactionVehicleInfo[iFac][szRows][fVI_Colours][1], -1);

                    printf("Vehicle ID %d - Vehicle Slot %d - Faction ID: %d - Model ID: %d", FactionVehicleInfo[iFac][szRows][fVI_vID], szRows, FactionVehicleInfo[iFac][szRows][fVI_facID], FactionVehicleInfo[iFac][szRows][fVI_ModelID]);
               
                    iFac++;
                    szRows++;
            }
        }
It spawns all the vehicles, although all the vehicles go into faction ID 1 when some are supposed to be into 2 or 3.
Reply
#9

Bump!!
Reply
#10

I think the loop you've created starts in number one that's why it is always created in that slot.
Try making the loop starts in number zero and see if it works, I don't quite know anything about MySQL.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)