Alright so when somebody selects a vehicle on the list, chooses a player to spawn it to, chooses two colours and hits "spawn", it calls this function:
function spawnButton(button)
if button == "left" then
local targetplayer = guiGetText(player)
local targetcolour1 = guiGetText(colour1)
local targetcolour2 = guiGetText(colour2)
local vehiclemodel = guiGridListGetItemText(vehicleMenuCarsList,guiGridListGetSelectedItem(vehicleMenuCarsList),1)
if targetplayer == "Player" or "" then
targetplayer = thePlayer
end
if targetcolour1 == "Colour 1" or "" then
targetcolour1 = 1
end
if targetcolour2 == "Colour 2" or "" then
targetcolour2 = 1
end
if vehiclemodel == -1 then
guiSetVisible(vehicleMenuWindow,false)
showCursor(false)
outputChatBox("You did not select a vehicle to spawn.",thePlayer)
end
local xs,ys,zs = getElementPosition(targetplayer)
local vehicleid = createVehicle(vehiclemodel, xs, ys, zs)
setVehicleColor(vehicleid, targetcolour1, targetcolour2, 0, 0)
guiSetVisible(vehicleMenuWindow,false)
showCursor(false)
outputChatBox("You have spawned a vehicle.",targetplayer)
end
end
I've tested the script with pre-set coordinates and it worked fine, but when the coordinates are xs, ys and zs the vehicle doesn't spawn. xs, ys and zs and set via the getElementPosition.