xXMADEXx Posted November 12, 2012 Share Posted November 12, 2012 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) Link to comment
Castillo Posted November 13, 2012 Share Posted November 13, 2012 You are surely using the same event name to show the GUI. Link to comment
xXMADEXx Posted November 13, 2012 Author Share Posted November 13, 2012 You are surely using the same event name to show the GUI. What is that? Do you think you can help me? Link to comment
Castillo Posted November 13, 2012 Share Posted November 13, 2012 Post the script you use for military spawner. Link to comment
Castillo Posted November 13, 2012 Share Posted November 13, 2012 Post the script you use for military spawner. Link to comment
xXMADEXx Posted November 13, 2012 Author Share Posted November 13, 2012 =========================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 ) Link to comment
Castillo Posted November 13, 2012 Share Posted November 13, 2012 See: "showGUI2" you use the same event on both of them. Link to comment
xXMADEXx Posted November 13, 2012 Author Share Posted November 13, 2012 See: "showGUI2" you use the same event on both of them. Can i switch it to "showGUI3"? Link to comment
Castillo Posted November 13, 2012 Share Posted November 13, 2012 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. Link to comment
xXMADEXx Posted November 13, 2012 Author Share Posted November 13, 2012 so, could i just make a script for each spawner? Link to comment
Castillo Posted November 13, 2012 Share Posted November 13, 2012 You can, but it would be inefficient. Link to comment
xXMADEXx Posted November 13, 2012 Author Share Posted November 13, 2012 You can, but it would be inefficient. damn.... Can you add me on skype so you can join my server and help me out? (if you want my skype is topKIDminer) Link to comment
Castillo Posted November 13, 2012 Share Posted November 13, 2012 I already gave you an idea, you can use it or not, read about tables at lua.org. Link to comment
xXMADEXx Posted November 13, 2012 Author Share Posted November 13, 2012 I already gave you an idea, you can use it or not, read about tables at lua.org. Kinda wishing i was a better scripter right now (facepalm) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now