mint3d Posted May 12, 2013 Posted May 12, 2013 I have a car spawner script but when i walk into the marker no gui shows up help 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 =( ("Infernus", 411) 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) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then guiSetVisible(Wnd,true) showCursor(true) end end addEvent("showGUI2",true) addEventHandler("showGUI2", getRootElement(), showGUI2)
mint3d Posted May 12, 2013 Author Posted May 12, 2013 f = createMarker( x,y,z, "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)
Castillo Posted May 12, 2013 Posted May 12, 2013 addEventHandler("onMarkerHit",t,showGUI) You are using the variable "t", but your marker variable is "f".
dugasz1 Posted May 12, 2013 Posted May 12, 2013 function showGUI2(hitElement) guiSetVisible(Wnd,true) showCursor(true) end Try it whitout the if. Just a idea
dugasz1 Posted May 12, 2013 Posted May 12, 2013 (edited) addEventHandler("showGUI2", getLocalPlayer(), showGUI2) oops.I want to write this in my last comment too,just delet this line by mistake Edited May 12, 2013 by Guest
dugasz1 Posted May 12, 2013 Posted May 12, 2013 No sorry don't delete just replace the 2. argument to getLocalPlayer() (I'm writing from mobile it's hard. i edited my fail post)
Castillo Posted May 12, 2013 Posted May 12, 2013 -- client side: function showGUI2 ( ) guiSetVisible ( Wnd, true ) showCursor ( true ) end addEvent ( "showGUI2", true ) addEventHandler ( "showGUI2", getRootElement(), showGUI2 ) -- server side: function showGUI ( hitPlayer ) if ( getElementType ( hitPlayer ) == "player" ) then triggerClientEvent ( hitPlayer, "showGUI2", hitPlayer ) end end addEventHandler ( "onMarkerHit", f, showGUI ) P.S: Stop double-triple posting, use the "EDIT" button.
فاّرس Posted May 13, 2013 Posted May 13, 2013 try this : addEvent("showGUI2",true) function open() guiSetVisible(Wnd, true) showCursor(true) end addEventHandler("showGUI2", getRootElement(),open) -- Server function showGUI2(player) triggerClientEvent(player,"showGUI2", player) end addEventHandler("onMarkerHit",f,showGUI2)
Castillo Posted May 13, 2013 Posted May 13, 2013 That's because the problem is not on that part, you have another script errors on the client side. 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 = { { "Infernus", 411 } } 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 triggerServerEvent("CreVehice", localPlayer, model) end end end addEventHandler("onClientGUIClick", button2, use2, false) function close2() if (source == button2) then 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 ( ) guiSetVisible ( Wnd, true ) showCursor ( true ) end addEvent ( "showGUI2", true ) addEventHandler ( "showGUI2", getRootElement(), showGUI2 )
فاّرس Posted May 13, 2013 Posted May 13, 2013 That's because the problem is not on that part, you have another script errors on the client side. 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 = { { "Infernus", 411 } } 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 triggerServerEvent("CreVehice", localPlayer, model) end end end addEventHandler("onClientGUIClick", button2, use2, false) function close2() if (source == button2) then 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 ( ) guiSetVisible ( Wnd, true ) showCursor ( true ) end addEvent ( "showGUI2", true ) addEventHandler ( "showGUI2", getRootElement(), showGUI2 ) Line 45 and 53 , why you wrote name of the button and you already difend this.
Castillo Posted May 13, 2013 Posted May 13, 2013 That's because the problem is not on that part, you have another script errors on the client side. 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 = { { "Infernus", 411 } } 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 triggerServerEvent("CreVehice", localPlayer, model) end end end addEventHandler("onClientGUIClick", button2, use2, false) function close2() if (source == button2) then 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 ( ) guiSetVisible ( Wnd, true ) showCursor ( true ) end addEvent ( "showGUI2", true ) addEventHandler ( "showGUI2", getRootElement(), showGUI2 ) Line 45 and 53 , why you wrote name of the button and you already difend this. I didn't change how he wrote it, I just fixed the script errors.
mint3d Posted May 15, 2013 Author Posted May 15, 2013 Ok the script works but how do i make it so its only for SWAT
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