Juffx Posted June 8, 2015 Share Posted June 8, 2015 (edited) Hello my hotdog van script to not work correctly, the intention would be that would change random color to colortable but not change hotdog van color? This script will work even a year ago? colorTable = { {255, 0, 0}, {239, 84, 0}, {239, 236, 0}, {129, 239, 0}, {0, 255, 0}, {0, 239, 140}, {0, 230, 239}, {0, 123, 239}, {0, 39, 239}, {0, 0, 255}, {50, 0, 239}, {78, 0, 239}, {239, 0, 185}, {239, 0, 78}, } dogvan_positions = { {-2036.49, 303.46, 35.07, 357.35, 359.50, 0}, {-1982.70, 94.32, 27.58, 358.59, 0, 138.44}, {-2274.97, 534.41, 34.98, 358.68, 3.5, 0}, {-2467.93, 755.75, 35.07, 358.61, 0, 270}, {-2690.40, 354.49, 4.61, 358.65, 0, 145.26}, {-2714.41, 241.72, 4.23, 0, 0,0}, {-2550.43, -15.92, 16.32, 0, 0, 0}, {-2277.19, 214.44, 35.07, 0, 0, 322.0}, {-2374.66, -599.266, 132.01, 0, 0, 154.70}, {-2207.72, -400.05, 35.23, 0, 0, 10.62}, {-2091.82, -98.00, 35.06, 0, 0, 40.33}, {-1726.25, 682.70, 24.83, 0, 1.80, 0}, {-1971.28, 876.91, 45.11, 0, 0, 166.25}, {-1655.37, 1323.67, 7.08, 0, 0, 225.24}, {-2513.28, 1206.38, 37.32, 0, 0, 44.51}, {-1720.36, -123.344, 3.45, 0, 0, 195.99}, {-2351.35, -1648.06, 483.63, 0, 0.54, 31.67}, {-2222.37, -2143.72, 44.42, 9.32, 2.15, 302.72}, {-1495.58, 877.66, 7.09, 0, 0, 180}, } drugprice = 50 hotdog_price = 5 local shopText1 = "Buy a hotdog? - "..hotdog_price.."$" local shopText2 = "Press SHIFT to buy or walk away." local scr_x, scr_y = guiGetScreenSize() local fontSize = 1.0 local amountOfDrugs = 0 function createHotDogStart() for k, v in ipairs(dogvan_positions) do dogvan = createVehicle( 588, dogvan_positions[k][1], dogvan_positions[k][2], dogvan_positions[k][3], dogvan_positions[k][4], dogvan_positions[k][5], dogvan_positions[k][6] ) setVehicleColor ( dogvan, colorTable[math.random(1,14)][1], colorTable[math.random(1,14)][2], colorTable[math.random(1,14)][3], colorTable[math.random(1,14)][1], colorTable[math.random(1,14)][2], colorTable[math.random(1,14)][3] ) setElementFrozen( dogvan, true ) setVehicleLocked( dogvan, true ) setVehicleDamageProof ( dogvan, true ) setVehicleDoorsUndamageable ( dogvan, true ) dogshop = createMarker ( dogvan_positions[k][1]+2.2, dogvan_positions[k][2], dogvan_positions[k][3]-1, "cylinder", 1.2, 0, 255, 255, 120 ) dogshopCorona = createMarker ( dogvan_positions[k][1]+2.2, dogvan_positions[k][2], dogvan_positions[k][3]-0.2, "corona", 1.2, 0, 255, 255, 50 ) createObject( 3385, dogvan_positions[k][1], dogvan_positions[k][2], dogvan_positions[k][3]-1.5 ) attachElements ( dogshop, dogvan, 2.2, 0, -1 ) attachElements ( dogshopCorona, dogvan, 2.2, 0, -0.2 ) addEventHandler("onClientMarkerHit", dogshop, dogshop_enter) addEventHandler("onClientMarkerLeave", dogshop, dogshop_exit) end end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), createHotDogStart ) PS: Sorry my bad english Edited June 8, 2015 by Guest Link to comment
Miika Posted June 8, 2015 Share Posted June 8, 2015 You can't change hot-dog's color, I don't know why. I Tested with other vehicles. Link to comment
Juffx Posted June 8, 2015 Author Share Posted June 8, 2015 I can to change color But script not change color?? Link to comment
Walid Posted June 8, 2015 Share Posted June 8, 2015 it change the color but only onClientResourceStart , it mean the color will be changed every time you login. Link to comment
Juffx Posted June 8, 2015 Author Share Posted June 8, 2015 it change the color but only onClientResourceStart , it mean the color will be changed every time you login. But it not changed.. All hotdog van is this Link to comment
Walid Posted June 8, 2015 Share Posted June 8, 2015 try this and tell me what happen function changeColor() if isElement(dogvan) then local index = math.random(#colorTable) local r,g,b = colorTable[index][1], colorTable[index][2], colorTable[index][3] setVehicleColor ( dogvan, r,g,b) end end addCommandHandler("color",changeColor) Link to comment
Juffx Posted June 8, 2015 Author Share Posted June 8, 2015 try this and tell me what happen function changeColor() if isElement(dogvan) then local index = math.random(#colorTable) local r,g,b = colorTable[index][1], colorTable[index][2], colorTable[index][3] setVehicleColor ( dogvan, r,g,b) end end addCommandHandler("color",changeColor) Nothing happened even though I added the function and I make /color Link to comment
Walid Posted June 8, 2015 Share Posted June 8, 2015 Nothing happened even though I added the function and I make /color debugscript ?? Link to comment
Walid Posted June 8, 2015 Share Posted June 8, 2015 Nothing.. it's working fine i tested it Link to comment
Juffx Posted June 8, 2015 Author Share Posted June 8, 2015 Nothing.. it's working fine i tested it Post your code? Link to comment
Walid Posted June 8, 2015 Share Posted June 8, 2015 it's working fine i tested it Post your code?the code working just use table.insert to change all vehicles color. Example -- server side local veh = {} local colorTable = {{255, 0, 0},{239, 84, 0},{239, 236, 0},{129, 239, 0},{0, 255, 0},{0, 239, 140},{0, 230, 239},{0, 123, 239},{0, 39, 239},{0, 0, 255},{50, 0, 239},{78, 0, 239}} local dogvan_positions = { {-2036.49, 303.46, 35.07, 357.35, 359.50, 0}, {-1982.70, 94.32, 27.58, 358.59, 0, 138.44}, {-2274.97, 534.41, 34.98, 358.68, 3.5, 0}, {-2467.93, 755.75, 35.07, 358.61, 0, 270}, {-2690.40, 354.49, 4.61, 358.65, 0, 145.26}, {-2714.41, 241.72, 4.23, 0, 0,0}, {-2550.43, -15.92, 16.32, 0, 0, 0}, {-2277.19, 214.44, 35.07, 0, 0, 322.0}, {-2374.66, -599.266, 132.01, 0, 0, 154.70}, {-2207.72, -400.05, 35.23, 0, 0, 10.62}, {-2091.82, -98.00, 35.06, 0, 0, 40.33}, {-1726.25, 682.70, 24.83, 0, 1.80, 0}, {-1971.28, 876.91, 45.11, 0, 0, 166.25}, {-1655.37, 1323.67, 7.08, 0, 0, 225.24}, {-2513.28, 1206.38, 37.32, 0, 0, 44.51}, {-1720.36, -123.344, 3.45, 0, 0, 195.99}, {-2351.35, -1648.06, 483.63, 0, 0.54, 31.67}, {-2222.37, -2143.72, 44.42, 9.32, 2.15, 302.72}, {-1495.58, 877.66, 7.09, 0, 0, 180}, } function createHotDogStart() for k, v in ipairs(dogvan_positions) do dogvan = createVehicle( 588, dogvan_positions[k][1], dogvan_positions[k][2], dogvan_positions[k][3], dogvan_positions[k][4], dogvan_positions[k][5], dogvan_positions[k][6] ) table.insert(veh,dogvan) local index = math.random(#colorTable) local r,g,b = colorTable[index][1], colorTable[index][2], colorTable[index][3] setVehicleColor ( dogvan, r,g,b) setElementFrozen( dogvan, true ) setVehicleLocked( dogvan, true ) setVehicleDamageProof ( dogvan, true ) setVehicleDoorsUndamageable ( dogvan, true ) dogshop = createMarker ( dogvan_positions[k][1]+2.2, dogvan_positions[k][2], dogvan_positions[k][3]-1, "cylinder", 1.2, 0, 255, 255, 120 ) dogshopCorona = createMarker ( dogvan_positions[k][1]+2.2, dogvan_positions[k][2], dogvan_positions[k][3]-0.2, "corona", 1.2, 0, 255, 255, 50 ) createObject( 3385, dogvan_positions[k][1], dogvan_positions[k][2], dogvan_positions[k][3]-1.5 ) attachElements ( dogshop, dogvan, 2.2, 0, -1 ) attachElements ( dogshopCorona, dogvan, 2.2, 0, -0.2 ) end end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createHotDogStart ) function changeColor(player) for i,v in pairs (veh) do local index = math.random(#colorTable) local r,g,b = colorTable[index][1], colorTable[index][2], colorTable[index][3] setVehicleColor (v, r,g,b) end end addCommandHandler("c",changeColor) Link to comment
Juffx Posted June 8, 2015 Author Share Posted June 8, 2015 Possible to get to work on this color change in client side? Link to comment
Miika Posted June 11, 2015 Share Posted June 11, 2015 Yes, if you use createVehicle on client side. 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