Loop through 3DText lables and vehicles - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Loop through 3DText lables and vehicles (
/showthread.php?tid=419596)
Loop through 3DText lables and vehicles -
Cypress - 01.03.2013
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;
}
Re: Loop through 3DText lables and vehicles -
[MG]Dimi - 01.03.2013
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.
Re: Loop through 3DText lables and vehicles -
AndreT - 01.03.2013
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(...);
// ...
Re: Loop through 3DText lables and vehicles -
Cypress - 01.03.2013
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.