Jump to content

[Help] Vehicle Color


3B00DG4MER

Recommended Posts

Hello,Today i made a Spawn System which Spawn Vehicle From Selected Row

It's work perfectly but there is one Problem :

i have add if the vehicle is Sultan set the color of sultan blue sky

it show :

Bad argument @ 'setVehicleColor'

Client Side:

            function createveh() 
             local pspawner = getLocalPlayer() 
             local x, y, z = getElementPosition ( pspawner ) 
             local vehicle = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) 
             guiSetVisible(GUIEditor.window[1], false) 
             outputChatBox("You selected "..vehicle..".",pspawner) 
             createVehicle ( vehicle, x, y, z, 0,0,90 ) 
             if vehicle == "560" then 
             setVehicleColor ( vehicle, 7, 7, 0, 0 ) 
             end 
             showCursor(false) 
        end 
        addEventHandler("onClientGUIClick", spawn, createveh, false) 

Link to comment
function createveh() 
             local pspawner = getLocalPlayer() 
             local x, y, z = getElementPosition ( pspawner ) 
             local vehicle = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) 
             guiSetVisible(GUIEditor.window[1], false) 
             outputChatBox("You selected "..vehicle..".",pspawner) 
             local veh = createVehicle ( vehicle, x, y, z, 0,0,90 ) 
             if vehicle == "560" then 
                 setVehicleColor ( veh, 7, 7, 0, 0 ) 
             end 
             showCursor(false) 
        end 
        addEventHandler("onClientGUIClick", spawn, createveh, false) 

Link to comment
function createveh() 
             local pspawner = getLocalPlayer() 
             local x, y, z = getElementPosition ( pspawner ) 
             local vehicle = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) 
             guiSetVisible(GUIEditor.window[1], false) 
             outputChatBox("You selected "..vehicle..".",pspawner) 
             local veh = createVehicle ( vehicle, x, y, z, 0,0,90 ) 
             if vehicle == "560" then 
                 setVehicleColor ( veh, 7, 7, 0, 0 ) 
             end 
             showCursor(false) 
        end 
        addEventHandler("onClientGUIClick", spawn, createveh, false) 

There is No Bug

But it doesn't set Color of Vehicle :cry:

Link to comment
  
addEventHandler("onClientGUIClick",spawn,function() 
    local x,y,z = getElementPosition(localPlayer) 
    local id = guiGridListGetItemText(GUIEditor.gridlist[1],guiGridListGetSelectedItem(GUIEditor.gridlist[1]),1) 
    guiSetVisible(GUIEditor.window[1],false) 
    showCursor(false) 
    outputChatBox("You selected "..vehicle..".",localPlayer) 
    local vehicle = createVehicle(tonumber(id),x,y,z,0,0,90) 
    if tonumber(id) == 560 then 
        setVehicleColor(vehicle,0,128,255) 
    end 
end,false) 
  

Link to comment
  
addEventHandler("onClientGUIClick",spawn,function() 
    local x,y,z = getElementPosition(localPlayer) 
    local id = guiGridListGetItemText(GUIEditor.gridlist[1],guiGridListGetSelectedItem(GUIEditor.gridlist[1]),1) 
    guiSetVisible(GUIEditor.window[1],false) 
    showCursor(false) 
    outputChatBox("You selected "..vehicle..".",localPlayer) 
    local vehicle = createVehicle(tonumber(id),x,y,z,0,0,90) 
    if tonumber(id) == 560 then 
        setVehicleColor(vehicle,0,128,255) 
    end 
end,false) 
  

Doesn't work

it mean there is a bug with that function

Link to comment
The grid list contains vehicle names or vehicle models?

First row contain IDs Second contain Vehicle names

        GUIEditor.gridlist[1] = guiCreateGridList(30, 124, 337, 221, false, GUIEditor.window[1]) 
                guiGridListAddColumn(GUIEditor.gridlist[1], "ID", 0.3) 
                guiGridListAddColumn(GUIEditor.gridlist[1], "Name", 0.7) 
        for i = 1, 6 do 
            guiGridListAddRow(GUIEditor.gridlist[1]) 
        end 
        guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "596", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 0, 2, "Police Car (Los Santos)", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "597", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 1, 2, "Police Car (San Fierro)", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "598", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 2, 2, "Police Car (Las Venturas)", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 3, 1, "523", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 3, 2, "HPV1000", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 4, 1, "528", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 4, 2, "FBI Truck", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 5, 1, "560", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 5, 2, "Sultan", false, false) 

Link to comment
Hello,Today i made a Spawn System which Spawn Vehicle From Selected Row

It's work perfectly but there is one Problem :

i have add if the vehicle is Sultan set the color of sultan blue sky

it show :

Bad argument @ 'setVehicleColor'

Client Side:

            function createveh() 
             local pspawner = getLocalPlayer() 
             local x, y, z = getElementPosition ( pspawner ) 
             local vehicle = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) 
             guiSetVisible(GUIEditor.window[1], false) 
             outputChatBox("You selected "..vehicle..".",pspawner) 
             createVehicle ( vehicle, x, y, z, 0,0,90 ) 
             if vehicle == "560" then 
             setVehicleColor ( vehicle, 7, 7, 0, 0 ) 
             end 
             showCursor(false) 
        end 
        addEventHandler("onClientGUIClick", spawn, createveh, false) 

Can you fix that ?

function spawnvehicle( vehicle ) 
if veh then 
destroyElement(veh) 
end 
local x, y, z = getElementPosition(source) 
local veh = createVehicle(vehicle , x, y, z) 
             if vehicle == "560" then 
                 setVehicleColor ( veh, 7, 7, 0, 0 ) 
             end 
            warpPedIntoVehicle(source ,veh) 
end 
  
  
addEvent( "onSpawnVeh", true ) 
addEventHandler( "onSpawnVeh", root, spawnvehicle ) 

Vehicle Won't Destory

Link to comment

3B00DG4MER, Try this:

Client

function createveh() 
    local pspawner = getLocalPlayer() 
    local x, y, z = getElementPosition ( pspawner ) 
    local vehicle = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) 
    if vehicle then 
        outputChatBox("You selected "..vehicle..".",pspawner) 
        triggerServerEvent("onSpawnVeh", localPlayer, tonumber(vehicle)) 
        guiSetVisible(GUIEditor.window[1], false) 
        showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", spawn, createveh, false) 

Server

local vehicle = {} 
function spawnvehicle( vehID ) 
    if isElement(vehicle[source]) then 
        destroyElement(vehicle[source]) 
    end 
    local x, y, z = getElementPosition(source) 
    vehicle[source] = createVehicle(vehID , x, y, z) 
    if vehID == 560 then 
        setVehicleColor ( vehicle[source], 7, 7, 0, 0 ) 
    end 
    warpPedIntoVehicle( source, vehicle[source] ) 
end 
addEvent( "onSpawnVeh", true ) 
addEventHandler( "onSpawnVeh", root, spawnvehicle ) 

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...