Loop through 3DText lables and vehicles
#1

Hello.

I have made 2 vehicles on which I want to show their health in a 3DTextLabel. However, I'm failing constantly.

pawn Код:
new Vehicles[2],
    Text3D:VehiclesLabel[2];

public OnGameModeInit()
{
     for(new i = 0; i < 2; i++) // Also tried for(new i = 0; i < sizeof(Vehicles); i++)
     {
        VehiclesLabel[Vehicles[i]] = CreateDynamic3DTextLabel("100%", -1, 0.0, 0.0, 0.0, 50.0, INVALID_PLAYER_ID, Vehicles[i], 0, -1, -1, -1, 50.0);
     }

     // All code that is above stops working
     return 1;
}
Reply
#2

pawn Код:
new Vehicles[2],
    Text3D:VehiclesLabel[2];

public OnGameModeInit()
{
     for(new i = 0; i < 2; i++) // Also tried for(new i = 0; i < sizeof(Vehicles); i++)
     {
        VehiclesLabel[i] = CreateDynamic3DTextLabel("100%", -1, 0.0, 0.0, 0.0, 50.0, INVALID_PLAYER_ID, Vehicles[i], 0, -1, -1, -1, 50.0);
     }

     // All code that is above stops working
     return 1;
}
Like this if I see correctly.
Reply
#3

You will need to know how vehicle IDs are created in the server internally and assess how you want to approach this problem.

If you are going to create the textdraw labels for 2 vehicles only, you will probably be better off not using a loop as this would overcomplicate things - also the server has no way of knowing which 2 vehicles you want to deal with.

When spawning the vehicles, does your current code do the following:
pawn Код:
// ...
Vehicles[0] = CreateVehicle(...);
// ...
Vehicles[1] = CreateVehicle(...);
// ...
Reply
#4

Quote:
Originally Posted by AndreT
Посмотреть сообщение
You will need to know how vehicle IDs are created in the server internally and assess how you want to approach this problem.

If you are going to create the textdraw labels for 2 vehicles only, you will probably be better off not using a loop as this would overcomplicate things - also the server has no way of knowing which 2 vehicles you want to deal with.

When spawning the vehicles, does your current code do the following:
pawn Код:
// ...
Vehicles[0] = CreateVehicle(...);
// ...
Vehicles[1] = CreateVehicle(...);
// ...
Yes it does this exactly.

Well I have solved the problem. This was strange.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)