Sign in to follow this  
gabrielslayer

How to add functions to each button help me please

Recommended Posts

Quote


painelvip = false 
function button()
showCursor (true)
    painel = guiCreateWindow(286, 231, 454, 345, "VIP BSA", false)
    guiWindowSetSizable(painel, false)
    
    myWindow = guiCreateStaticImage(9, 19, 435, 316, "123.png", false, painel)
    button1 = guiCreateButton(0, 229, 140, 49, "Skin VIP", false, myWindow)
    guiSetAlpha(button1, 0.80)
    button2 = guiCreateButton(150, 229, 140, 49, "Carro VIP", false, myWindow)
    guiSetAlpha(button2, 0.80)
    button3 = guiCreateButton(295, 229, 140, 49, "Habilidades", false, myWindow)
    guiSetAlpha(button3, 0.80)
    button4 = guiCreateButton(347, 46, 78, 32, "Fechar", false, myWindow)
    guiSetAlpha(button4, 0.80)    


function guiToggleVisible ( )        
        if ( guiGetVisible ( painel ) == true ) then -- check if the gui element is visible               
                guiSetVisible ( painel, false ) -- if it is, we hide it
            showCursor (false)        
        else              
                guiSetVisible ( painel, true ) -- if not, we make it visible
                    showCursor (true)
        end
end
addEvent ("OpenGang",true)
addEventHandler ("OpenGang",root,guiToggleVisible)
bindKey ( "F2", "down", guiToggleVisible )
end
addCommandHandler ("vip", button)


function painelgang(thePlayer)
    login = getAccountName(getPlayerAccount(thePlayer))
    if isObjectInACLGroup("user."..login, aclGetGroup("VIP")) then 
        triggerClientEvent(thePlayer, "OpenGang", getRootElement())
        triggerClientEvent(thePlayer, "onResourceStart", getRootElement())
        else
          outputChatBox("[Erro]: #BEBEBESomente membros da #FFFFFF~=[ ✘☠ #FF0000Gang #FFFFFF☠✘ ]=~", thePlayer, 255, 0, 0, true)
    end
end

function cursorPosition(x, y, w, h)
    if (not isCursorShowing()) then
        return false
    end
    local mx, my = getCursorPosition()
    local fullx, fully = guiGetScreenSize()
    cursorx, cursory = mx*fullx, my*fully
    if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
        return true
    else
        return false
    end
end
-----------------------------------------------------------

addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()),
        function ( )
            if (source == button1) then
                    setElementModel ( 280 )
                     guiSetVisible( painel, false )
                    showCursor( false )                    
            end
        end         
)


veh = {}
addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()),
        function ( )
            if (source == button2) then
        local x, y, z = getElementPosition(thePlayer)
        local RaceVehicle = createVehicle ( 411, 0, 0, 0 ) 
        local spawnVeh = spawnVehicle ( RaceVehicle, x+3, y+3, z )    
        if spawnVeh    then
        outputChatBox("Vehicle was spawned", thePlayer)
        else
        outputChatBox("Error",thePlayer)
        end

                guiSetVisible( painel, false )
                showCursor( false )        
            end
         end

)

addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()),
        function ( )
            if (source == button3) then
            for _, stat in ipairs({ 24, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79 }) do
            setPedStat(thePlayer, stat, 1000)
            outputChatBox("Your game stats upgraded to maximum!", thePlayer, 0, 255, 0, false)
            end
                 guiSetVisible( painel, false )
                showCursor( false )    
            end
         end
    
)

addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()),
        function ( )
            if (source == button4) then
            guiSetVisible( painel, false )
            showCursor( false )
            guiSetVisible( painel, false )
            showCursor( false )              
            end
         end
)
 

I know there are many errors but I can not solve them...

Help me please.

Share this post


Link to post

Did u try fixing it urself what did debugscript 3 say? just saying

19 minutes ago, gabrielslayer said:

I know there are many errors but I can not solve them...

Help me please.

doesn't help and this section is for people willing to learn scripting if u want some one to fix ur script u gotta find someone to help u or pay for a scripter

Share this post


Link to post
30 minutes ago, kikos500 said:

Did u try fixing it urself what did debugscript 3 say? just saying

doesn't help and this section is for people willing to learn scripting if u want some one to fix ur script u gotta find someone to help u or pay for a scripter

I'm learning to build the same
I've been working on it since the beginning

Share this post


Link to post

This is how an event handler works.

addEventHandler("EVENT_NAME", ELEMENT_YOU_WANT_TO_ATTACH_THIS_TO, FUNCTION)

Dince arg 2 requires an element to attach to we just use the button as the element to attach:

addEventHandler ( "onClientGUIClick", button1,
	function ( )
		setElementModel ( 280 )
		guiSetVisible( painel, false )
		showCursor( false )
	end         
)
Edited by Mr.Loki

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.