oldnag Posted October 3, 2013 Share Posted October 3, 2013 i cant seem to get the ui to appear when i click the rock any idea why server: function createMiningRock() miningRock = createObject(17026, 2343, -651, 125,0,0,0) end addEventHandler("onResourceStart",getRootElement(),createMiningRock) function rockClicked( theButton, theState, thePlayer ) if theButton == "right" and theState == "down" then outputChatBox( "You should have a window now", thePlayer ) triggerClientEvent("showMiningUI", getRootElement()) end end addEventHandler( "onElementClicked", getRootElement(), rockClicked ) [/code] client: function showMiningUI() miningUI = guiCreateWindow(773, 426, 399, 205, "Mining", false) guiWindowSetSizable(miningUI, false) guiSetAlpha(miningUI, 1.00) guiSetProperty(miningUI, "CaptionColour", "FF2FFF00") bStartMining = guiCreateButton(11, 121, 376, 66, "Start Mining", false, miningUI) bCancelMining = guiCreateButton(359, 26, 18, 15, "x", false, miningUI) guiSetProperty(bStartMining, "NormalTextColour", "FF2FFF00") guiSetProperty(bMiningCancel, "NormalTextColour", "FFFD0102") helpText = guiCreateLabel(10, 31, 362, 112, "To start mining just click the button below and wait until your \ncharacter stops gathering to do it again. To abort current task \njust click on the \"x\" at the top right of the UI", false, miningUI) addEventHandler("onClientGUIClick", bStartmining, startMining) addEventHandler("onClientGUIClick", bcancelMining, cancelMining) end Link to comment
iPrestege Posted October 3, 2013 Share Posted October 3, 2013 try this : -- _Server Side local miningRock = createObject ( 17026, 2343, -651, 125,0,0,0 ) addEventHandler ( 'onElementClicked',miningRock, function ( theButton, theState, thePlayer ) if theButton == "right" and theState == "down" then triggerClientEvent ( thePlayer,'showMiningUI',thePlayer ) outputChatBox ( 'For test the event has been triggred.',thePlayer ) end end ) -- _Client Side function showMiningUI ( ) miningUI = guiCreateWindow(773, 426, 399, 205, "Mining", false) guiWindowSetSizable(miningUI, false) guiSetVisible (miningUI,false) guiSetAlpha(miningUI, 1.00) guiSetProperty(miningUI, "CaptionColour", "FF2FFF00") bStartMining = guiCreateButton(11, 121, 376, 66, "Start Mining", false, miningUI) bCancelMining = guiCreateButton(359, 26, 18, 15, "x", false, miningUI) guiSetProperty(bStartMining, "NormalTextColour", "FF2FFF00") guiSetProperty(bMiningCancel, "NormalTextColour", "FFFD0102") helpText = guiCreateLabel(10, 31, 362, 112, "To start mining just click the button below and wait until your \ncharacter stops gathering to do it again. To abort current task \njust click on the \"x\" at the top right of the UI", false, miningUI) addEventHandler("onClientGUIClick", bStartmining, startMining) addEventHandler("onClientGUIClick", bcancelMining, cancelMining) end showMiningUI ( ) addEvent('showMiningUI',true) addEventHandler ( 'showMiningUI',root, function ( ) guiSetVisible (miningUI,true) end ) Link to comment
oldnag Posted October 3, 2013 Author Share Posted October 3, 2013 my ui window wont close when i click the close button now, sorry im a noob at this function closeMiningUI(button, state) if (source==bCancelMining) and (button=="left") and (state=="down") then guiSetVisible(miningUI, false) destroyElement(miningUI) miningUI = nil showCursor(false) removeEventHandler("onClientGUIClick", getRootElement(), closeMiningUI) end end Link to comment
TAPL Posted October 3, 2013 Share Posted October 3, 2013 function cancelMining(button, state) if (source==bCancelMining) and (button=="left") and (state=="down") then guiSetVisible(miningUI, false) destroyElement(miningUI) miningUI = nil showCursor(false) removeEventHandler("onClientGUIClick", bCancelMining, cancelMining) end end 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