MightyAnimals Posted July 12, 2014 Share Posted July 12, 2014 Hey! After I got some help with my last resource, I'm now doing stuff with the carshop system> My problem is, I want to let the custom carnames show in the hud, instead of the standard MTA Model, I've tried multiple functions, neither did any of them work. Here's my code localPlayer = getLocalPlayer() function carshop_showInfo(carPrice, taxPrice) local isOverlayDisabled = getElementData(localPlayer, "hud:isOverlayDisabled") if isOverlayDisabled then outputChatBox("") outputChatBox("As you walk by the vehicle, you notice a card in the sidewindow. It reads the following:") --outputChatBox(" --------------------------------------") outputChatBox("| "..getVehicleNameFromModel( getElementModel( source ) ) ) outputChatBox("| Now available for $"..exports.global:formatMoney(carPrice).."!" ) outputChatBox("| Tax costs: $"..tostring(taxPrice) ) --outputChatBox(" --------------------------------------") outputChatBox("Press F or Enter to buy this vehicle") else local content = {} table.insert(content, {"Car Dealership - Paper Sheet", false, false, false, false, false, false, "title"} ) table.insert(content, {" " } ) table.insert(content, {" - MTA Model: "..getVehicleNameFromModel( getElementModel( source ) ) } ) table.insert(content, {" - Custom Model:"}) table.insert(content, {" - " ..getVehicleNameFromModel( getElementModel( source ) ) } ) -- Ment to be used for custom carnames, doesn't work yet. table.insert(content, {" - Price: $"..exports.global:formatMoney(carPrice) } ) table.insert(content, {" - Tax: $"..exports.global:formatMoney(taxPrice) } ) table.insert(content, {"Press 'F' or 'Enter' to purchase!" } ) exports.hud:sendTopRightNotification( content, localPlayer, 240) end end addEvent("carshop:showInfo", true) addEventHandler("carshop:showInfo", getRootElement(), carshop_showInfo) Link to comment
ADCX Posted July 12, 2014 Share Posted July 12, 2014 CustomVehicleNames = {[429] = "Banshee Alternate Name"} -- Fill with vehicle IDs and custom names setPlayerHudComponentVisible("vehicle_name",false) localPlayer = getLocalPlayer() function carshop_showInfo(carPrice, taxPrice) local isOverlayDisabled = getElementData(localPlayer, "hud:isOverlayDisabled") if isOverlayDisabled then outputChatBox("") outputChatBox("As you walk by the vehicle, you notice a card in the sidewindow. It reads the following:") --outputChatBox(" --------------------------------------") outputChatBox("| "..getVehicleNameFromModel( getElementModel( source ) ) ) outputChatBox("| Now available for $"..exports.global:formatMoney(carPrice).."!" ) outputChatBox("| Tax costs: $"..tostring(taxPrice) ) --outputChatBox(" --------------------------------------") outputChatBox("Press F or Enter to buy this vehicle") else local content = {} table.insert(content, {"Car Dealership - Paper Sheet", false, false, false, false, false, false, "title"} ) table.insert(content, {" " } ) table.insert(content, {" - MTA Model: "..getVehicleNameFromModel( getElementModel( source ) ) } ) table.insert(content, {" - Custom Model:"}) table.insert(content, {" - " ..getVehicleCustomName( getElementModel( source ) ) } ) table.insert(content, {" - Price: $"..exports.global:formatMoney(carPrice) } ) table.insert(content, {" - Tax: $"..exports.global:formatMoney(taxPrice) } ) table.insert(content, {"Press 'F' or 'Enter' to purchase!" } ) exports.hud:sendTopRightNotification( content, localPlayer, 240) end end addEvent("carshop:showInfo", true) addEventHandler("carshop:showInfo", getRootElement(), carshop_showInfo) function getVehicleCustomName(VehicleID) return CustomVehicleNames[VehicleID] end function VehicleEnter(thePlayer) if (thePlayer == localPlayer) then outputChatBox("You have entered " .. getVehicleCustomName(getElementModel(source))) -- Change to some DX or GUI that will show the custom car name end end addEventHandler("onClientVehicleEnter",getRootElement(),VehicleEnter) Link to comment
MightyAnimals Posted July 12, 2014 Author Share Posted July 12, 2014 Uh, It worked for a moment. When I place more vehicles It only shows on 1 or doesn't show at all. CustomVehicleNames = {[470] = "1993 Hummer H1"} -- Fill with vehicle IDs and custom names CustomVehicleNames = {[411] = "1992 Acura NSX"} Only shows ID 411 470 doesn't show. Link to comment
ADCX Posted July 12, 2014 Share Posted July 12, 2014 CustomVehicleNames = {[470] = "1993 Hummer H1", [411] = "1992 Acura NSX"} Link to comment
MightyAnimals Posted July 13, 2014 Author Share Posted July 13, 2014 Yeah.. I figured that out. 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