SpriN' Posted February 1, 2012 Share Posted February 1, 2012 I want to make a marker for SWAT job, but I got problem, here's my script local marker = createMarker (1282, -1664.5999755859, 12.5, "cylinder", 2, 255, 255, 255, 255) function createSWATTeam () SWATTeam = createTeam ("SWAT Team", 0, 0, 255) end addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), createSWATTeam) function GUIEditor_Window() GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} GUIEditor_Window[1] = guiCreateWindow(1031,232,301,397,"SWAT job",false) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,GUIEditor_Window[1]) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,GUIEditor_Window[1]) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"To take SWAT team job, press Take job.\n\nIf you don't want to, press Cancel.\n\n\nNOTE: You need to be into SWAT team group.",false,GUIEditor_Window[1]) end -- show GUI -- function showWindow () getVisible = guiGetVisible (GUIEditor_Window[1]) playerName = getPlayerName ( getLocalPlayer() ) if (getVisible == true) then guiSetVisible (GUIEditor_Window[1], false) showCursor (false) end if (getVisible == false) then guiSetVisible (GUIEditor_Window[1], true) showCursor (true) end end addEventHandler ("onMarkerHit", marker, showWindow) -- Remove GUI -- function closeWindow () if guiGetVisible(GUIEditor_Window[1]) == false then guiSetVisible(GUIEditor_Window[1], true) end end addEventHandler("onClientGUIClick", cancelButton, closeWindow) and this is the problem: Starting SWATWARNING: SWAT\marker.lua:42: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] SWAT restarted successfully ERROR: SWAT\marker.lua:23: attempt to index global 'GUIEditor_Window' (a function value) Link to comment
Castillo Posted February 1, 2012 Share Posted February 1, 2012 -- client side: local marker = createMarker (1282, -1664.5999755859, 12.5, "cylinder", 2, 255, 255, 255, 255) function GUIEditor_Window() GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} GUIEditor_Window[1] = guiCreateWindow(1031,232,301,397,"SWAT job",false) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,GUIEditor_Window[1]) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,GUIEditor_Window[1]) addEventHandler("onClientGUIClick", GUIEditor_Button[2], closeWindow, false) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"To take SWAT team job, press Take job.\n\nIf you don't want to, press Cancel.\n\n\nNOTE: You need to be into SWAT team group.",false,GUIEditor_Window[1]) end -- show GUI -- function showWindow (hitPlayer) if (hitPlayer ~= localPlayer) then return end local getVisible = guiGetVisible (GUIEditor_Window[1]) if (getVisible) then guiSetVisible (GUIEditor_Window[1], false) showCursor (false) else guiSetVisible (GUIEditor_Window[1], true) showCursor (true) end end addEventHandler ("onClientMarkerHit", marker, showWindow) -- Remove GUI -- function closeWindow () if guiGetVisible(GUIEditor_Window[1]) then guiSetVisible(GUIEditor_Window[1], false) showCursor(false) end end -- server side: function createSWATTeam () SWATTeam = createTeam ("SWAT Team", 0, 0, 255) end addEventHandler ("onResourceStart", resourceRoot, createSWATTeam) Link to comment
SpriN' Posted February 1, 2012 Author Share Posted February 1, 2012 Resolved, thanks for the help. Link to comment
SpriN' Posted February 2, 2012 Author Share Posted February 2, 2012 Well, I got another little problem with the GUIEditor_Button[1], I just want to make it when you click at it you change to SWAT Team and your skin change to SWAT skin.. I tried to add this but doesn't work addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function joinTeam (source) local SWATTeam = getTeamFromName ("SWAT Team") if (SWATTeam) then setPlayerTeam (source, "SWAT Team" ) setElementModel (thePlayer, 217) end end end Link to comment
TAPL Posted February 2, 2012 Share Posted February 2, 2012 Client-Side function joinTeam() triggerServerEvent("setSWAT",localPlayer) end addEventHandler("onClientGUIClick", GUIEditor_Button[1], joinTeam, false) Server-Side function createSWATTeam () SWATTeam = createTeam ("SWAT Team", 0, 0, 255) end addEventHandler ("onResourceStart", resourceRoot, createSWATTeam) function joinSWAT() setPlayerTeam(source,SWATTeam) setElementModel(source,217) end addEvent("setSWAT", true) addEventHandler("setSWAT",root,joinSWAT) Link to comment
SpriN' Posted February 2, 2012 Author Share Posted February 2, 2012 The gui doesn't appear when I use it like that: Client-side local marker = createMarker( 1282, -1664.5999755859, 12.5, "Cylinder", 2, 255, 255, 255, 255, 100, getRootElement()) function swatjob(hitElement) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} if getElementType( hitElement ) == "player" and hitElement == getLocalPlayer() then if ( guiGetVisible (windowjob) == true ) then guiSetVisible (windowjob, false ) else guiSetVisible (windowjob, false ) windowjob = guiCreateWindow(1031,232,301,397,"SWAT job",false) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,windowjob) addEventHandler("onClientGUIClick", GUIEditor_Button[2], closeWindow, false) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"To take SWAT team job, press Take job.\n\nIf you don't want to, press Cancel.\n\n\nNOTE: You need to be into SWAT team group.",false,windowjob) addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeswatWindow, false) addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) showCursor(true) end end end function joinTeam() triggerServerEvent("setSWAT",localPlayer) end function removeswatWindow() guiSetVisible(windowjob, false) showCursor(false) end Server-Side function createSWATTeam () SWATTeam = createTeam ("SWAT Team", 0, 0, 255) end addEventHandler ("onResourceStart", resourceRoot, createSWATTeam) function joinSWAT() setPlayerTeam(source,SWATTeam) setElementModel(source,285) end addEvent("setSWAT", true) addEventHandler("setSWAT",root,joinSWAT) and it's appear when I use it like that: local marker = createMarker( 1282, -1664.5999755859, 12.5, "Cylinder", 2, 255, 255, 255, 255, 100, getRootElement()) function swatjob(hitElement) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} if getElementType( hitElement ) == "player" and hitElement == getLocalPlayer() then if ( guiGetVisible (windowjob) == true ) then guiSetVisible (windowjob, false ) else guiSetVisible (windowjob, false ) windowjob = guiCreateWindow(1031,232,301,397,"SWAT job",false) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,windowjob) addEventHandler("onClientGUIClick", GUIEditor_Button[2], closeWindow, false) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"To take SWAT team job, press Take job.\n\nIf you don't want to, press Cancel.\n\n\nNOTE: You need to be into SWAT team group.",false,windowjob) addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeswatWindow, false) addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) showCursor(true) end end end function joinTeam (source) local SWATTeam = getTeamFromName ("SWAT Team") if (SWATTeam) then outputChatBox ( "You are now SWAT.",source, 0, 255, 0 ) setPlayerTeam (source, SWATTeam) end end addEventHandler("onClientMarkerHit", marker, swatjob) function removeswatWindow() guiSetVisible(windowjob, false) showCursor(false) end but the Take job button doesn't work Link to comment
TAPL Posted February 2, 2012 Share Posted February 2, 2012 Client-side local marker = createMarker( 1282, -1664.5999755859, 12.5, "Cylinder", 2, 255, 255, 255, 255) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} windowjob = guiCreateWindow(1031,232,301,397,"SWAT job",false) guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,windowjob) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"To take SWAT team job, press Take job.\n\nIf you don't want to, press Cancel.\n\n\nNOTE: You need to be into SWAT team group.",false,windowjob) function swatjob(hitElement) if getElementType(hitElement) == "player" then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, swatjob) function swatjobleave(leaveElement) if getElementType(leaveElement) == "player" then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, swatjobleave) function joinTeam() triggerServerEvent("setSWAT",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeswatWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeswatWindow, false) Server-Side function createSWATTeam () SWATTeam = createTeam ("SWAT Team", 0, 0, 255) end addEventHandler ("onResourceStart", resourceRoot, createSWATTeam) function joinSWAT() setPlayerTeam(source,SWATTeam) setElementModel(source,285) outputChatBox("You are now SWAT.",source,0,255,0) end addEvent("setSWAT", true) addEventHandler("setSWAT",root,joinSWAT) Link to comment
SpriN' Posted February 2, 2012 Author Share Posted February 2, 2012 Resolved, thank you. 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