Jump to content

no buttons?


Stevenn

Recommended Posts

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
--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

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
( 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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...