Jump to content

GUI and Spawn Help


mint3d

Recommended Posts

Ok so I made a car spawner script but I need help I need help on adding teams to some of them for example you can only use a certain one if your in a certain team heres the code

Client

    Wnd = guiCreateWindow(550,100,382,450,"Vehicle System",false) 
    guiSetAlpha( Wnd, 1 ) 
    guiWindowSetMovable(Wnd,true) 
    guiWindowSetSizable(Wnd,false) 
      
    button = guiCreateButton(36,400,110,47,"Exit",false,Wnd) 
    button2 = guiCreateButton(249,400,110,47,"Spawn",false,Wnd) 
      
    label2 = guiCreateLabel(127,47,242,15,'',false,Wnd) 
    label = guiCreateLabel(127,34,242,15,"Click on the vehicle you want",false,Wnd) 
    guiLabelSetVerticalAlign(label2,"center") 
    guiLabelSetHorizontalAlign(label2,"center",false) 
    showCursor(false) 
    guiSetVisible( Wnd, false ) 
      
        vehicles = 
                { 
                {"Bmx", 481},{"Mountain Bike", 510},{"Faggio", 462},--format "carname", "carid" 
                 
                } 
          
        grid = guiCreateGridList(36,78,300,300,false,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 use2() 
             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 
                  --takePlayerMoney (thePlayer, 1000) 
                  --takePlayerMoney (player, 1000) 
                       triggerServerEvent("CreVehice", localPlayer, model) 
                  end 
             end 
        end 
        addEventHandler("onClientGUIClick", button2, use2, false) 
         
        function close2() 
        if (source == button2) then 
        --takePlayerMoney (localPlayer, 1000) 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
        end 
        end 
        addEventHandler("onClientGUIClick", button2, close2) 
         
        
        function close() 
        if (source == button) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
        end 
        end 
        addEventHandler("onClientGUIClick", button, close) 
        
    function showGUI2(hitElement) 
  
    guiSetVisible(Wnd,true) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then  
    showCursor(true) 
    end 
    end 
    addEvent("showGUI2",true) 
    addEventHandler("showGUI2", getRootElement(), showGUI2) 

Server

  
    t = createMarker( 2030.01,1545.35,9.5, "cylinder", 2, 0, 100, 255, 100 )  
    f = createMarker( 2482.7263183594,-1686.0427246094,12.8, "cylinder", 2, 0, 100, 255, 100 ) 
    g = createMarker( 2001.3251953125,-1444,12.8, "cylinder", 2, 0, 100, 255, 100 ) 
    h = createMarker( 1184.890625,-1319,12.8, "cylinder", 2, 0, 100, 255, 100 ) 
    j = createMarker( 1624.0262451172,1818,9.6, "cylinder", 2, 0, 100, 255, 100 ) 
    k = createMarker( 1701.2663574219,1439,9.6, "cylinder", 2, 0, 100, 255, 100 ) 
    l = createMarker( -2662.2287597656,600,12.8, "cylinder", 2, 0, 100, 255, 100 ) 
    m = createMarker( -2204.9958496094,1694,7.2, "cylinder", 2, 0, 100, 255, 100 ) 
     
    local vehicles = {} 
      
    function spawnVeh(id) 
        local x, y, z = getElementPosition(source) 
        if isElement(vehicles[source]) then destroyElement(vehicles[source]) end 
        vehicles[source] = createVehicle(id, x + 3, y, z) 
        warpPedIntoVehicle ( source, vehicles[source] )  
    end 
    addEvent("CreVehice",true) 
    addEventHandler("CreVehice", root, spawnVeh) 
      
    addEventHandler("onPlayerQuit", root, 
    function() 
         if isElement(vehicles[source]) then 
              destroyElement(vehicles[source]) 
              vehicles[source] = nil 
         end 
    end) 
  
    
function showGUI(hitPlayer) 
  
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",t,showGUI) 
  
function showGUI(hitPlayer) 
  
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",f,showGUI) 
  
function showGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",g,showGUI) 
  
function showGUI(hitPlayer) 
  
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMearkerHit",h,showGUI) 
  
function showGUI(hitPlayer) 
  
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",j,showGUI) 
  
function showGUI(hitPlayer) 
  
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",k,showGUI) 
  
function showGUI(hitPlayer) 
  
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",l,showGUI) 
  
function showGUI(hitPlayer) 
  
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",m,showGUI) 
  
  

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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