Jump to content

What a i doing wrong


oldnag

Recommended Posts

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

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

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

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