Jump to content

Problema


JuegosPato

Recommended Posts

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

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
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
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
  • 1 year later...
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 :S

(No agan caso sobre el getElementModel, era otro resource.)

130909054102583948.png

Link to comment
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
Donde está el onClientMarkerHit o como haces aparecer el gui

Ya puse el

Ya le puse :D, 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
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
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:

130910015158238444.jpg

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

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

:D 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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...