Problem deleting text labels
#1

Ok so i wanna make that there is a 3dtext label on a OWNED car... i got this:
pawn Код:
new Text3D:vehicle3DText[MAX_VEHICLES];
// This function adds a vehicle to the house (if possible)
House_AddVehicle(HouseID, cModel, cPaint, cComponents[], Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2)
{
    // Setup local variables
    new vid, CarSlot;

    // Get a free carslot from the house
    CarSlot = House_GetFreeCarSlot(HouseID);

    // Check if there is a free carslot
    if (CarSlot != -1)
    {
        // Create a new vehicle and get the vehicle-id
        vid = CreateVehicle(cModel, cx, cy, cz, crot, Col1, Col2, 600);
        // Store the vehicle-id in the house's free carslot
        AHouseData[HouseID][VehicleIDs][CarSlot] = vid;

        // Save the model of the vehicle
        AVehicleData[vid][Model] = cModel;
        // Save the paintjob of the vehicle and apply it
        AVehicleData[vid][PaintJob] = cPaint;
        if (cPaint != 0)
            ChangeVehiclePaintjob(vid, cPaint - 1);

        // Also update the car-color
        ChangeVehicleColor(vid, Col1, Col2);
        // Save the colors of the vehicle
        AVehicleData[vid][Color1] = Col1;
        AVehicleData[vid][Color2] = Col2;

        // Save the components of the vehicle and apply them
        for (new i; i < 14; i++)
        {
            AVehicleData[vid][Components][i] = cComponents[i];
            // Check if the componentslot has a valid component-id
            if (AVehicleData[vid][Components][i] != 0)
                AddVehicleComponent(vid, AVehicleData[vid][Components][i]); // Add the component to the vehicle
        }

        // Save the spawn-data of the vehicle
        AVehicleData[vid][SpawnX] = cx;
        AVehicleData[vid][SpawnY] = cy;
        AVehicleData[vid][SpawnZ] = cz;
        AVehicleData[vid][SpawnRot] = crot;
        // Also set the fuel to maximum
        AVehicleData[vid][Fuel] = MaxFuel;
        // Also set the owner
        AVehicleData[vid][Owned] = true;
        format(AVehicleData[vid][Owner], 24, AHouseData[HouseID][Owner]);
        // Save the HouseID for the vehicle
        AVehicleData[vid][BelongsToHouse] = HouseID;
        new string[128];
        format(string, sizeof(string), "Vehicle owned by: \n%s", AVehicleData[vid][Owner]);
        vehicle3DText[cModel] = Create3DTextLabel(string, 0xFFFFFF, 0, 0, 0, 80, 0);
        Attach3DTextLabelToVehicle(vehicle3DText[cModel], vid, 0.0, 0.0, 0.0);
       
    }
    else // No free carslot was found, return 0
        return 0;

    // Exit the function and return the vehicle-id
    return vid;
}
This all works...
But now the deleting part when a player leaves... This doesnt work and the next player wichjoins and gets same car ID gets the same 3dtext label on it + its own. This is the code
pawn Код:
// This function is used only when a player logs out (the vehicles are unloaded)
House_RemoveVehicles(HouseID)
{
    // Setup local variables
    new vid, cModel;
    cModel = AVehicleData[vid][Model];
    // Loop through all carslots of this house
    for (new CarSlot; CarSlot < 10; CarSlot++)
    {
        // Get the vehicle-id
        vid = AHouseData[HouseID][VehicleIDs][CarSlot];

        // Check if there was a vehicle in this carslot
        if (vid != 0)
        {
            // Delete the vehicle and clear the data
            DestroyVehicle(vid);
            AHouseData[HouseID][VehicleIDs][CarSlot] = 0;
            AVehicleData[vid][Owned] = false;
            AVehicleData[vid][Owner] = 0;
            AVehicleData[vid][Model] = 0;
            AVehicleData[vid][PaintJob] = 0;
            for (new i; i < 14; i++)
                AVehicleData[vid][Components][i] = 0;
            AVehicleData[vid][SpawnX] = 0.0;
            AVehicleData[vid][SpawnY] = 0.0;
            AVehicleData[vid][SpawnZ] = 0.0;
            AVehicleData[vid][SpawnRot] = 0.0;
            AVehicleData[vid][BelongsToHouse] = 0;
            Delete3DTextLabel(Text3D:vehicle3DText[cModel]);
        }
    }
}
This gets called at disconnect...
pawn Код:
for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
    {
        // Get the HouseID from this slot
        HouseID = APlayerData[playerid][Houses][HouseSlot];
        // Check if there is a house in this slot
        if (HouseID != 0)
        {
            // Unload the cars of the house
            House_RemoveVehicles(HouseID);
            // Set the house so it cannot be entered by anyone (close the house)
            AHouseData[HouseID][HouseOpened] = false;
        }
    }
Why this wont delete that text label? I tried like 100 times now :S

Thanks in advance
Reply


Messages In This Thread
Problem deleting text labels - by thimo - 27.12.2011, 09:27
Re: Problem deleting text labels - by Ash. - 27.12.2011, 09:39
Re: Problem deleting text labels - by thimo - 27.12.2011, 09:42
Re: Problem deleting text labels - by -Prodigy- - 27.12.2011, 09:42
Re: Problem deleting text labels - by thimo - 27.12.2011, 09:46
Re: Problem deleting text labels - by Ash. - 27.12.2011, 09:54
Re: Problem deleting text labels - by thimo - 27.12.2011, 10:40
Re: Problem deleting text labels - by Ash. - 27.12.2011, 10:45
Re: Problem deleting text labels - by thimo - 27.12.2011, 11:13
Re: Problem deleting text labels - by Ash. - 27.12.2011, 12:03

Forum Jump:


Users browsing this thread: 1 Guest(s)