Jump to content

[help]mouse-over [solved]


#RooTs

Recommended Posts

hello guys, is there any easier way to. so I can move the mouse in a certain place, and make a sound?

dx line

dxDrawImage ( botX+sizeX+417, 140, 150, 150, isMouseInPosition ( botX+sizeX+417, 140, 150, 150 ) and "icon/fu2.png" or "icon/fu1.png", 0, 0, 0, tocolor ( 255, 255, 255) ) 

position

botX+sizeX+417, 140, 150, 150 

my attempt

function ClientMouseEnter (_,state) 
        if painelAnim == true then 
            if state == "down" then 
                if isCursorOnElement (botX+sizeX+417, 140, 150, 150) then 
                playSound(click) 
                end 
            end 
        end 
end 
addEventHandler ("onClientMouseEnter", root, ClientMouseEnter) 

Edited by Guest
Link to comment
hello guys, is there any easier way to. so I can move the mouse in a certain place, and make a sound?

dx line

dxDrawImage ( botX+sizeX+417, 140, 150, 150, isMouseInPosition ( botX+sizeX+417, 140, 150, 150 ) and "icon/fu2.png" or "icon/fu1.png", 0, 0, 0, tocolor ( 255, 255, 255) ) 

position

botX+sizeX+417, 140, 150, 150 

my attempt

function ClientMouseEnter (_,state) 
        if painelAnim == true then 
            if state == "down" then 
                if isCursorOnElement (botX+sizeX+417, 140, 150, 150) then 
                playSound(click) 
                end 
            end 
        end 
end 
addEventHandler ("onClientMouseEnter", root, ClientMouseEnter) 

no need to create a function for this, use the isCursorOnElement if in the very function dx

if isCursorOnElement (botX+sizeX+417, 140, 150, 150) then 
             playSound(click) 
       else -- you can opt for it if you want to test 
            stopSound(click) 
  

OBS: I have not tested, if not right tell me

Link to comment

OnClientMouseEnter only detects mouse over gui elements, not the dx ones, i myself tried it over dx, didn't work, make an invisible gui element behind the dx and then use the event...

EDIT : Didn't see the above post while typing ^

Link to comment
OnClientMouseEnter only detects mouse over gui elements, not the dx ones, i myself tried it over dx, didn't work, make an invisible gui element behind the dx and then use the event...

EDIT : Didn't see the above post while typing ^

no other way?

Link to comment
hello guys, is there any easier way to. so I can move the mouse in a certain place, and make a sound?

dx line

dxDrawImage ( botX+sizeX+417, 140, 150, 150, isMouseInPosition ( botX+sizeX+417, 140, 150, 150 ) and "icon/fu2.png" or "icon/fu1.png", 0, 0, 0, tocolor ( 255, 255, 255) ) 

position

botX+sizeX+417, 140, 150, 150 

my attempt

function ClientMouseEnter (_,state) 
        if painelAnim == true then 
            if state == "down" then 
                if isCursorOnElement (botX+sizeX+417, 140, 150, 150) then 
                playSound(click) 
                end 
            end 
        end 
end 
addEventHandler ("onClientMouseEnter", root, ClientMouseEnter) 

no need to create a function for this, use the isCursorOnElement if in the very function dx

if isCursorOnElement (botX+sizeX+417, 140, 150, 150) then 
             playSound(click) 
       else -- you can opt for it if you want to test 
            stopSound(click) 
  

OBS: I have not tested, if not right tell me

Mr.Dante's will work...

Link to comment

I tried this and it worked. but you have an error message...

        if isMouseInPosition ( botX+sizeX+420, botX2+sizeX2+100, 150, 150 ) then 
            som = playSound(click) 
            setTimer ( function() stopSound(som) end, 50, 1 ) 
            dxDrawImage ( botX+sizeX+420, botX2+sizeX2+100, 150, 150,"icon/chat2.png", 0, 0, 0, tocolor ( 255, 255, 255) ) 
        else 
            dxDrawImage ( botX+sizeX+420, botX2+sizeX2+100, 150, 150,"icon/chat1.png", 0, 0, 0, tocolor ( 255, 255, 255) ) 
        end 

WARNING: mod_panel\sourceC.lua:132: Bad argument @ 'stopSound' [Expected sound at argument 1] 
WARNING: mod_panel\sourceC.lua:132: Bad argument @ 'stopSound' [Expected sound at argument 1] 
WARNING: mod_panel\sourceC.lua:132: Bad argument @ 'stopSound' [Expected sound at argument 1] [DUB x10] 
WARNING: mod_panel\sourceC.lua:132: Bad argument @ 'stopSound' [Expected sound at argument 1] [DUB x5] 

is possible add the playSound within of render ???

Link to comment
I tried this and it worked. but you have an error message...
        if isMouseInPosition ( botX+sizeX+420, botX2+sizeX2+100, 150, 150 ) then 
            som = playSound(click) 
            setTimer ( function() stopSound(som) end, 50, 1 ) 
            dxDrawImage ( botX+sizeX+420, botX2+sizeX2+100, 150, 150,"icon/chat2.png", 0, 0, 0, tocolor ( 255, 255, 255) ) 
        else 
            dxDrawImage ( botX+sizeX+420, botX2+sizeX2+100, 150, 150,"icon/chat1.png", 0, 0, 0, tocolor ( 255, 255, 255) ) 
        end 

WARNING: mod_panel\sourceC.lua:132: Bad argument @ 'stopSound' [Expected sound at argument 1] 
WARNING: mod_panel\sourceC.lua:132: Bad argument @ 'stopSound' [Expected sound at argument 1] 
WARNING: mod_panel\sourceC.lua:132: Bad argument @ 'stopSound' [Expected sound at argument 1] [DUB x10] 
WARNING: mod_panel\sourceC.lua:132: Bad argument @ 'stopSound' [Expected sound at argument 1] [DUB x5] 

is possible add the playSound within of render ???

Stop Sound has to be the music of the variable, not the playsound

if isMouseInPosition ( botX+sizeX+420, botX2+sizeX2+100, 150, 150 ) then 
            playSound(click) 
            setTimer ( function() stopSound(click) end, 50, 1 ) 
            dxDrawImage ( botX+sizeX+420, botX2+sizeX2+100, 150, 150,"icon/chat2.png", 0, 0, 0, tocolor ( 255, 255, 255) ) 
        else 
            dxDrawImage ( botX+sizeX+420, botX2+sizeX2+100, 150, 150,"icon/chat1.png", 0, 0, 0, tocolor ( 255, 255, 255) ) 
        end 

Link to comment
If it gives you this error then probably the sound did end ... soo before you try to stop the sound you should check if it isElement.
sound = playSound(click) 
setTimer ( function() if isElement(sound) then stopSound(sound) end end, 50, 1 ) 

LOLL, worked. I was thinking it was not possible :lol:

more with the cursor over an image and another. the sound is repeating endlessly.

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