Baseplate Posted September 2, 2012 Share Posted September 2, 2012 I have this script, the GUI shows up on marker hit, but buttons aren't working Client local vehicles = {"BMX", "Bike", "Mountain Bike"} local bikes = createMarker(1183.2487792969, -1314.9769287109, 12.546875, 'cylinder', 1.5, 255, 255, 255, 255) function createVehGui () MainGui = guiCreateWindow(408,203,240,349,"Vehicle",false) VehGrid = guiCreateGridList(17,32,200,256,false,MainGui) guiGridListSetSelectionMode(VehGrid,2) _bikes = guiGridListAddColumn(VehGrid,"Vehicle name:",0.85) Spawn = guiCreateButton(15,305,96,35,"Use",false,MainGui) guiSetFont(Spawn,"clear-normal") Cancel = guiCreateButton(128,305,96,35,"Close",false,MainGui) guiSetFont(Cancel,"clear-normal") for index, vehicle in ipairs(vehicles) do local row = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, row, _bikes, tostring(vehicle), false, false ) end end addEventHandler("onClientMarkerHit", bikes, function ( hitElement ) if (hitElement == localPlayer) then createVehGui ( hitElement ) if (MainGui ~= nil) then guiSetVisible(MainGui, true) showCursor(true) guiSetInputEnabled(true) else outputChatBox ("Error: Please Re-enter in the marker to get your vehicle.", 255, 0, 0) end end end ) addEventHandler("onClientGUIClick", root, function () if (source == Spawn) then local row,col = guiGridListGetSelectedItem(VehGrid) if (row and col and row ~= -1 and col ~= -1) then local vehicleName = guiGridListGetItemText(VehGrid, row, 1) if vehicleName then triggerServerEvent("spawnBike",localPlayer,vehicleName) end else outputChatBox("Error: Please select a vehicle from the list.",255,0,0) end elseif (source == Cancel) then guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) end end ) addEventHandler("onClientPlayerWasted", root, function () guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) end) Server: function spawnBike (lol) local id = getElementModel(thevehicle) if id == 509 or id == 510 or id == 481 then local x, y, z = getElementPosition ( source ) local xr, yr, zr = getElementRotation ( source ) createVehicle = createVehicle (id, x, y, z + 0.5, xr, yr, zr ) warpPedIntoVehicle(source, createVehicle) end end addEvent( "spawnBike", true) addEventHandler("spawnBike",root,spawnBike) Link to comment
TAPL Posted September 2, 2012 Share Posted September 2, 2012 thevehicle is not define. actually i don't understand why you have it in your code local id = getElementModel(thevehicle) You should get the vehicle id from its name using this: https://wiki.multitheftauto.com/wiki/GetVehicleModelFromName also this is wrong warpPedIntoVehicle(source, createVehicle) Link to comment
Baseplate Posted September 2, 2012 Author Share Posted September 2, 2012 Meh iz idiot , Thanks Tapl, working fine now 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