Jump to content

[Help]ayuuda con vehiculos


Felipe Viedma

Recommended Posts

eh estado revisando muchos dias ya este script la primera vez que lo edite todo funciono perfecto bueno despues creando otro panel de vehiculos se me bugio y no funciono mas por favor si me pudieran decir que esta malo

------client-------

Wnd = guiCreateWindow ( 0.4, 0.25, 0.25, 0.5, "Swat Vehicles", true ) 
guiSetAlpha( Wnd, 1 ) 
button = guiCreateButton ( 0.01, 0.8, 0.99, 0.15, "Close", true, Wnd ) 
label = guiCreateLabel ( 0.1, 0.1, 0.9, 0.1, "", true, Wnd ) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
guiWindowSetSizable( Wnd, false ) 
guiWindowSetMovable( Wnd, false ) 
  
    autos = 
            { 
            {"Lancha",430 }, 
            {"Maverick",497 }, 
            {"enforcer",427 }, 
            {"S.W.A.T",601 }, 
            } 
      
    grid = guiCreateGridList(0.01, 0.2, 0.99, 0.5, true, Wnd) 
    guiGridListAddColumn(grid, "Swat", 0.85) 
      
    for i,veh in ipairs(autos) do 
         row = guiGridListAddRow(grid) 
         -- 
         guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) 
         guiGridListSetItemData(grid, row, 1, tostring(veh[2])) 
    end 
      
    function usar() 
         local row, col = guiGridListGetSelectedItem(grid)   
         if (row and col and row ~= -1 and col ~= -1) then 
              local model = tonumber(guiGridListGetItemData(grid, row, 1)) 
              if model ~= "" then 
                   triggerServerEvent("aparecer", localPlayer, model) 
              end 
         end 
    end 
    addEventHandler("onClientDoubleClick", root, usar, false) 
    
    function cerrar() 
    if (source == button) then 
    guiSetVisible(Wnd,false) 
    showCursor(false) 
    end 
    end 
    addEventHandler("onClientGUIClick", button, cerrar) 
    
function showGUI() 
guiSetVisible(Wnd,true) 
showCursor(true) 
end 
addEvent("showGUI",true) 
addEventHandler("showGUI", getRootElement(),showGUI) 

-------server------

s1s = createMarker(459.98159790039,-1981.4075927734,1.3401165008545, "cylinder", 2, 0, 0, 255, 255 ) 
s2s = createMarker( 488.13076782227,-1860.2916259766,29.447389602661, "cylinder", 2, 0, 0, 255, 255 ) 
s3s = createMarker(  416.40319824219,-1901.6784667969,2, "cylinder", 2, 0, 0, 255, 255 ) 
s4s = createMarker( 407.46484375,-1901.2440185547,2, "cylinder", 2, 0, 0, 255, 255 ) 
  
local autos = { } 
  
function aparecer ( id ) 
    local theTeam = getPlayerTeam ( source ) 
    local theTeamName = getTeamName ( theTeam ) 
    if ( theTeamName == "Fuerzas Armadas" ) or ( theTeamName == "S.W.A.T" ) then 
        local x, y, z = getElementPosition ( source ) 
        if isElement ( autos [ source ] ) then 
            destroyElement ( autos [ source ] ) 
        end 
        autos [ source ] = createVehicle ( id, x, y, z + 1 ) 
        setVehicleColor ( autos [ source ], getTeamColor ( theTeam ) ) 
        warpPedIntoVehicle ( source, autos [ source ] ) 
    else 
        outoutChatBox ( "S.W.A.T y fuerzas armadas online", source, 255, 0, 0 ) 
    end 
end 
addEvent ( "aparecer", true ) 
addEventHandler ( "aparecer", root, aparecer ) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if isElement ( autos [ source ] ) then 
            destroyElement ( autos [ source ] ) 
            autos [ source ] = nil 
        end 
    end 
) 
    
function showGUI ( hitPlayer ) 
    if ( source == s1s or source == s2s or source == s3s or source == s4s  ) then 
        local theTeam = getPlayerTeam ( hitPlayer ) 
        local theTeamName = getTeamName ( theTeam ) 
        if ( theTeamName == "Fuerzas Armadas" ) or ( theTeamName == "S.W.A.T" ) then 
            setElementFrozen ( hitPlayer, false ) 
            triggerClientEvent ( hitPlayer, "showGUI", getRootElement(), hitPlayer ) 
        end 
    end 
end 
addEventHandler ( "onMarkerHit",root, showGUI ) 

muchas gracias por la atencion :D

Link to comment

este si me funciona pero al momento de hacer el segundo para SWAT no pasa nada solo se crean los markers

-----client---- 
Wnd = guiCreateWindow ( 0.4, 0.25, 0.25, 0.5, "Police Vehicles", true ) 
guiSetAlpha( Wnd, 1 ) 
button = guiCreateButton ( 0.01, 0.8, 0.99, 0.15, "Close", true, Wnd ) 
label = guiCreateLabel ( 0.1, 0.1, 0.9, 0.1, "Double Click Vehicle to take it.", true, Wnd ) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
guiWindowSetSizable( Wnd, false ) 
guiWindowSetMovable( Wnd, false ) 
  
    vehicles = 
            { 
            {"Moto", 523}, 
            {"Police LS", 596}, 
            {"Police LV", 598}, 
            {"Police Ranger", 599}, 
            } 
      
    grid = guiCreateGridList(0.01, 0.2, 0.99, 0.5, true, Wnd) 
    guiGridListAddColumn(grid, "Vehicles", 0.85) 
      
    for i,veh in ipairs(vehicles) do 
         row = guiGridListAddRow(grid) 
         -- 
         guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) 
         guiGridListSetItemData(grid, row, 1, tostring(veh[2])) 
    end 
      
    function use() 
         local row, col = guiGridListGetSelectedItem(grid)   
         if (row and col and row ~= -1 and col ~= -1) then 
              local model = tonumber(guiGridListGetItemData(grid, row, 1)) 
              if model ~= "" then 
                   triggerServerEvent("CreVehiceP", localPlayer, model) 
              end 
         end 
    end 
    addEventHandler("onClientDoubleClick", root, use, false) 
    
    function close() 
    if (source == button) then 
    guiSetVisible(Wnd,false) 
    showCursor(false) 
    end 
    end 
    addEventHandler("onClientGUIClick", button, close) 
    
function showGUI2p() 
guiSetVisible(Wnd,true) 
showCursor(true) 
end 
addEvent("showGUI2p",true) 
addEventHandler("showGUI2p", getRootElement(), showGUI2p) 

----server------- 
  
markerp = createMarker( 1556.9852294922, -1608.2557373047, 12.3828125, "cylinder", 2, 0, 0, 255, 255 ) 
marker2p = createMarker( 1570.1909179688, -1608.2557373047, 12.3828125, "cylinder", 2, 0, 0, 255, 255 ) 
marker3p = createMarker( 1584.61328125, -1608.2557373047, 12.3828125, "cylinder", 2, 0, 0, 255, 255 ) 
marker4p = createMarker( 1595.1407470703, -1608.2557373047, 12.3828125, "cylinder", 2, 0, 0, 255, 255 ) 
  
local vehicles = { } 
  
function spawnVehP ( id ) 
    local theTeam = getPlayerTeam ( source ) 
    local theTeamName = getTeamName ( theTeam ) 
    if ( theTeamName == "policia" ) or ( theTeamName == "" ) then 
        local x, y, z = getElementPosition ( source ) 
        if isElement ( vehicles [ source ] ) then 
            destroyElement ( vehicles [ source ] ) 
        end 
        vehicles [ source ] = createVehicle ( id, x, y, z + 1 ) 
        setVehicleColor ( vehicles [ source ], getTeamColor ( theTeam ) ) 
        warpPedIntoVehicle ( source, vehicles [ source ] ) 
    else 
        outoutChatBox ( "Only police agents and FBI can get free vehicles from here!", source, 255, 0, 0 ) 
    end 
end 
addEvent ( "CreVehiceP", true ) 
addEventHandler ( "CreVehiceP", root, spawnVehP ) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if isElement ( vehicles [ source ] ) then 
            destroyElement ( vehicles [ source ] ) 
            vehicles [ source ] = nil 
        end 
    end 
) 
    
function showGUIp ( hitPlayer ) 
    if ( source == markerp or source == marker2p or source == marker3p or source == marker4por  ) then 
        local theTeam = getPlayerTeam ( hitPlayer ) 
        local theTeamName = getTeamName ( theTeam ) 
        if ( theTeamName == "policia" ) or ( theTeamName == "" ) then 
            setElementFrozen ( hitPlayer, false ) 
            triggerClientEvent ( hitPlayer, "showGUI2p", getRootElement(), hitPlayer ) 
        end 
    end 
end 
addEventHandler ( "onMarkerHit",root, showGUIp ) 

Link to comment
  • Recently Browsing   0 members

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