Jump to content

GUI buttons what am I missing?


maoko

Recommended Posts

GUIEditor = {
    button = {}
}

addEventHandler("onClientResourceStart", resourceRoot,
    function ()
		local screenW, screenH = guiGetScreenSize()
        propswindow = guiCreateWindow((screenW - 636) / 2, (screenH - 362) / 2, 636, 362, "Race Props", false)
        guiWindowSetSizable(propswindow, false)
        explosivebarrel = guiCreateButton(0.04, 0.12, 0.18, 0.11, "Explosive Barrel", true, propswindow)
        ramp1 = guiCreateButton(184, 43, 116, 40, "Ramp1", false, propswindow)
        ramp2 = guiCreateButton(333, 42, 124, 41, "Ramp2", false, propswindow)
        ramp3 = guiCreateButton(486, 43, 120, 40, "Ramp3", false, propswindow)
        breakablehay = guiCreateButton(27, 105, 116, 42, "Breakable Hay", false, propswindow)
        mine = guiCreateButton(184, 107, 116, 40, "Mine (can't explode)", false, propswindow)
        rock1 = guiCreateButton(332, 107, 125, 40, "Rock1", false, propswindow)
        rock2 = guiCreateButton(483, 106, 123, 41, "Rock2", false, propswindow)
        wirefence = guiCreateButton(28, 173, 115, 43, "Wire Fence", false, propswindow)
        metalarch = guiCreateButton(182, 175, 118, 41, "Metal Arch", false, propswindow)
        tree1 = guiCreateButton(329, 176, 128, 40, "Tree1", false, propswindow)
        tree2 = guiCreateButton(486, 178, 120, 38, "Tree2", false, propswindow)
        railfence = guiCreateButton(29, 241, 114, 41, "Rail Fence", false, propswindow)
        hugefencing = guiCreateButton(184, 241, 116, 41, "Huge Fencing", false, propswindow)
        oildrum = guiCreateButton(328, 242, 129, 40, "Oil Drum", false, propswindow)
        glass = guiCreateButton(487, 245, 119, 37, "Glass", false, propswindow)
        bigsmoke = guiCreateButton(29, 305, 114, 36, "Big Smoke", false, propswindow)
        noclipburger = guiCreateButton(184, 308, 116, 33, "Noclip Burger", false, propswindow)
        GUIEditor.button[2] = guiCreateButton(328, 306, 129, 35, "", false, propswindow)
        GUIEditor.button[3] = guiCreateButton(485, 301, 121, 36, "", false, propswindow)    
		guiSetVisible(propswindow, false)
		addEventHandler ( "onClientGUIClick", explosivebarrel, clientCreateObject, false )
		end
)	


function clientOpenWindow()
	local state = guiGetVisible (propswindow)
		if state == false then
			guiSetVisible (propswindow, true)
			showCursor (true)
		else
			guiSetVisible (propswindow, false)
			showCursor (false)
		end
end
addCommandHandler ( "props", clientOpenWindow )
	
function clientCreateObject(thePlayer,button,state)
	if button == "left" and state == "up" then
		local x, y, z = getElementPosition ( thePlayer ) -- get the player's position
		local rotX, rotY, rotZ = getElementRotation ( thePlayer )
		local theMarker = createMarker ( x, y, z, "cylinder", 1, 200, 0, 200, 170 )
		if ( theMarker ) then -- check if the marker was created successfully
			outputConsole ( "Prop created successfully", thePlayer )
			outputDebugString ("<object id=\"object (barrel4) (1)\" breakable=\"true\" interior=\"0\" alpha=\"255\" dimension=\"0\" model=\"1225\" scale=\"1\" doublesided=\"false\" collisions=\"true\" posX=£"..x.."£ posY=£"..y.."£ posZ=£"..z.."£ rotX=£"..rotX.."£ rotY=£"..rotY.."£ rotZ=£"..rotZ.."£></object>" )
		-- move the input focus back onto the game (allowing players to move around, open the chatbox, etc)
		guiSetInputEnabled(false)
		-- hide the window and all the components
		guiSetVisible(propswindow, false)
		-- hide the mouse cursor
		showCursor(false)
		end
	end
end

I'm currently getting no errors but I want clientCreateObject function to work. It did work when it was simply something like:

function clientCreateObject(button,state)

if button == "left" and state == "up" then

        -- move the input focus back onto the game (allowing players to move around, open the chatbox, etc)
        guiSetInputEnabled(false)
        -- hide the window and all the components
        guiSetVisible(propswindow, false)
        -- hide the mouse cursor
        showCursor(false)

end

 

But with my additional things it doesn't do anything anymore. What's missing or wrong?

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