CreateVehicle() Flying in mid-air
#1

Hello,

I'm having a issue with my vehicle-saving code.. For some reason when the script spawns the vehicles, they spawn "frozen" in mid-air, like you see on this picture.

They unfreeze once I touch them somehow with my player.
Do anyone have any idea what might cause this? I'm using simply CreateVehicle() to spawn them...

Reply
#2

Could u give the code?
Reply
#3

Oh yes, of course, Sorry.

pawn Код:
public BuildVehicles()
{
    new File:carfile = fopen(CARMOD_FILE_LOC, io_read);
    new linebuffer[256]; // Stores the value of each line.

    // This checks it exists.
    if(carfile)
    {
        // This reads by line, starts off with "{owner, plate, modelid, col1, col2, x, y, z, ang}"
        while(fread(carfile, linebuffer))
        {
            // Check for INI stuff
            if(strfind(linebuffer, ";", true, 0) != -1 || strlen(linebuffer) != 0)
            {
                new tmp[10][MAX_PLAYER_NAME];
                new vehOwner[MAX_PLAYER_NAME], vehPlate;
                new vehModel, vehCol1, vehCol2;
                new Float:vehX, Float:vehY, Float:vehZ, Float:vehAng;

                new len = strlen(linebuffer);

                strdel(linebuffer, 0, 1); // "owner, plate, modelid, carcol1, col2, x, y, z, ang}"
                strdel(linebuffer, (len-1), len); // "owner, plate, modelid, col1, col2, x, y, z, ang"

                split(linebuffer, tmp, ':');

                vehOwner = tmp[0];
                vehPlate = strval(tmp[1]);

                vehModel = strval(tmp[2]);
                vehCol1 = strval(tmp[3]);
                vehCol2 = strval(tmp[4]);

                vehX = floatstr(tmp[5]);
                vehY = floatstr(tmp[6]);
                vehZ = floatstr(tmp[7]);
                vehAng = floatstr(tmp[8]);

                new veh = CreateVehicle(vehModel, vehX, vehY, vehZ, vehAng, vehCol1, vehCol2, -1);
                printf("[ Built Vehicle ] VehID[%i] Owner[%s] VehPlate[%d]", veh, vehOwner, vehPlate);
                LicensePlate[veh] = vehPlate;
                localVehicle[veh] = true;
               
                StoredVehX[veh] = vehX;
                StoredVehY[veh] = vehY;
                StoredVehZ[veh] = vehX;
                StoredVehAng[veh] = vehAng;
               
                StoredVehCol1[veh] = vehCol1;
                StoredVehCol2[veh] = vehCol2;
                if(strlen(vehOwner)) // False returns "0", so this is basically if vehOwner has any value.
                {
                    ToggleVehicleLocked(veh, true);
                    IsVehicleOwned[veh] = true;
                    copy(vehOwnerName[veh], vehOwner, MAX_PLAYER_NAME);
                }
            }
        }
        fclose(carfile);
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)