Jump to content

[HELP] Changing the name of vehicles


Recommended Posts

Is there any way I can change the names of the vehicles, so it shows other name, for example I am using getVehicleName so it shows BMW M5 instead of Merit for example. I want to make it so I don't have to set an export or anything else on everyyy code, I want to to be set globaly.

Thanks.

Link to comment

I keep getting the error:

'}' expected (to close '{' at line 1) near '='

Code:

local vehicule = { 
{550 = "BMW M5"}, 
{551 = "Dacia 1310 Brek"}, 
{480 = "Porshe 911 Sport Clssic"}, 
{402 = "BMW E46 Ursuleț"}, 
{494 = "Nissan GTR"}, 
{502 = "Ford Mustang Boss"}, 
{503 = "BMW M3 Sport"}, 
{555 = "BMW M5 Sport"}, 
{526 = "Audi A6"}, 
{400 = "Dacia Duster"}, 
{507 = "Dacia Logan"}, 
{404 = "Dacia 1300"}, 
{474 = "Mercedes E500"}, 
{496 = "Ford Focus"}, 
{412 = "Mazda RX-8"}, 
{603 = "Shelby"}, 
{574 = "Căruță & Cal"}, 
{411 = "Lamborghini Veneno"}, 
{471 = "ATV Honda"}, 
{419 = "Chevrolet Camaro SS"}, 
{489 = "BMW X6"}, 
{445 = "Dacia 1310"}, 
{533 = "Nenault Cleo Sport"}, 
{544 = "Chevrolet Co"}, 
{589 = "Peugeot 206"}, 
{429 = "Chevrolet Corvette"}, 
{579 = "Range Rover"}, 
{490 = "BMW X5"}, 
} 
  
function getVehicleName(model) 
    return vehicule[model] or 'Necunoscut' 
end 
  
addEvent ( "getVehicleName", true ) 
addEventHandler ( "getVehicleName", getRootElement(), getVehicleName ) 

Link to comment

The script isnt recognizing the variables. try this:

  
vehicles = { 
{a550 = "BMW M5"}, 
{a551 = "Dacia 1310 Brek"}, 
{a480 = "Porshe 911 Sport Clssic"}, 
{a402 = "BMW E46 Ursuleț"}, 
{a494 = "Nissan GTR"}, 
{a502 = "Ford Mustang Boss"}, 
{a503 = "BMW M3 Sport"}, 
{a555 = "BMW M5 Sport"}, 
{a526 = "Audi A6"}, 
{a400 = "Dacia Duster"}, 
{a507 = "Dacia Logan"}, 
{a404 = "Dacia 1300"}, 
{a474 = "Mercedes E500"}, 
{a496 = "Ford Focus"}, 
{a412 = "Mazda RX-8"}, 
{a603 = "Shelby"}, 
{a574 = "Căruță & Cal"}, 
{a411 = "Lamborghini Veneno"}, 
{a471 = "ATV Honda"}, 
{a419 = "Chevrolet Camaro SS"}, 
{a489 = "BMW X6"}, 
{a445 = "Dacia 1310"}, 
{a533 = "Nenault Cleo Sport"}, 
{a544 = "Chevrolet Co"}, 
{a589 = "Peugeot 206"}, 
{a429 = "Chevrolet Corvette"}, 
{a579 = "Range Rover"}, 
{a490 = "BMW X5"} 
} 
  
function getVehicleName(model) 
    return vehicles["a"..model] or 'Necunoscut' 
end 
  
addEvent ( "getVehicleName", true ) 
addEventHandler ( "getVehicleName", getRootElement(), getVehicleName ) 
  

Link to comment
local vehicule =  
{ 
    550 = "BMW M5", 
    551 = "Dacia 1310 Brek", 
    480 = "Porshe 911 Sport Clssic", 
} 
  
function getVehicleName(model) 
    return vehicule[model] or 'Necunoscut' 
end 
  
addEvent ( "getVehicleName", true ) 
addEventHandler ( "getVehicleName", getRootElement(), getVehicleName ) 

I don't know why did you put in the last two lines, you don't actually need it.

Link to comment
The script isnt recognizing the variables. try this:
  
vehicles = { 
{a550 = "BMW M5"}, 
{a551 = "Dacia 1310 Brek"}, 
{a480 = "Porshe 911 Sport Clssic"}, 
{a402 = "BMW E46 Ursuleț"}, 
{a494 = "Nissan GTR"}, 
{a502 = "Ford Mustang Boss"}, 
{a503 = "BMW M3 Sport"}, 
{a555 = "BMW M5 Sport"}, 
{a526 = "Audi A6"}, 
{a400 = "Dacia Duster"}, 
{a507 = "Dacia Logan"}, 
{a404 = "Dacia 1300"}, 
{a474 = "Mercedes E500"}, 
{a496 = "Ford Focus"}, 
{a412 = "Mazda RX-8"}, 
{a603 = "Shelby"}, 
{a574 = "Căruță & Cal"}, 
{a411 = "Lamborghini Veneno"}, 
{a471 = "ATV Honda"}, 
{a419 = "Chevrolet Camaro SS"}, 
{a489 = "BMW X6"}, 
{a445 = "Dacia 1310"}, 
{a533 = "Nenault Cleo Sport"}, 
{a544 = "Chevrolet Co"}, 
{a589 = "Peugeot 206"}, 
{a429 = "Chevrolet Corvette"}, 
{a579 = "Range Rover"}, 
{a490 = "BMW X5"} 
} 
  
function getVehicleName(model) 
    return vehicles["a"..model] or 'Necunoscut' 
end 
  
addEvent ( "getVehicleName", true ) 
addEventHandler ( "getVehicleName", getRootElement(), getVehicleName ) 
  

Not sure if that would work, but I was having trouble using the brackets at my arrays too. You'll be creating new arrays with a different key, value pattern again. I would recommend to use [ model ], just like so;

local vehicles = { 
    [ 550 ] = "BMW M5", 
    [ 551 ] = "Dacia 1310 Brek", 
    [ 480 ] = "Porshe 911 Sport Clssic", 
    [ 402 ] = "BMW E46 Ursuleț", 
    [ 494 ] = "Nissan GTR", 
    [ 502 ] = "Ford Mustang Boss", 
    [ 503 ] = "BMW M3 Sport", 
    [ 555 ] = "BMW M5 Sport", 
    [ 526 ] = "Audi A6", 
    [ 400 ] = "Dacia Duster", 
    [ 507 ] = "Dacia Logan", 
    [ 404 ] = "Dacia 1300", 
    [ 474 ] = "Mercedes E500", 
    [ 496 ] = "Ford Focus", 
    [ 412 ] = "Mazda RX-8", 
    [ 603 ] = "Shelby", 
    [ 574 ] = "Căruță & Cal", 
    [ 411 ] = "Lamborghini Veneno", 
    [ 471 ] = "ATV Honda", 
    [ 419 ] = "Chevrolet Camaro SS", 
    [ 489 ] = "BMW X6", 
    [ 445 ] = "Dacia 1310", 
    [ 533 ] = "Nenault Cleo Sport", 
    [ 544 ] = "Chevrolet Co", 
    [ 589 ] = "Peugeot 206", 
    [ 429 ] = "Chevrolet Corvette", 
    [ 579 ] = "Range Rover", 
    [ 490 ] = "BMW X5" 
}; 
  
function getVehicleName ( model ) 
    return vehicles [ model ] or 'Unknown'; 
end  
addEvent ( "getVehicleName", true ) 
addEventHandler ( "getVehicleName", getRootElement(), getVehicleName ) 

edit; ^ up was faster, haha.

Link to comment

This is what I did in other script:

local carName = exports['veh-names]:getVehicleName(source) 
    triggerClientEvent ( "gui:hint", thePlayer, "Info", "This vehicle is a: " .. carName .. ".",4) 
 

But it does not work, I get the default name..

Link to comment
local carName = exports['veh-names]:getVehicleName(source) 
  
  
  
  
 

Should be:

local carName = exports['veh-names']:getVehicleName(getElementModel(source)) 

And remove this as it doesn't make any sense.

addEvent ( "getVehicleName", true ) 
addEventHandler ( "getVehicleName", getRootElement(), getVehicleName ) 

Link to comment

Here is where the error is coming from:

exports.chat:outputChatBox(source, "Unlocks the vehicle. ((" .. exports['veh-names']:getVehicleName(getElementModel(vehicle)) .. "))") 

---------------------

And here I get the error: attempt to concatenate local 'carName' (a boolean value)

Code:

local carName = exports['veh-names']:getVehicleName(getElementModel(source)) 
triggerClientEvent ( "gui:hint", thePlayer, "Info", "This vehicle is a : " .. carName .. ".",4) 

---------------------

Meta:

<meta> 
    <info author="Geo" type="script" description="Vehicle Names"/> 
  
    <script src="c_nume_vehicule.lua" type="client"/> 
    <export function="getVehicleName" type="client"/> 
    <export function="getVehicleName" type="server"/> 
</meta> 

Code:

local vehicule = { 
    [ 550 ] = "BMW M5", 
    [ 551 ] = "Dacia 1310 Break", 
    [ 480 ] = "Porshe 911 Sport Clssic", 
    [ 402 ] = "BMW E30", 
    [ 494 ] = "Nissan GTR", 
    [ 502 ] = "Ford Mustang Boss", 
    [ 503 ] = "BMW M3 Sport", 
    [ 555 ] = "BMW M5 Sport", 
    [ 526 ] = "Audi A6", 
    [ 400 ] = "Dacia Duster", 
    [ 507 ] = "Dacia Logan", 
    [ 404 ] = "Dacia 1300", 
    [ 474 ] = "Mercedes E500", 
    [ 496 ] = "Ford Focus", 
    [ 412 ] = "Mazda RX-8", 
    [ 603 ] = "Shelby", 
    [ 574 ] = "Căruță & Cal", 
    [ 411 ] = "Lamborghini Veneno", 
    [ 471 ] = "ATV Honda", 
    [ 419 ] = "Chevrolet Camaro SS", 
    [ 489 ] = "BMW X6", 
    [ 445 ] = "Dacia 1310", 
    [ 533 ] = "Nenault Cleo Sport", 
    [ 544 ] = "Chevrolet Co", 
    [ 589 ] = "Peugeot 206", 
    [ 429 ] = "Chevrolet Corvette", 
    [ 579 ] = "Range Rover", 
    [ 490 ] = "BMW X5" 
}; 
  
function getVehicleName ( model ) 
    return vehicule [ model ] or 'Necunoscut'; 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...