Jump to content

Help With Team Spawners


xXMADEXx

Recommended Posts

Posted

Hey guys!! As some of you may know, i am still a noob at scripting. I'm trying to make a system, where teams (such as swat, mili, misc) have there own spawner's. For some reason if you walk into the free vehicle spawner, it will show the military spawner too. Can somone please help?:

server.lua:

    LSPD = createMarker( 749.77618408203, -2177.5676269531, 12.35, "cylinder", 2, 0, 255, 0, 200 ) 
     
    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 + 1, y, z) 
    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",LSPD,showGUI) 

client.lua:

Wnd = guiCreateWindow(579,245,482,622,"US-RP Free Vehicle System",false) 
guiSetAlpha( Wnd, 1 ) 
guiWindowSetMovable(Wnd,false) 
guiWindowSetSizable(Wnd,false) 
  
button = guiCreateButton(15,566,458,47,"Exit",false,Wnd) 
  
label = guiCreateLabel(127,34,328,41,"Double Click The Vehicle You Wish To Take.",false,Wnd) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
  
    vehicles = 
            { 
            {"troll", 462}, 
            {"VooDoo", 412}, 
            {"Glendale", 466} 
            } 
      
    grid = guiCreateGridList(36,78,421,464,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 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("CreVehice", 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 showGUI2() 
guiSetVisible(Wnd,true) 
showCursor(true) 
end 
addEvent("showGUI2",true) 
addEventHandler("showGUI2", getRootElement(), showGUI2) 

Posted

You are surely using the same event name to show the GUI.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Post the script you use for military spawner.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Post the script you use for military spawner.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

=========================FREE SPAWNER=============================

Server.lua:

    LSPD = createMarker( 1536.2338867188, -1654.8493652344, 12.5, "cylinder", 2, 0, 100, 255, 200 ) 
    Hosp1 = createMarker( 1183.8322753906, -1313.5714111328, 12.5, "cylinder", 2, 0, 100, 255, 200 ) 
    Spawn = createMarker( 1647.9964599609, -2244.6364746094, 12.5, "cylinder", 2, 0, 100, 255, 200 ) 
    Spawnlot = createMarker( 1536.7595214844, -2235.4956054688, 12.7, "cylinder", 2, 0, 100, 255, 200 ) 
    Grovestreet = createMarker( 2490.3369140625, -1665.6422119141, 12.3, "cylinder", 2, 0, 100, 255, 200 ) 
    nearAP = createMarker(1946.6610107422, -2140.8979492188, 12.7, "cylinder", 2, 0, 100, 255, 200 ) 
    park = createMarker(1647.7314453125, -1134.5999755859, 23, "cylinder", 2, 0, 100, 255, 200 ) 
    hosp = createMarker(2000.9978027344, -1446.0225830078, 12.5, "cylinder", 2, 0, 100, 255, 200 ) 
    hosp3 = createMarker(1602.1302490234, 1838.1687011719, 10, "cylinder", 2, 0, 100, 255, 200 ) 
    SFPD = createMarker(-1568.4545898438, 674.07067871094, 6, "cylinder", 2, 0, 100, 255, 200 ) 
    LVAP = createMarker(1706.4786376953, 1454.9436035156, 10, "cylinder", 2, 0, 100, 255, 200 ) 
    LVPD = createMarker(2282.3659667969, 2426.1804199219, 10, "cylinder", 2, 0, 100, 255, 200 ) 
     
    local vehicles = {} 
      
    function spawnFreeVeh(id) 
        local x, y, z = getElementPosition(source) 
        if isElement(vehicles[source]) then destroyElement(vehicles[source]) end 
        vehicles[source] = createVehicle(id, x + 1, y, z) 
    end 
    addEvent("CreVehice",true) 
    addEventHandler("CreVehice", root, spawnFreeVeh) 
      
    addEventHandler("onPlayerQuit", root, 
    function() 
         if isElement(vehicles[source]) then 
              destroyElement(vehicles[source]) 
              vehicles[source] = nil 
         end 
    end) 
     
    function freeGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",LSPD,freeGUI) 
  
    function freeGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",Spawn,freeGUI) 
  
    function freeGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",Hosp1,freeGUI) 
  
    function freeGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",Spawnlot,freeGUI) 
  
    function freeGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",Grovestreet,freeGUI) 
  
    function freeGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",nearAP,freeGUI) 
  
    function freeGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",park,freeGUI) 
  
    function freeGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",hosp,freeGUI) 
  
    function freeGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",hosp3,freeGUI) 
  
    function freeGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",SFPD,freeGUI) 
  
    function freeGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",LVAP,freeGUI) 
  
    function freeGUI(hitPlayer) 
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",LVPD,freeGUI) 

Client.lua:

Wnd = guiCreateWindow(579,245,482,622,"US-RP Free Vehicle System",false) 
guiSetAlpha( Wnd, 1 ) 
guiWindowSetMovable(Wnd,false) 
guiWindowSetSizable(Wnd,false) 
  
button = guiCreateButton(15,566,458,47,"Exit",false,Wnd) 
  
label = guiCreateLabel(127,34,328,41,"Double Click The Vehicle You Wish To Take.",false,Wnd) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
  
    vehicles = 
            { 
            {"Faggio", 462}, 
            {"VooDoo", 412}, 
            {"Glendale", 466} 
            } 
      
    grid = guiCreateGridList(36,78,421,464,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 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("CreVehice", 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 freeGUI() 
guiSetVisible(Wnd,true) 
showCursor(true) 
end 
addEvent("freeGUI",true) 
addEventHandler("freeGUI", getRootElement(), freeGUI) 

=====================================MILITARY SPAWNER==============================

Server.lua:

    LSPD = createMarker( 749.77618408203, -2177.5676269531, 12.2, "cylinder", 2, 0, 255, 0, 200 ) 
     
    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 + 1, y, z) 
    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",LSPD,showGUI) 

Client.lua:

Wnd = guiCreateWindow(579,245,482,622,"US-RP Free Vehicle System",false) 
guiSetAlpha( Wnd, 1 ) 
guiWindowSetMovable(Wnd,false) 
guiWindowSetSizable(Wnd,false) 
  
button = guiCreateButton(15,566,458,47,"Exit",false,Wnd) 
  
label = guiCreateLabel(127,34,328,41,"Double Click The Vehicle You Wish To Take.",false,Wnd) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
  
    vehicles = 
            { 
            {"Patriot", 470}, 
            {"Barracks", 433}, 
            {"Police LS", 596}, 
            {"Police LV", 598}, 
            {"Police SF", 597}, 
            } 
      
    grid = guiCreateGridList(36,78,421,464,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 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("CreVehice", 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 showGUI2() 
guiSetVisible(Wnd,true) 
showCursor(true) 
end 
addEvent("showGUI2",true) 
addEventHandler("showGUI2", getRootElement(), showGUI2) 

(thanks Castillo :) )

Posted

See: "showGUI2" you use the same event on both of them.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You can of course, but this method is really bad, you should create a table with the coordinates, vehicles that'll appear on the grid list, then you can create all the markers and assing them the vehicles ( could be either element data, or another table ), then when hit the marker, send them to the client side, show the GUI and add the vehicles to the grid list.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You can, but it would be inefficient.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I already gave you an idea, you can use it or not, read about tables at lua.org.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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