..:D&G:.. Posted May 10, 2014 Share Posted May 10, 2014 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
Castillo Posted May 10, 2014 Share Posted May 10, 2014 There isn't. You can make just a resource which has the vehicle names and export a function. Link to comment
..:D&G:.. Posted May 10, 2014 Author Share Posted May 10, 2014 Eh... ok. How do I do that then? Link to comment
JR10 Posted May 10, 2014 Share Posted May 10, 2014 local names = { 411 = 'Name' } function getVehicleName(model) return names[model] or 'Unknown' end You just need to export getVehicleName. Link to comment
..:D&G:.. Posted May 10, 2014 Author Share Posted May 10, 2014 Can you please give me an example of an export? Link to comment
JR10 Posted May 10, 2014 Share Posted May 10, 2014 This might help: https://wiki.multitheftauto.com/wiki/Call Link to comment
..:D&G:.. Posted May 18, 2014 Author Share Posted May 18, 2014 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
Karuzo Posted May 18, 2014 Share Posted May 18, 2014 {490 = "BMW X5"}, Delete the "," Link to comment
.:HyPeX:. Posted May 18, 2014 Share Posted May 18, 2014 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
pa3ck Posted May 18, 2014 Share Posted May 18, 2014 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
tosfera Posted May 18, 2014 Share Posted May 18, 2014 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
..:D&G:.. Posted May 19, 2014 Author Share Posted May 19, 2014 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
TAPL Posted May 19, 2014 Share Posted May 19, 2014 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
..:D&G:.. Posted May 19, 2014 Author Share Posted May 19, 2014 WARNING: Bad argument @ 'getVehicleName' [C] ERROR: attempt to concatenate a boolean value Link to comment
TAPL Posted May 19, 2014 Share Posted May 19, 2014 Show the codes and the meta you have used. Link to comment
..:D&G:.. Posted May 19, 2014 Author Share Posted May 19, 2014 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
TAPL Posted May 19, 2014 Share Posted May 19, 2014 Try this and see if it output anything in the chat. local carName = exports['veh-names']:getVehicleName(402) outputChatBox(carName) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now