gabrielslayer Posted August 26, 2017 Share Posted August 26, 2017 function Window () painel = guiCreateWindow(286, 231, 454, 345, "VIP BSA", true) guiWindowSetSizable(painel, true) showCursor ( true ) myWindow = guiCreateStaticImage(9, 19, 435, 316, "123.png", false, painel) button1 = guiCreateButton(0, 229, 140, 49, "Skin VIP", false, myWindow) button2 = guiCreateButton(150, 229, 140, 49, "Carro VIP", false, myWindow) button3 = guiCreateButton(295, 229, 140, 49, "Habilidades", false, myWindow) button4 = guiCreateButton(347, 46, 78, 32, "Fechar", false, myWindow) guiSetAlpha(button1, 0.20) guiSetAlpha(button2, 0.20) guiSetAlpha(button3, 0.20) guiSetAlpha(button4, 0.20) if ( guiGetVisible ( Window ) == true ) then guiSetVisible ( painel,Window, false ) showCursor ( false ) else guiSetVisible ( painel,Window, true ) showCursor ( true ) end end addCommandHandler ("vip", Window, painel, myWindow) --------------------------------------------- addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == button1) then local player = getLocalPlayer() setElementModel ( source, 230 ) outputChatBox ('#000000[#00ffffVoce Acaba De Pega Skin#000000] !',source,255,255,255,true) end end ) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == button2) then local player = getLocalPlayer() if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) veh[source] = nil end local x,y,z = getElementPosition(source) veh[source] = createVehicle(411, x,y,z + 2) outputChatBox ('#000000[#00ffffVoce Acaba De Criar Um Carro#000000] !',source,255,255,255,true) warpPedIntoVehicle (source,veh[source]) end end ) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == button3) then local player = getLocalPlayer() local stat = getPedStat ( source, 1 ) -- Check that getPedStat returned a value if ( stat > 1000 ) then outputChatBox ('#000000[#00ffffVoce Pegou Habilidades#000000]!',source,255,255,255,true) end end ) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == button4) then local player = getLocalPlayer() guiSetVisible( myWindow, false ) showCursor( false ) guiSetVisible( myWindow, false ) showCursor( false ) end end ) Link to comment
gabrielslayer Posted August 26, 2017 Author Share Posted August 26, 2017 27 minutes ago, gabrielslayer said: function Window () painel = guiCreateWindow(286, 231, 454, 345, "VIP BSA", true) guiWindowSetSizable(painel, true) showCursor ( true ) myWindow = guiCreateStaticImage(9, 19, 435, 316, "123.png", false, painel) button1 = guiCreateButton(0, 229, 140, 49, "Skin VIP", false, myWindow) button2 = guiCreateButton(150, 229, 140, 49, "Carro VIP", false, myWindow) button3 = guiCreateButton(295, 229, 140, 49, "Habilidades", false, myWindow) button4 = guiCreateButton(347, 46, 78, 32, "Fechar", false, myWindow) guiSetAlpha(button1, 0.20) guiSetAlpha(button2, 0.20) guiSetAlpha(button3, 0.20) guiSetAlpha(button4, 0.20) if ( guiGetVisible ( Window ) == true ) then guiSetVisible ( painel,Window, false ) showCursor ( false ) else guiSetVisible ( painel,Window, true ) showCursor ( true ) end end addCommandHandler ("vip", Window, painel, myWindow) --------------------------------------------- addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == button1) then local player = getLocalPlayer() setElementModel ( source, 230 ) outputChatBox ('#000000[#00ffffVoce Acaba De Pega Skin#000000] !',source,255,255,255,true) end end ) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == button2) then local player = getLocalPlayer() if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) veh[source] = nil end local x,y,z = getElementPosition(source) veh[source] = createVehicle(411, x,y,z + 2) outputChatBox ('#000000[#00ffffVoce Acaba De Criar Um Carro#000000] !',source,255,255,255,true) warpPedIntoVehicle (source,veh[source]) end end ) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == button3) then local player = getLocalPlayer() local stat = getPedStat ( source, 1 ) -- Check that getPedStat returned a value if ( stat > 1000 ) then outputChatBox ('#000000[#00ffffVoce Pegou Habilidades#000000]!',source,255,255,255,true) end end ) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == button4) then local player = getLocalPlayer() guiSetVisible( myWindow, false ) showCursor( false ) guiSetVisible( myWindow, false ) showCursor( false ) end end ) help dx :c Link to comment
Administrators Lpsd Posted August 26, 2017 Administrators Share Posted August 26, 2017 First of all, you should be using debugscript to check for errors. I'm more than certain this code would produce some errors. To do this type "debugscript 3" into the console then try using your script, errors appear at the bottom of your screen. Now to the code itself, check out the addCommandHandler wiki page & look at the arguments; Required Arguments commandName: This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function. handlerFunction: This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional. addCommandHandler ("vip", Window, painel, myWindow) --your code. "painel" and "myWindow" have no use addCommandHandler ("vip", Window) --fixed code Same again with guiSetVisible Required Arguments guiElement: the GUI element whose visibility is to be changed state: the new visibility state if ( guiGetVisible ( Window ) == true ) then --Window is a function, not a GUI element guiSetVisible ( painel,Window, false ) --2nd arg expected boolean (true/false) got function showCursor ( false ) else guiSetVisible ( painel,Window, true ) --same here showCursor ( true ) end if ( guiGetVisible ( painel ) == true ) then --Checking for GUI element, not function guiSetVisible ( painel, false ) --Fixed args showCursor ( false ) else guiSetVisible ( painel, true ) showCursor ( true ) end All good, right? No - you're still making a big mistake. Since you're using the Window function to toggle the GUI visible/hidden, there's no need to keep creating (or overwriting) the GUI elements. painel = guiCreateWindow(286, 231, 454, 345, "VIP BSA", true) guiWindowSetSizable(painel, true) myWindow = guiCreateStaticImage(9, 19, 435, 316, "123.png", false, painel) button1 = guiCreateButton(0, 229, 140, 49, "Skin VIP", false, myWindow) button2 = guiCreateButton(150, 229, 140, 49, "Carro VIP", false, myWindow) button3 = guiCreateButton(295, 229, 140, 49, "Habilidades", false, myWindow) button4 = guiCreateButton(347, 46, 78, 32, "Fechar", false, myWindow) guiSetAlpha(button1, 0.20) guiSetAlpha(button2, 0.20) guiSetAlpha(button3, 0.20) guiSetAlpha(button4, 0.20) All of the above code (taken from the Window function) should be put into a seperate function which is attached to an OnClientResourceStart event handler. Should be pretty easy to do. The Wiki is your best friend. Use it 1 Link to comment
gabrielslayer Posted August 26, 2017 Author Share Posted August 26, 2017 (edited) 2 hours ago, LopSided_ said: First of all, you should be using debugscript to check for errors. I'm more than certain this code would produce some errors. To do this type "debugscript 3" into the console then try using your script, errors appear at the bottom of your screen. Now to the code itself, check out the addCommandHandler wiki page & look at the arguments; Required Arguments commandName: This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function. handlerFunction: This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional. addCommandHandler ("vip", Window, painel, myWindow) --your code. "painel" and "myWindow" have no use addCommandHandler ("vip", Window) --fixed code Same again with guiSetVisible Required Arguments guiElement: the GUI element whose visibility is to be changed state: the new visibility state if ( guiGetVisible ( Window ) == true ) then --Window is a function, not a GUI element guiSetVisible ( painel,Window, false ) --2nd arg expected boolean (true/false) got function showCursor ( false ) else guiSetVisible ( painel,Window, true ) --same here showCursor ( true ) end if ( guiGetVisible ( painel ) == true ) then --Checking for GUI element, not function guiSetVisible ( painel, false ) --Fixed args showCursor ( false ) else guiSetVisible ( painel, true ) showCursor ( true ) end All good, right? No - you're still making a big mistake. Since you're using the Window function to toggle the GUI visible/hidden, there's no need to keep creating (or overwriting) the GUI elements. painel = guiCreateWindow(286, 231, 454, 345, "VIP BSA", true) guiWindowSetSizable(painel, true) myWindow = guiCreateStaticImage(9, 19, 435, 316, "123.png", false, painel) button1 = guiCreateButton(0, 229, 140, 49, "Skin VIP", false, myWindow) button2 = guiCreateButton(150, 229, 140, 49, "Carro VIP", false, myWindow) button3 = guiCreateButton(295, 229, 140, 49, "Habilidades", false, myWindow) button4 = guiCreateButton(347, 46, 78, 32, "Fechar", false, myWindow) guiSetAlpha(button1, 0.20) guiSetAlpha(button2, 0.20) guiSetAlpha(button3, 0.20) guiSetAlpha(button4, 0.20) All of the above code (taken from the Window function) should be put into a seperate function which is attached to an OnClientResourceStart event handler. Should be pretty easy to do. The Wiki is your best friend. Use it Thanks, but the doubt still perciste, debugscript shows me error in line 75 "unexpected symbol near ')'" and I did not understand the part of OnClientResourceStart where I need to put, define which function? Follow the code: addEventHandler("onClientResourceStart", resourceRoot, function Window () painel = guiCreateWindow(286, 231, 454, 345, "VIP BSA", true) guiWindowSetSizable(painel, true) myWindow = guiCreateStaticImage(9, 19, 435, 316, "123.png", false, painel) button1 = guiCreateButton(0, 229, 140, 49, "Skin VIP", false, myWindow) button2 = guiCreateButton(150, 229, 140, 49, "Carro VIP", false, myWindow) button3 = guiCreateButton(295, 229, 140, 49, "Habilidades", false, myWindow) button4 = guiCreateButton(347, 46, 78, 32, "Fechar", false, myWindow) guiSetAlpha(button1, 0.20) guiSetAlpha(button2, 0.20) guiSetAlpha(button3, 0.20) guiSetAlpha(button4, 0.20) if ( guiGetVisible ( painel ) == true ) then --Checking for GUI element, not function guiSetVisible ( painel, false ) --Fixed args showCursor ( false ) else guiSetVisible ( painel, true ) showCursor ( true ) end end ) addCommandHandler ("vip", Window) --------------------------------------------- ---------------------------------------------- addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == button1) then local player = getLocalPlayer() setElementModel ( source, 230 ) outputChatBox ('#000000[#00ffffVoce Acaba De Pega Skin#000000] !',source,255,255,255,true) --- guiSetVisible( myWindow, false ) --- showCursor( false ) end end ) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == button2) then local player = getLocalPlayer() if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) veh[source] = nil end local x,y,z = getElementPosition(source) veh[source] = createVehicle(411, x,y,z + 2) outputChatBox ('#000000[#00ffffVoce Acaba De Criar Um Carro#000000] !',source,255,255,255,true) warpPedIntoVehicle (source,veh[source]) -- guiSetVisible( myWindow, false ) -- showCursor( false ) end end ) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == button3) then local player = getLocalPlayer() local stat = getPedStat ( source, 1 ) -- Check that getPedStat returned a value if ( stat > 1000 ) then outputChatBox ('#000000[#00ffffVoce Pegou Habilidades#000000]!',source,255,255,255,true) -- guiSetVisible( myWindow, false ) -- showCursor( false ) end end ) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == button4) then local player = getLocalPlayer() guiSetVisible( myWindow, false ) showCursor( false ) guiSetVisible( myWindow, false ) showCursor( false ) end end ) Edited August 26, 2017 by gabrielslayer Link to comment
Administrators Lpsd Posted August 26, 2017 Administrators Share Posted August 26, 2017 I would advise you to check out the Scripting Introduction first, or check out some Lua tutorials (https://www.tutorialspoint.com/lua/) 1 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