SA-MP Forums Archive
Vehicle name as Text draw - 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: Vehicle name as Text draw (/showthread.php?tid=315505)



Vehicle name as Text draw - Twinki1993 - 03.02.2012

Well how do I make text draw that will show vehicle name? I know how to make textdraw but I dont know how to put these two together.

Coords: 286, 465

So when you enter vehicle there will be text draw saying "Infernus", "Turismo" etc.. For all cars basically.


AW: Vehicle name as Text draw - Drebin - 03.02.2012

You need an array which holds the vehicle names in chronological order (lowest model ID is 400, so you start with the name of vehicle model 400, go on with 401, 402 etc).
pawn Код:
new VehicleNames[][] =
{"Name of 400","Name of 401","Name of 402","Name of 403","Name of 404","Name of 405",[...]};
When a player enters a vehicle, you get the model ID of the vehicle and substract 400 from it (e.g. he entered vehicle model ID 405, you substract 400 from it = 5). Now you get the string at position 5 from this array (in this case "Name of 405"), put it into the textdraw and then show the textdraw to the player.
Search the forum for some speedometers which have a textdraw for the vehicle menu and look into the code to get the idea.


Re: Vehicle name as Text draw - MP2 - 03.02.2012

pawn Код:
new VehicleNames2[][]= {
    {"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"}
};

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2 && oldstate == 1)
    {
        format(szString, sizeof(szString), "~G~%s", VehicleNames2[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
        GameTextForPlayer(playerid, szString, 1337, 1);
    }
    return 1;
}



Re: Vehicle name as Text draw - Twinki1993 - 03.02.2012

Quote:

C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(853) : error 017: undefined symbol "szString"
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(853) : error 017: undefined symbol "szString"
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(853) : error 029: invalid expression, assumed zero
C:\Users\Maki\Desktop\server 0.3d\gamemodes\TankDM.pwn(853) : fatal error 107: too many error messages on one line

This is what I've got with your code Mp2


Re: Vehicle name as Text draw - MP2 - 03.02.2012

Define szString then.

new szString[16];


Re: Vehicle name as Text draw - Vince - 03.02.2012

Then define szString. I hope you know how to declare string variables already?

Sidenote: This Hungarian Notation is both redundant and retarded.


Re: Vehicle name as Text draw - Twinki1993 - 03.02.2012

Well thanks, it's working but it stays only for some little time. I want of it to be there until player leaves the vehicle


Re: Vehicle name as Text draw - Twinki1993 - 03.02.2012

BUMP


Re: Vehicle name as Text draw - Scenario - 03.02.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
Then define szString. I hope you know how to declare string variables already?

Sidenote: This Hungarian Notation is both redundant and retarded.
Use it for a little while and you'll understand its purpose.

Quote:
Originally Posted by Twinki1993
Посмотреть сообщение
Well thanks, it's working but it stays only for some little time. I want of it to be there until player leaves the vehicle
You need to create a text-draw and use the code MP2 provided to display the vehicle name. Once the player leaves the vehicle, hide the text-draw.


Re: Vehicle name as Text draw - Vince - 03.02.2012

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Use it for a little while and you'll understand its purpose.
OFF: What purpose?
  1. variables of one type cannot be implicitly converted to another (tag mismatch).
  2. type checking is done by the compiler (tag mismatch).
  3. szString is a recursive variable name; string, zero-terminated, string.
  4. sz itself is redundant because all strings in Pawn are always zero-terminated.