xeon17 Posted September 24, 2014 Author Share Posted September 24, 2014 if I use onClientResourceStart I will not have a random image entering the marker. In other buttons I also use guiSetVisible, and have no problem Link to comment
Anubhav Posted September 24, 2014 Share Posted September 24, 2014 --[[---------------------------------------------------- -- client script main -- @author Banex -- @update 22/09/2014 ----------------------------------------------------]]-- local sx,sy = guiGetScreenSize() local px,py = 1600,900 local x,y = (sx/px), (sy/py) local Menus = { { "gfx/images/menu.png" }, { "gfx/images/menu2.png" }, { "gfx/images/menu3.png" } } local random = math.random(#Menus) local interiors = { [5] = true,[9] = true,[10] = true,[7] = true,[6] = true } function ShowGUI( hitPlayer ) Background = guiCreateStaticImage(x*200, y*240, 606, 340,table.concat(Menus[random]), false) Button2 = guiCreateStaticImage(370, 80, 130.32, 61.92,"gfx/images/button-low.png",false,Background) Button3 = guiCreateStaticImage(320, 150, 213.96096, 61.9704, "gfx/images/button-mediun.png", false, Background) Button4 = guiCreateStaticImage(380, 220, 100.2, 75.6, "gfx/images/button-big.png", false, Background) Button22 = guiCreateStaticImage(370, 80, 130.32, 61.92,"gfx/images/button-low2.png",false,Background) Button33 = guiCreateStaticImage(320, 150, 213.96096, 61.9704, "gfx/images/button-mediun2.png", false, Background) Button44 = guiCreateStaticImage(380, 220, 100.2, 75.6, "gfx/images/button-big2.png", false, Background) Close2 = guiCreateLabel(578,10,15,15,"✖", false, Background ) Close = guiCreateLabel(580,8,15,15,"✖", false, Background ) Button222 = guiCreateStaticImage(370, 80, 130.32, 61.92,"gfx/images/button.png",false,Background) Button333 = guiCreateStaticImage(320, 150, 213.96096, 61.9704, "gfx/images/button.png", false, Background) Button444 = guiCreateStaticImage(380, 220, 100.2, 75.6, "gfx/images/button.png", false, Background) guiLabelSetColor(Close2,0,0,0) guiSetVisible (Button22, false ) guiSetVisible (Button33, false ) guiSetVisible (Button44, false ) guiSetVisible (Close2, false ) showCursor( true ) addEventHandler("onClientGUIClick", Close, function() showCursor( false ) guiSetVisible(Background, false) end ) addEventHandler("onClientGUIClick", Close2, function() showCursor( false ) guiSetVisible(Background, false) end ) end addEvent("showGUI",true) addEventHandler("showGUI",getRootElement(),ShowGUI) Link to comment
xeon17 Posted September 24, 2014 Author Share Posted September 24, 2014 not working, no errors in debugscript Link to comment
Mr_Moose Posted September 24, 2014 Share Posted September 24, 2014 You should create the "Background" static image in the root of your script and then hide it, the function ShowGUI should only make the GUI and the cursor visible, as it is now you're making a new GUI every time you hit the marker. Link to comment
xeon17 Posted September 24, 2014 Author Share Posted September 24, 2014 You should create the "Background" static image in the root of your script and then hide it, the function ShowGUI should only make the GUI and the cursor visible, as it is now you're making a new GUI every time you hit the marker. How Link to comment
Mr_Moose Posted September 24, 2014 Share Posted September 24, 2014 Background = guiCreateStaticImage(x*200, y*240, 606, 340,table.concat(Menus[random]), false) Button2 = guiCreateStaticImage(370, 80, 130.32, 61.92,"gfx/images/button-low.png",false,Background) Button3 = guiCreateStaticImage(320, 150, 213.96096, 61.9704, "gfx/images/button-mediun.png", false, Background) Button4 = guiCreateStaticImage(380, 220, 100.2, 75.6, "gfx/images/button-big.png", false, Background) Button22 = guiCreateStaticImage(370, 80, 130.32, 61.92,"gfx/images/button-low2.png",false,Background) Button33 = guiCreateStaticImage(320, 150, 213.96096, 61.9704, "gfx/images/button-mediun2.png", false, Background) Button44 = guiCreateStaticImage(380, 220, 100.2, 75.6, "gfx/images/button-big2.png", false, Background) Close2 = guiCreateLabel(578,10,15,15,"✖", false, Background ) Close = guiCreateLabel(580,8,15,15,"✖", false, Background ) Button222 = guiCreateStaticImage(370, 80, 130.32, 61.92,"gfx/images/button.png",false,Background) Button333 = guiCreateStaticImage(320, 150, 213.96096, 61.9704, "gfx/images/button.png", false, Background) Button444 = guiCreateStaticImage(380, 220, 100.2, 75.6, "gfx/images/button.png", false, Background) guiLabelSetColor(Close2,0,0,0) guiSetVisible (Background, false ) showCursor( false ) addEventHandler("onClientGUIClick", Close, function() showCursor( false ) guiSetVisible(Background, false) end) addEventHandler("onClientGUIClick", Close2, function() showCursor( false ) guiSetVisible(Background, false) end) function ShowGUI( hitPlayer ) showCursor( true ) guiSetVisible(Background, true) end addEvent("showGUI",true) addEventHandler("showGUI",getRootElement(),ShowGUI) Link to comment
xeon17 Posted September 24, 2014 Author Share Posted September 24, 2014 --[[---------------------------------------------------- -- client script main -- @author Banex -- @update 22/09/2014 ----------------------------------------------------]]-- local sx,sy = guiGetScreenSize() local px,py = 1600,900 local x,y = (sx/px), (sy/py) local Menus = { { "gfx/images/menu.png" }, { "gfx/images/menu2.png" }, { "gfx/images/menu3.png" } } local random = math.random(#Menus) local interiors = { [5] = true,[9] = true,[10] = true,[7] = true,[6] = true } function ShowGUI() Background = guiCreateStaticImage(x*200, y*240, 606, 340,table.concat(Menus[random]), false) Button2 = guiCreateStaticImage(370, 80, 130.32, 61.92,"gfx/images/button-low.png",false,Background) Button3 = guiCreateStaticImage(320, 150, 213.96096, 61.9704, "gfx/images/button-mediun.png", false, Background) Button4 = guiCreateStaticImage(380, 220, 100.2, 75.6, "gfx/images/button-big.png", false, Background) Button22 = guiCreateStaticImage(370, 80, 130.32, 61.92,"gfx/images/button-low2.png",false,Background) Button33 = guiCreateStaticImage(320, 150, 213.96096, 61.9704, "gfx/images/button-mediun2.png", false, Background) Button44 = guiCreateStaticImage(380, 220, 100.2, 75.6, "gfx/images/button-big2.png", false, Background) Close2 = guiCreateLabel(578,10,15,15,"✖", false, Background ) Close = guiCreateLabel(580,8,15,15,"✖", false, Background ) Button222 = guiCreateStaticImage(370, 80, 130.32, 61.92,"gfx/images/button.png",false,Background) Button333 = guiCreateStaticImage(320, 150, 213.96096, 61.9704, "gfx/images/button.png", false, Background) Button444 = guiCreateStaticImage(380, 220, 100.2, 75.6, "gfx/images/button.png", false, Background) end guiLabelSetColor(Close2,0,0,0) guiSetVisible (Background, false ) showCursor( false ) addEventHandler("onClientGUIClick", Close, function() showCursor( false ) guiSetVisible(Background, false) end) addEventHandler("onClientGUIClick", Close2, function() showCursor( false ) guiSetVisible(Background, false) end) function ShowGUI( hitPlayer ) showCursor( true ) guiSetVisible(Background, true) end addEvent("showGUI",true) addEventHandler("showGUI",getRootElement(),ShowGUI) addEventHandler("onClientMouseEnter",root, function () if ( source == Button222 ) then playSound("gfx/sounds/click.mp3") guiSetVisible (Button2, false ) guiSetVisible (Button22, true ) elseif ( source == Button333 ) then playSound("gfx/sounds/click.mp3") guiSetVisible (Button3, false ) guiSetVisible (Button33, true ) elseif ( source == Button444 ) then playSound("gfx/sounds/click.mp3") guiSetVisible (Button4, false ) guiSetVisible (Button44, true ) elseif ( source == Close ) then playSound("gfx/sounds/click.mp3") guiSetVisible (Close2, true ) end end) addEventHandler( "onClientMouseLeave", root, function () if ( source == Button222 ) then guiSetVisible (Button2, true ) guiSetVisible (Button22, false ) elseif ( source == Button333 ) then guiSetVisible (Button3, true ) guiSetVisible (Button33, false ) elseif ( source == Button444 ) then guiSetVisible (Button4, true ) guiSetVisible (Button44, false ) elseif ( source == Close ) then guiSetVisible (Close2, false ) end end) addEventHandler ("onClientGUIClick", root, function() if ( source == Close ) or ( source == Close2 ) then guiSetVisible (Background, false ) showCursor ( false ) elseif ( source == Button222 ) then triggerServerEvent("Low",getLocalPlayer()) elseif ( source == Button333 ) then triggerServerEvent("Medium",getLocalPlayer()) elseif ( source == Button444 ) then triggerServerEvent("Big",getLocalPlayer()) end end) markers = { { 373.9, -118.8, 1000.4, 5, 5 }, { 373.9, -118.8, 1000.4, 11, 5 }, { 373.9, -118.8, 1000.4, 10, 5 }, { 373.9, -118.8, 1000.4, 9, 5 }, { 373.9, -118.8, 1000.4, 7, 5 }, { 373.9, -118.8, 1000.4, 6, 5 }, { 373.9, -118.8, 1000.4, 4, 5 }, { 373.9, -118.8, 1000.4, 0, 5 }, { 373.9, -118.8, 1000.4, 1, 5 }, { 373.9, -118.8, 1000.4, 8, 5 }, { 369, -6, 1000.8515625, 2, 9 }, { 369, -6, 1000.8515625, 1, 9 }, { 369, -6, 1000.8515625, 5, 9 }, { 369, -6, 1000.8515625, 9, 9 }, { 369, -6, 1000.8515625, 10, 9 }, { 369, -6, 1000.8515625, 11, 9 }, { 369, -6, 1000.8515625, 8, 9 }, { 369, -6, 1000.8515625, 6, 9 }, { 369, -6, 1000.8515625, 7, 9 }, { 369, -6, 1000.8515625, 4, 9 }, { 369, -6, 1000.8515625, 3, 9 }, { 369, -6, 1000.8515625, 0, 9 }, { 375.6, -67.5, 1000.5, 0, 10 }, { 375.6, -67.5, 1000.5, 1, 10 }, { 375.6, -67.5, 1000.5, 5, 10 }, { 375.6, -67.5, 1000.5, 6, 10 }, { 375.6, -67.5, 1000.5, 7, 10 }, { 375.6, -67.5, 1000.5, 8, 10 }, { 375.6, -67.5, 1000.5, 9, 10 }, { 375.6, -67.5, 1000.5, 2, 10 }, { 375.6, -67.5, 1000.5, 3, 10 }, { 375.6, -67.5, 1000.5, 4, 10 }, } for k,v in ipairs (markers) do z = v[3] -1 Marker = createMarker ( v[1], v[2], z, "cylinder", 1, 255, 0, 0, 200 ) addEventHandler('onClientMarkerHit', Marker, function ( hitPlayer ) if ( hitPlayer == localPlayer ) then ShowGUI() end end ) end addEventHandler("onClientResourceStart", getRootElement(), function() setTimer(function() local localX, localY = getElementPosition(localPlayer) for _, blip in pairs(getElementsByType("blip")) do local blipX, blipY = getElementPosition(blip) if(getDistanceBetweenPoints2D(localX, localY, blipX, blipY) > 1300) then local icon = getElementData(blip, "IconID") if not icon then setElementData(blip, "IconID", getBlipIcon(blip), false) end setBlipIcon(blip, 0) setBlipColor(blip, 255, 255, 255, 0) else local icon = getElementData(blip, "IconID") if icon then setBlipIcon(blip, icon) end end end end, 500, 0) end) addEventHandler("onClientElementStreamIn", getRootElement(), function () if interiors [getElementInterior(localPlayer)] then setPedWeaponSlot ( localPlayer , 0 ) toggleControl("fire", false) toggleControl("sprint", false) toggleControl("next_weapon", false) toggleControl("previous_weapon", false) toggleControl ("aim_weapon", false) toggleControl ("vehicle_fire", false) toggleControl ("aim_weapon", false) end end) addEventHandler("onClientElementStreamOut", getRootElement(), function () if interiors [getElementInterior(localPlayer)] then toggleControl("fire", true) toggleControl("sprint", true) toggleControl("next_weapon", true) toggleControl("previous_weapon", true) toggleControl ("aim_weapon", true) toggleControl ("vehicle_fire", true) toggleControl ("aim_weapon", true) end end) http://imgur.com/908XLPA.png 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