Stevenn Posted March 31, 2012 Share Posted March 31, 2012 Hello.. I have a problem the marker is there and all but when I enter the marker I cannot see the buttons?? --gui policeGui = guiCreateWindow(301,463,263,257,"",false) guiMemo = guiCreateMemo(9,26,241,156,"Text",false,policeGui) guiButtonAccept = guiCreateButton(10,216,65,32,"Accept",true,policeGui)-- if I change to false, nothing happens when I click on the button! guiButtonClose = guiCreateButton(178,215,65,32,"Close",true,policeGui)-- same here! guiSetVisible(policeGui,false) guiMemoSetReadOnly(guiMemo,true) guiWindowSetMovable (policeGui,false ) guiWindowSetSizable (policeGui,false ) lp = getLocalPlayer() policeMarker = createMarker(1552,-1677,16,"cylinder",2,170,30,0) addEventHandler("onClientMarkerHit",policeMarker,function(p) if p == lp and not isPedInVehicle(lp) then guiSetVisible(policeGui,true) showCursor(true) end end) addEventHandler("onClientGuiClick",policeGui, function(b) if b == "left" then if source == guiButtonAccept then triggerServerEvent("policeServer",lp) outputChatBox("You are now hired as a police officer") showCursor(false) guiSetVisible(policeGui,false) end elseif source == guiButtonClose then guiSetVisible(policeGui,false) showCursor(false) end end) Link to comment
TAPL Posted March 31, 2012 Share Posted March 31, 2012 --gui policeGui = guiCreateWindow(301,463,263,257,"",false) guiMemo = guiCreateMemo(9,26,241,156,"Text",false,policeGui) guiButtonAccept = guiCreateButton(10,216,65,32,"Accept",false,policeGui)-- if I change to false, nothing happens when I click on the button! guiButtonClose = guiCreateButton(178,215,65,32,"Close",false,policeGui)-- same here! guiSetVisible(policeGui,false) guiMemoSetReadOnly(guiMemo,true) guiWindowSetMovable (policeGui,false ) guiWindowSetSizable (policeGui,false ) lp = getLocalPlayer() policeMarker = createMarker(1552,-1677,16,"cylinder",2,170,30,0) addEventHandler("onClientMarkerHit",policeMarker,function(p) if p == lp and not isPedInVehicle(lp) then guiSetVisible(policeGui,true) showCursor(true) end end) addEventHandler("onClientGuiClick",root, function() if source == guiButtonAccept then triggerServerEvent("policeServer",lp) outputChatBox("You are now hired as a police officer") showCursor(false) guiSetVisible(policeGui,false) elseif source == guiButtonClose then guiSetVisible(policeGui,false) showCursor(false) end end) Link to comment
Stevenn Posted March 31, 2012 Author Share Posted March 31, 2012 if I use that code, nothing will happen when I press on any of the buttons. Link to comment
drk Posted March 31, 2012 Share Posted March 31, 2012 Because Lua is Case-Sensitive. You are using event name "onClientGuiClick" and must be "onClientGUIClick". Link to comment
Stevenn Posted March 31, 2012 Author Share Posted March 31, 2012 Because Lua is Case-Sensitive. You are using event name "onClientGuiClick" and must be "onClientGUIClick". Wops, my bad. It works perfectly now! thanks. Link to comment
Stevenn Posted March 31, 2012 Author Share Posted March 31, 2012 Now to another thing, if I want to calculate the gui so it centers and the buttons how the hell do I do that? guiGetScreenSize I've read all that but I still don't understand.. Link to comment
drk Posted March 31, 2012 Share Posted March 31, 2012 If you wanna center the GUI, use this function: https://wiki.multitheftauto.com/wiki/CenterWindow It's more easy for you. To create GUIs / GUI elements / DX rectangles, images, text or other thing use GUIEditor. It generates automatically the position. To put it relative to all resolutions use: local x, y = guiGetScreenSize ( ) Then you can use like: ( posX / yourResolutionX ) * sx, ( posY / yourResolutionY ) * sy, ( width / yourResolutionX ) * sx, ( height / yourResolutionY ) * sy Link to comment
Kenix Posted March 31, 2012 Share Posted March 31, 2012 ( posX / yourResolutionX ) * sx, ( posY / yourResolutionY ) * sy, ( width / yourResolutionX ) * sx, ( height / yourResolutionY ) * sy No. It's not correct. local nScreenX, nScreenY = guiGetScreenSize( ) --[[ nPosX = 0.5 nPosY = 0.5 nSizeX = 0.5 nSizeY = 0.5 ]] nPosX = nPosX * nScreenX nPosY = nPosY * nScreenY nSizeX = nSizeX * nScreenX nSizeY = nSizeY * nScreenY guiCreateWindow( nPosX, nPosY, nSizeX, nSizeY, '...', false ) Anyway you can use relative argument. guiCreateWindow( 0.5, 0.5, 0.5, 0.5, '...', true ) Link to comment
Stevenn Posted March 31, 2012 Author Share Posted March 31, 2012 I'm sorry, but I don't get it. I understand that you don't want to give out codes without me even trying but I am! so I wonder if anyone could just post an example of how I would calculate policeGui = guiCreateWindow(301,463,263,257,"",false) guiMemo = guiCreateMemo(9,26,241,156,"Text",false,policeGui) guiButtonAccept = guiCreateButton(10,216,65,32,"Accept",false,policeGui) guiButtonClose = guiCreateButton(178,215,65,32,"Close",false,policeGui) After reading the guiGetScreenSize again I understand that example, but it will just create a window in the bottom of my screen, what if I want to change the position how would I do that? Link to comment
Kenix Posted March 31, 2012 Share Posted March 31, 2012 The better way use resource guieditor. Because you can select convert to absolute or to relative. https://community.multitheftauto.com/index.php?p= ... ils&id=141 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