Jump to content

Function no Work


JuniorMelo

Recommended Posts

Posted

hello, I have this function that is not working :shock::? ,

function MouseClick(button,state) 
    if button == "left" and state == "down" then 
        if ( source == f1 ) then 
               triggerServerEvent("Ativo", getLocalPlayer(), getLocalPlayer(), Ativo) 
              ori9 = on 
        else 
              triggerServerEvent("Garagem", getLocalPlayer(), getLocalPlayer(), garagem) 
              ori9 = off 
        end 
    end 
end 
addEventHandler("onClientClick",getRootElement(),MouseClick) 

Posted

What exactly are you trying to do? It's kinda hard to tell from this script. Also, be sure to check debugscript for errors by using /debugscript 3

And if you could, please post the whole script.

Posted (edited)

No Have erros in /debugscript 3

function guiPart() 
f1 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3-47,okX-70, recY-375, "", false) 
f2 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3-2,okX-70, recY-375, "F2", false) 
f3 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3+43,okX-70, recY-375, "F2", false) 
guiSetAlpha ( f1, 0 ) 
guiSetAlpha ( f2, 0 ) 
guiSetAlpha ( f3, 0 ) 
end 
  
function MouseClick(button,state) 
    if button == "left" and state == "down" then 
        if ( source == f1 ) then 
            triggerServerEvent("Ativo", getLocalPlayer(), getLocalPlayer(), Ativo) --Event GiveCar 
            ori9 = on --Image ON 
        else 
            triggerServerEvent("Garagem", getLocalPlayer(), getLocalPlayer(), Garagem) --Event Destroy Car 
            ori9 = off --image OFF 
        end 
    end 
end 
addEventHandler("onClientClick",getRootElement(),MouseClick) 

Edited by Guest
Posted

Ok, so you're looking for something like this, however it's not going to work unless you have the following variables defined somewhere else in the script:

- on

- Ativo

- off

- Garagem

function guiPart() 
    f1 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3-47,okX-70, recY-375, "", false) 
    f2 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3-2,okX-70, recY-375, "F2", false) 
    f3 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3+43,okX-70, recY-375, "F2", false) 
    guiSetAlpha ( f1, 0 ) 
    guiSetAlpha ( f2, 0 ) 
    guiSetAlpha ( f3, 0 ) 
end 
  
function MouseClick ( button, state )  
    if ( button == "left" ) then  
        if ( source == f1 ) then 
            triggerServerEvent("Ativo", getLocalPlayer(), getLocalPlayer(), Ativo); 
            ori9 = on; 
        else 
            triggerServerEvent("Garagem", getLocalPlayer(), getLocalPlayer(), Garagem); 
            ori9 = off; 
        end 
    end  
end  
addEventHandler ( "onClientGUIClick", root, MouseClick ); 

Posted
Ok, so you're looking for something like this, however it's not going to work unless you have the following variables defined somewhere else in the script:

- on

- Ativo

- off

- Garagem

function guiPart() 
    f1 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3-47,okX-70, recY-375, "", false) 
    f2 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3-2,okX-70, recY-375, "F2", false) 
    f3 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3+43,okX-70, recY-375, "F2", false) 
    guiSetAlpha ( f1, 0 ) 
    guiSetAlpha ( f2, 0 ) 
    guiSetAlpha ( f3, 0 ) 
end 
  
function MouseClick ( button, state )  
    if ( button == "left" ) then  
        if ( source == f1 ) then 
            triggerServerEvent("Ativo", getLocalPlayer(), getLocalPlayer(), Ativo); 
            ori9 = on; 
        else 
            triggerServerEvent("Garagem", getLocalPlayer(), getLocalPlayer(), Garagem); 
            ori9 = off; 
        end 
    end  
end  
addEventHandler ( "onClientGUIClick", root, MouseClick ); 

this way does not work.

I believe it is for an event , "onClientGUIClick" ,

triggerServerEvent("Ativo", getLocalPlayer(), getLocalPlayer(), Ativo); --Event Give Car 
       triggerServerEvent("Garagem", getLocalPlayer(), getLocalPlayer(), Garagem); --Event Destroy Car 
       ori9 = on; --dxDrawImage ON 
       ori9 = off;   -- dxDrawImage OFF 

Posted

You work with GUI Buttons?

Then use onClientGUIClick, not onClientClick!!

"This is linked to the GTA world, as oppose to GUI for which onClientGUIClick is to be used. This event allows detection of click positions of the 3D world."

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