JuegosPato Posted August 24, 2012 Share Posted August 24, 2012 El problema es cuando seleccionas a un vehículo y después usas el botón "use" pero no te sale el Vehículo. 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("onClientMarkerLeave", bikes, function ( leaveElement ) if (leaveElement == localPlayer) then guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) 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("Erro: 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
BorderLine Posted August 24, 2012 Share Posted August 24, 2012 evita usar variables con el mismo nombre de funciones.. por ejemplo deberias poner algo como bike = createVehicle(id, x, y, z + 0.5, xr, yr, zr ) warpPedIntoVehicle(source, bike) Link to comment
CheiN Posted August 24, 2012 Share Posted August 24, 2012 tu problema es en el server side y estas warpeando pero no puedes usar createVehicle por que no es parte de su sintax Link to comment
BorderLine Posted August 24, 2012 Share Posted August 24, 2012 como ke la sintaxis esta mal? yo lo veo bien... mira los argumentos Link to comment
CheiN Posted August 24, 2012 Share Posted August 24, 2012 esta bien? warpPedIntoVehicle (source, createVehicle) ofc yakuza, pato esta mal Link to comment
BorderLine Posted August 24, 2012 Share Posted August 24, 2012 aaah pero por eso le mencione ke no usara esas funciones nativas de mta como variables.. intenta esto pato function spawnBike () 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 ) bike = createVehicle (id, x, y, z + 0.5, xr, yr, zr ) warpPedIntoVehicle(source, bike) end end addEvent( "spawnBike", true) addEventHandler("spawnBike",root,spawnBike) Link to comment
JuegosPato Posted August 24, 2012 Author Share Posted August 24, 2012 aaah pero por eso le mencione ke no usara esas funciones nativas de mta como variables..intenta esto pato function spawnBike () 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 ) bike = createVehicle (id, x, y, z + 0.5, xr, yr, zr ) warpPedIntoVehicle(source, bike) end end addEvent( "spawnBike", true) addEventHandler("spawnBike",root,spawnBike) No funciona ahora.No aparese el gui. Link to comment
Alexs Posted August 24, 2012 Share Posted August 24, 2012 local vehicles = {"BMX", "Bike", "Mountain Bike"} local bikes = createMarker(1183.2487792969, -1314.9769287109, 12.546875, 'cylinder', 1.5, 255, 255, 255, 255) 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 ) guiSetVisible(MainGui, false) --Reemplace la función que tenias por esto. addEventHandler("onClientMarkerLeave", bikes, function ( leaveElement ) if (leaveElement == localPlayer) then guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) 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("Erro: 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) PD: Acá no veo cuando muestras el GUi de creación. Link to comment
JuegosPato Posted September 9, 2013 Author Share Posted September 9, 2013 local vehicles = {"BMX", "Bike", "Mountain Bike"} local bikes = createMarker(1183.2487792969, -1314.9769287109, 12.546875, 'cylinder', 1.5, 255, 255, 255, 255) 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 ) guiSetVisible(MainGui, false) --Reemplace la función que tenias por esto. addEventHandler("onClientMarkerLeave", bikes, function ( leaveElement ) if (leaveElement == localPlayer) then guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) 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("Erro: 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) PD: Acá no veo cuando muestras el GUi de creación. Me dice que tengo un error en la Linea 12 (No agan caso sobre el getElementModel, era otro resource.) Link to comment
EstrategiaGTA Posted September 9, 2013 Share Posted September 9, 2013 Pon un end al final de la función. Link to comment
Sensacion Posted September 9, 2013 Share Posted September 9, 2013 Postea todo client y server. Link to comment
JuegosPato Posted September 9, 2013 Author Share Posted September 9, 2013 Postea todo client y server. Client. local vehicles = {"BMX", "Bike", "Mountain Bike"} local bikes = createMarker(1183.2487792969, -1314.9769287109, 12.546875, 'cylinder', 1.5, 255, 255, 255, 255) 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 ) guiSetVisible(MainGui, false) --Reemplace la función que tenias por esto. addEventHandler("onClientMarkerLeave", bikes, function ( leaveElement ) if (leaveElement == localPlayer) then guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) 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("Erro: 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 () 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 ) bike = createVehicle (id, x, y, z + 0.5, xr, yr, zr ) warpPedIntoVehicle(source, bike) end end addEvent( "spawnBike", true) addEventHandler("spawnBike",root,spawnBike) Link to comment
Sensacion Posted September 9, 2013 Share Posted September 9, 2013 Donde está el onClientMarkerHit o como haces aparecer el gui Link to comment
JuegosPato Posted September 9, 2013 Author Share Posted September 9, 2013 Donde está el onClientMarkerHit o como haces aparecer el gui Ya puse el Ya le puse , pero, ahora me da error, no aparece el gui igual Esto es lo que aparece: ERROR:tdb-xd/client.lua21:attempt to call global 'createVehGui' (a nill value) local vehicles = {"BMX", "Bike", "Mountain Bike"} local bikes = createMarker(1183.2487792969, -1314.9769287109, 12.546875, 'cylinder', 1.5, 255, 255, 255, 255) 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 end local row = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, row, _bikes, tostring(vehicle), false, false ) guiSetVisible(MainGui, false) ---------------------------------------------------------------------------------------------------------------- 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("Erro: 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) Link to comment
Castillo Posted September 9, 2013 Share Posted September 9, 2013 local vehicles = {"BMX", "Bike", "Mountain Bike"} local bikes = createMarker(1183.2487792969, -1314.9769287109, 12.546875, 'cylinder', 1.5, 255, 255, 255, 255) 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 end local row = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, row, _bikes, tostring(vehicle), false, false ) guiSetVisible(MainGui, false) ---------------------------------------------------------------------------------------------------------------- addEventHandler("onClientMarkerHit", bikes, function ( hitElement ) if (hitElement == localPlayer) then 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("Erro: 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) Link to comment
JuegosPato Posted September 9, 2013 Author Share Posted September 9, 2013 local vehicles = {"BMX", "Bike", "Mountain Bike"} local bikes = createMarker(1183.2487792969, -1314.9769287109, 12.546875, 'cylinder', 1.5, 255, 255, 255, 255) 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 end local row = guiGridListAddRow (VehGrid) guiGridListSetItemText ( VehGrid, row, _bikes, tostring(vehicle), false, false ) guiSetVisible(MainGui, false) ---------------------------------------------------------------------------------------------------------------- addEventHandler("onClientMarkerHit", bikes, function ( hitElement ) if (hitElement == localPlayer) then 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("Erro: 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) Ahora esta el GUI, pero los nuevos errores son que no estan los vehiculos y tengo un error con el getElementModel D: Imagen: Por si acaso, aqui les dejo el Server. function spawnBike () 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 ) bike = createVehicle (id, x, y, z + 0.5, xr, yr, zr ) warpPedIntoVehicle(source, bike) end end addEvent( "spawnBike", true) addEventHandler("spawnBike",root,spa Link to comment
Sensacion Posted September 10, 2013 Share Posted September 10, 2013 local vehicles = {"BMX", "Bike", "Mountain Bike"} local bikes = createMarker(1183.2487792969, -1314.9769287109, 12.546875, 'cylinder', 1.5, 255, 255, 255, 255) 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 guiSetVisible(MainGui, false) ---------------------------------------------------------------------------------------------------------------- addEventHandler("onClientMarkerHit", bikes, function ( hitElement ) if (hitElement == localPlayer) then 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("Erro: 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) Link to comment
JuegosPato Posted September 10, 2013 Author Share Posted September 10, 2013 local vehicles = {"BMX", "Bike", "Mountain Bike"} local bikes = createMarker(1183.2487792969, -1314.9769287109, 12.546875, 'cylinder', 1.5, 255, 255, 255, 255) 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 guiSetVisible(MainGui, false) ---------------------------------------------------------------------------------------------------------------- addEventHandler("onClientMarkerHit", bikes, function ( hitElement ) if (hitElement == localPlayer) then 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("Erro: 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) Ahora si aparecen los vehiculos, pero, cuando selecciono y toco en "Use" no me da el coche. /debuscript 3: WARNING: tdb/server.lua:2: Bad argument @ 'getElementModel' [Expected element at argument 1, go nil] Link to comment
Sensacion Posted September 10, 2013 Share Posted September 10, 2013 addEvent ( 'spawnBike', true ) addEventHandler ( 'spawnBike', root, function ( model ) id = getVehicleModelFromName( model ) local off = createVehicle ( id, 1183.2487792969, -1314.9769287109, 14.546875, 0, 0, 270 ) setTimer( warpPedIntoVehicle, 100, 1, source, off ) end ) Link to comment
JuegosPato Posted September 10, 2013 Author Share Posted September 10, 2013 addEvent ( 'spawnBike', true ) addEventHandler ( 'spawnBike', root, function ( model ) id = getVehicleModelFromName( model ) local off = createVehicle ( id, 1183.2487792969, -1314.9769287109, 14.546875, 0, 0, 270 ) setTimer( warpPedIntoVehicle, 100, 1, source, off ) end ) Errores nuevos: -Cuando selecciona un Vehiculo y toca el boton "use", te da el coche, pero, no se te cierra el GUI. -Usas un coche y vas por el marker se te habre el GUI. -Podes poner muchos vehiculos y se te bugea todo. Link to comment
Sensacion Posted September 10, 2013 Share Posted September 10, 2013 guiSetVisible isPedInVehicle destroyElement Link to comment
JuegosPato Posted September 10, 2013 Author Share Posted September 10, 2013 guiSetVisible isPedInVehicle destroyElement No entiendo nada , me cambiaste todo el script D:, pero lo intentare. Link to comment
EstrategiaGTA Posted September 10, 2013 Share Posted September 10, 2013 Solo te arregló el script, él te dijo esas funciones para: guiSetVisible --Así harás que cuando seleccione el vehículo y le de click al button, se cierre el GUI isPedInVehicle --Dijiste que no quieres hacer aparecer el GUI cuando están en un vehículo. Con eso haz que si el jugador está en un vehículo, no se abra el GUI. destroyElement --Para destruir el vehículo, supongo Link to comment
JuegosPato Posted September 10, 2013 Author Share Posted September 10, 2013 Solo te arregló el script, él te dijo esas funciones para: guiSetVisible --Así harás que cuando seleccione el vehículo y le de click al button, se cierre el GUI isPedInVehicle --Dijiste que no quieres hacer aparecer el GUI cuando están en un vehículo. Con eso haz que si el jugador está en un vehículo, no se abra el GUI. destroyElement --Para destruir el vehículo, supongo Ya puse la funcion de 'destroyElement' y la de 'guiSetVisible', lo que no me se es 'isPedInVehicle' D: Cuando tengas un vehiculo y vas al marker que no se habra el GUI. Server side. addEvent ( 'spawnBike', true ) addEventHandler ( "spawnBike", getRootElement(), function ( cars ) if isElement ( veh ) then destroyElement ( veh ) end local cn = getVehicleModelFromName ( cars ) local x,y,z = getElementPosition ( source ) local cn2 = getVehicleNameFromModel ( cn ) veh = createVehicle ( cn, x, y, z ) warpPedIntoVehicle ( source, veh ) end ) Client. local vehicles = {"BMX", "Bike", "Mountain Bike"} local bikes = createMarker(1183.2487792969, -1314.9769287109, 12.546875, 'cylinder', 1.5, 255, 255, 255, 255) 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 guiSetVisible(MainGui, false) addEventHandler("onClientMarkerHit", bikes, function ( hitElement ) if (hitElement == localPlayer) then 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 guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) 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("Erro: 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) Link to comment
Recommended Posts