StefanAlmighty Posted August 27, 2015 Share Posted August 27, 2015 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. Link to comment
ozulus Posted August 27, 2015 Share Posted August 27, 2015 (edited) Omg sorry double post Edited August 27, 2015 by Guest Link to comment
ozulus Posted August 27, 2015 Share Posted August 27, 2015 Not sure but should be like that 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 = source -- i wrote source instead of thePlayer because thePlayer isnt defined else targetplayer = getPlayerFromPartialName(targetplayer) 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.",targetplayer) 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 function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Link to comment
StefanAlmighty Posted August 27, 2015 Author Share Posted August 27, 2015 EDIT: Nevermind, fixed. 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