Help with 3Dtext
#1

I made this script to show vehicle names as a 3DText. But it is not showing. I got no errors or warnings with it but it is not working ingame. I want the Text to stay on the vehicle all the time unless the server restart or close.

pawn Код:
#include <a_samp>

new Text3D:VTextLabel[MAX_VEHICLES];

new VNames[][]= {
    {"Landstalker"}, {"Bravura"}, {"Buffalo"}, {"Linerunner"}, {"Perrenial"},
    {"Sentinel"}, {"Dumper"}, {"Firetruck"}, {"Trashmaster"}, {"Stretch"},
    {"Manana"}, {"Infernus"}, {"Voodoo"}, {"Pony"}, {"Mule"}, {"Cheetah"},
    {"Ambulance"}, {"Leviathan"}, {"Moonbeam"}, {"Esperanto"}, {"Taxi"},
    {"Washington"}, {"Bobcat"}, {"Mr Whoopee"}, {"BF Injection"}, {"Hunter"},
    {"Premier"}, {"Enforcer"}, {"Securicar"}, {"Banshee"}, {"Predator"},
    {"Bus"}, {"Rhino"}, {"Barracks"}, {"Hotknife"}, {"Trailer 1"}, {"Previon"},
    {"Coach"}, {"Cabbie"}, {"Stallion"}, {"Rumpo"}, {"RC Bandit"}, {"Romero"},
    {"Packer"}, {"Monster"}, {"Admiral"}, {"Squalo"}, {"Sparrow"},
    {"Pizzaboy"}, {"Tram"}, {"Trailer 2"}, {"Turismo"}, {"Speeder"}, {"Reefer"},
    {"Tropic"}, {"Flatbed"}, {"Yankee"}, {"Caddy"}, {"Solair"},
    {"Berkley's RC Van"}, {"Skimmer"}, {"PCJ-600"}, {"Faggio"}, {"Freeway"},
    {"RC Baron"}, {"RC Raider"}, {"Glendale"}, {"Oceanic"}, {"Sanchez"},
    {"Seasparrow"}, {"Patriot"}, {"Quad"}, {"Coastguard"}, {"Dinghy"}, {"Hermes"},
    {"Sabre"}, {"Rustler"}, {"ZR-350"}, {"Walton"}, {"Regina"}, {"Comet"},
    {"BMX"}, {"Burrito"}, {"Camper"}, {"Marquis"}, {"Baggage"}, {"Dozer"},
    {"Maverick"}, {"News Maverick"}, {"Rancher"}, {"FBI Rancher"}, {"Virgo"},
    {"Greenwood"}, {"Jetmax"}, {"Hotring"}, {"Sandking"}, {"Blista Compact"},
    {"Police Maverick"}, {"Boxville"}, {"Benson"}, {"Mesa"},{"RC Goblin"},
    {"Hotring Racer A"}, {"Hotring Racer B"}, {"Bloodring Banger"}, {"Rancher"},
    {"Super GT"}, {"Elegant"}, {"Journey"}, {"Bike"}, {"Mountain Bike"},
    {"Beagle"}, {"Cropdust"}, {"Stunt"}, {"Tanker"}, {"Roadtrain"}, {"Nebula"},
    {"Majestic"}, {"Buccaneer"}, {"Shamal"}, {"Hydra"}, {"FCR-900"},
    {"NRG-500"}, {"HPV1000"}, {"Cement Truck"}, {"Tow Truck"}, {"Fortune"},
    {"Cadrona"}, {"FBI Truck"}, {"Willard"}, {"Forklift"}, {"Tractor"},
    {"Combine"}, {"Feltzer"}, {"Remington"}, {"Slamvan"}, {"Blade"},
    {"Freight"}, {"Brownstreak"}, {"Vortex"},{"Vincent"}, {"Bullet"}, {"Clover"},
    {"Sadler"}, {"Ladder Firetruck"}, {"Hustler"}, {"Intruder"}, {"Primo"},
    {"Cargobob"}, {"Tampa"}, {"Sunrise"}, {"Merit"}, {"Utility"}, {"Nevada"},
    {"Yosemite"}, {"Windsor"}, {"Monster A"}, {"Monster B"}, {"Uranus"},
    {"Jester"}, {"Sultan"}, {"Stratum"}, {"Elegy"}, {"Raindance"}, {"RC Tiger"},
    {"Flash"}, {"Tahoma"}, {"Savanna"}, {"Bandito"}, {"Freight Flat"},
    {"Streak Carriage"}, {"Kart"}, {"Mower"}, {"Dune"}, {"Sweeper"},
    {"Broadway"}, {"Tornado"}, {"AT-400"}, {"DFT-30"}, {"Huntley"},
    {"Stafford"}, {"BF-400"}, {"Newsvan"}, {"Tug"}, {"Trailer 3"}, {"Emperor"},
    {"Wayfarer"}, {"Euros"}, {"Hotdog"}, {"Club"}, {"Freight Carriage"},
    {"Trailer 4"},  {"Andromada"}, {"Dodo"}, {"RC Cam"}, {"Launch"},
    {"Police Car (LSPD)"}, {"Police Car (SFPD)"}, {"Police Car (LVPD)"},
    {"Police Ranger"}, {"Picador"}, {"S.W.A.T. Van"}, {"Alpha"}, {"Phoenix"},
    {"Old Glendale"}, {"Old Sadler"}, {"Luggage Trailer A"}, {"Luggage Trailer B"},
    {"Stair Trailer"}, {"Boxville"}, {"Farm Plow"}, {"Utility Trailer"}
};


forward VehicleTLabel(playerid);

public VehicleTLabel(playerid)
{
     new VText[50];
     new Float:vX, Float:vY, Float:vZ;
     new vehicleid = GetPlayerVehicleID(playerid);
     GetVehiclePos(vehicleid, vX, vY, vZ);
     VTextLabel[vehicleid] = Create3DTextLabel(VText, 0xFFFF00FF, vX, vY, vZ, 50.0, 0,0);
     format(VText, 128, "%s", VNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
     Attach3DTextLabelToVehicle(VTextLabel[vehicleid], vehicleid, 0.0, 0.0, 2.0);
     return 1;
}
Reply
#2

pawn Код:
new modelid = GetVehicleModel(GetPlayerVehicleID(playerid));
format(VText, sizeof (VText), "%s", (modelid) ? (VNames[modelid - 400]) : ("N/A"));
VTextLabel[vehicleid] = Create3DTextLabel(VText, 0xFFFF00FF, vX, vY, vZ, 50.0, 0,0);
Attach3DTextLabelToVehicle(VTextLabel[vehicleid], vehicleid, 0.0, 0.0, 2.0);
You should first format and then create the 3D label because the text will be NULL and the server/client might crash. You also declared VText with size 50 and you used 128 in the format. It shouldn't be longer than the original size.
Reply
#3

Still not working, i did what you said.

PS: I forgot to set the VText's size to 50 :P
Reply
#4

Where do you call VehicleTLabel?
Reply
#5

That is the whole FS i provided on the topic. Sorry i don't know a lot about the forward functions so. Where should i call it?
Reply
#6

Of course it doesn't work because it never calls VehicleTLabel; hence the 3D label will never be created, nor will be attached to the vehicle.

That's up to you (entirely) and it depends on when you want to create the 3D label. However, I'd suggest you to create the 3D label when a vehicle is created.
Reply
#7

If i add it under OnVehicleSpawn callback, it says undefined symbol playerid. it is a bit confusing for me so can you elaborate a bit more please?
Reply
#8

OnVehicleSpawn is called when a vehicle re-spawns, not when a vehicle is created.

The best option would be to hook CreateVehicle/AddStaticVehicle/AddStaticVehicleEx functions and call your own callback "OnVehicleCreate" and create, attach the 3D label there. All you need is vehicleid, not the playerid.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)