Jump to content

Como hacer esto.


JuegosPato

Recommended Posts

Posted
guiCreateWindow 
guiCreateGridList 
guiCreateButton 
guiGridListGetSelectedItem 
guiGridListGetItemText 
triggerServerEvent 
getVehicleModelFromName 
createVehicle 
warpPedIntoVehicle 

Posted
guiCreateWindow 
guiCreateGridList 
guiCreateButton 
guiGridListGetSelectedItem 
guiGridListGetItemText 
triggerServerEvent 
getVehicleModelFromName 
createVehicle 
warpPedIntoVehicle 

Algo dificil para mi, pero lo intentare.

Posted

Este es el gui.Pero me complica algo con las otras funciones :S

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(391,195,507,430,"Vehicles",false) 
GUIEditor_Button[1] = guiCreateButton(0.0276,0.8186,0.3846,0.1465,"Use",true,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(0.5819,0.8186,0.3846,0.1465,"Close",true,GUIEditor_Window[1]) 
GUIEditor_Grid[1] = guiCreateGridList(0.0217,0.0558,0.9546,0.7419,true,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
  
guiGridListAddColumn(GUIEditor_Grid[1],"Vehicle name:",0.2) 
  
for i = 1, 1 do 
    guiGridListAddRow(GUIEditor_Grid[1]) 
end 
  
guiGridListSetItemText(GUIEditor_Grid[1],0,1,"BMX") 

Posted
Este es el gui.Pero me complica algo con las otras funciones :S
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(391,195,507,430,"Vehicles",false) 
GUIEditor_Button[1] = guiCreateButton(0.0276,0.8186,0.3846,0.1465,"Use",true,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(0.5819,0.8186,0.3846,0.1465,"Close",true,GUIEditor_Window[1]) 
GUIEditor_Grid[1] = guiCreateGridList(0.0217,0.0558,0.9546,0.7419,true,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
  
guiGridListAddColumn(GUIEditor_Grid[1],"Vehicle name:",0.2) 
  
for i = 1, 1 do 
    guiGridListAddRow(GUIEditor_Grid[1]) 
end 
  
guiGridListSetItemText(GUIEditor_Grid[1],0,1,"BMX") 

Si ese es el GUI (intentando copiar a CIT eh) xD pero yo no digo nada, ahora utiliza las otras funciones para crear los vehhicles :)

Posted
Este es el gui.Pero me complica algo con las otras funciones :S
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(391,195,507,430,"Vehicles",false) 
GUIEditor_Button[1] = guiCreateButton(0.0276,0.8186,0.3846,0.1465,"Use",true,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(0.5819,0.8186,0.3846,0.1465,"Close",true,GUIEditor_Window[1]) 
GUIEditor_Grid[1] = guiCreateGridList(0.0217,0.0558,0.9546,0.7419,true,GUIEditor_Window[1]) 
guiGridListSetSelectionMode(GUIEditor_Grid[1],2) 
  
guiGridListAddColumn(GUIEditor_Grid[1],"Vehicle name:",0.2) 
  
for i = 1, 1 do 
    guiGridListAddRow(GUIEditor_Grid[1]) 
end 
  
guiGridListSetItemText(GUIEditor_Grid[1],0,1,"BMX") 

Si ese es el GUI (intentando copiar a CIT eh) xD pero yo no digo nada, ahora utiliza las otras funciones para crear los vehhicles :)

xD, No, no quiero copiar al Cit, al Saur, ni nada de eso, (Pues en realidad si), me gusto la idea de eso.Porque evita que aya más lag en el servidor.

:C Me complican las funciones D:

Posted

C:

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(391,195,507,430,"Vehicles",false) 
GUIEditor_Button[1] = guiCreateButton(0.0276,0.8186,0.3846,0.1465,"Use",true,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(0.5819,0.8186,0.3846,0.1465,"Close",true,GUIEditor_Window[1]) 
GUIEditor_Grid[1] = guiCreateGridList(0.0217,0.0558,0.9546,0.7419,true,GUIEditor_Window[1]) 
  
col = guiGridListAddColumn(GUIEditor_Grid[1],"Vehicle name:",0.2) 
  
addEventHandler("onClientResourceStart",resourceRoot,function() 
local row = guiGridListAddRow(GUIEditor_Grid[1]) 
guiGridListSetItemText(GUIEditor_Grid[1],row,col,"BMX",false,false) 
end 
) 

Posted
C:
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Grid = {} 
  
GUIEditor_Window[1] = guiCreateWindow(391,195,507,430,"Vehicles",false) 
GUIEditor_Button[1] = guiCreateButton(0.0276,0.8186,0.3846,0.1465,"Use",true,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(0.5819,0.8186,0.3846,0.1465,"Close",true,GUIEditor_Window[1]) 
GUIEditor_Grid[1] = guiCreateGridList(0.0217,0.0558,0.9546,0.7419,true,GUIEditor_Window[1]) 
  
col = guiGridListAddColumn(GUIEditor_Grid[1],"Vehicle name:",0.2) 
  
addEventHandler("onClientResourceStart",resourceRoot,function() 
local row = guiGridListAddRow(GUIEditor_Grid[1]) 
guiGridListSetItemText(GUIEditor_Grid[1],row,col,"BMX",false,false) 
end 
) 

Gracias Mota, pero ya lo solucione.

El problema que tengo ahora es:

-No le da el vehículo cuando lo selecciona.

-Cuando vas corriendo y tocas el marker, el personaje anda corriendo con el GUI.

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("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) 
  

Posted
addEventHandler("onClientMarkerLeave", bikes, 
    function ( leaveElement ) 
        if (leaveElement == localPlayer) then 
                guiSetVisible(MainGui, false) 
                showCursor(false) 
                guiSetInputEnabled(false) 
            end 
end 
) 

si no funciona dime lo hize a la rapida :P

Posted
addEventHandler("onClientMarkerLeave", bikes, 
    function ( leaveElement ) 
        if (leaveElement == localPlayer) then 
                guiSetVisible(MainGui, false) 
                showCursor(false) 
                guiSetInputEnabled(false) 
            end 
end 
) 

si no funciona dime lo hize a la rapida :P

No.No funcionó.

No se.Creo que puse mal en la linea.

Era así, no?

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) 

Posted

me equivoque en 1 argumento :3

  
addEventHandler("onClientMarkerLeave", bikes, 
    function ( leftPlayer,matchingDimension ) 
        if (leaveElement == localPlayer) then 
                guiSetVisible(MainGui, false) 
                showCursor(false) 
                guiSetInputEnabled(false) 
            end 
end 
) 
  

proba asi

Posted
me equivoque en 1 argumento :3
  
addEventHandler("onClientMarkerLeave", bikes, 
    function ( leftPlayer,matchingDimension ) 
        if (leaveElement == localPlayer) then 
                guiSetVisible(MainGui, false) 
                showCursor(false) 
                guiSetInputEnabled(false) 
            end 
end 
) 
  

proba asi

No. No aparece el gui.

Posted
  
addEventHandler("onClientMarkerLeave", bikes, 
    function ( leftPlayer,matchingDimension ) 
        if (leaveElement == localPlayer) then 
                guiSetVisible(MainGui, false) 
                showCursor(false) 
                guiSetInputEnabled(false) 
            end 
end 
) 
  

este, por ejemplo el argumento que usas se llama leftPlayer, pero tu comparas si un argumento (no definido) llamado 'leaveElement' es igual al localPlayer.

Posted
  
addEventHandler("onClientMarkerLeave", bikes, 
    function ( leftPlayer,matchingDimension ) 
        if (leaveElement == localPlayer) then 
                guiSetVisible(MainGui, false) 
                showCursor(false) 
                guiSetInputEnabled(false) 
            end 
end 
) 
  

este, por ejemplo el argumento que usas se llama leftPlayer, pero tu comparas si un argumento (no definido) llamado 'leaveElement' es igual al localPlayer.

:S Mmm.

Yo solamente quería solucionar sobre el botón del "Use" porque seleccionaba a un vehículo y después tocabas el botón y no aparecía, solamente quiero ayuda en eso.

Posted

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("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) 

  • Recently Browsing   0 members

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