Lucario Posted May 27, 2013 Share Posted May 27, 2013 Hi, im changing the main of original panel resource freeroam, but it have some problems, when i start the script, the gui autoopen, and when i press F1 it give me a error, and the buttons doesnt work. Client: CONTROL_MARGIN_RIGHT = 5 LINE_MARGIN = 5 LINE_HEIGHT = 16 g_Root = getRootElement() g_ResRoot = getResourceRootElement(getThisResource()) g_Me = getLocalPlayer() server = createServerCallInterface() guiSetInputMode("no_binds_when_editing") GUIEditor = { checkbox = {}, window = {}, button = {}, label = {} } GUIEditor.window[1] = guiCreateWindow(22, 182, 366, 399, "Panel Principal de Juramento Freeroam", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(10, 46, 110, 51, "Skins", false, GUIEditor.window[1]) local font_0 = guiCreateFont("bhz.ttf") guiSetFont(GUIEditor.button[1], font_0) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFFFFFF") GUIEditor.button[2] = guiCreateButton(10, 103, 109, 51, "Ropa de CJ", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[2], font_0) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFFFFFFF") GUIEditor.button[3] = guiCreateButton(129, 46, 109, 51, "Animaciones", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[3], font_0) guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FFFFFFFF") GUIEditor.button[4] = guiCreateButton(129, 103, 109, 51, "Mejoras", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[4], font_0) guiSetProperty(GUIEditor.button[4], "NormalTextColour", "FFFFFFFF") GUIEditor.button[5] = guiCreateButton(248, 46, 109, 51, "Armas", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[5], font_0) guiSetProperty(GUIEditor.button[5], "NormalTextColour", "FFFFFFFF") GUIEditor.button[6] = guiCreateButton(248, 103, 109, 51, "Morir", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[6], font_0) guiSetProperty(GUIEditor.button[6], "NormalTextColour", "FFFFFFFF") GUIEditor.button[7] = guiCreateButton(9, 338, 110, 51, "Crear Vehiculo", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[7], font_0) guiSetProperty(GUIEditor.button[7], "NormalTextColour", "FFFFFFFF") GUIEditor.label[1] = guiCreateLabel(255, 336, 97, 31, "Caerse de la \nMoto:", false, GUIEditor.window[1]) local font_1 = guiCreateFont("EmblemaOne.ttf") guiSetFont(GUIEditor.label[1], font_1) guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) GUIEditor.checkbox[1] = guiCreateCheckBox(294, 370, 15, 18, "", false, false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(9, 154, 347, 18, "---------------------------------------------------------------------------------------------------------", false, GUIEditor.window[1]) GUIEditor.label[3] = guiCreateLabel(9, 302, 347, 15, "---------------------------------------------------------------------------------------------------------------------", false, GUIEditor.window[1]) GUIEditor.label[4] = guiCreateLabel(10, 19, 347, 27, "Beneficios de los Jugadores:", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[4], font_1) guiLabelSetHorizontalAlign(GUIEditor.label[4], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[4], "center") GUIEditor.label[5] = guiCreateLabel(9, 312, 343, 24, "Apartado de los Carros:", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[5], font_1) guiLabelSetHorizontalAlign(GUIEditor.label[5], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[5], "center") GUIEditor.label[6] = guiCreateLabel(9, 172, 347, 23, "Otros Beneficios:", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[6], font_1) guiLabelSetHorizontalAlign(GUIEditor.label[6], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[6], "center") GUIEditor.button[8] = guiCreateButton(9, 201, 110, 51, "Skins Jura", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[8], font_0) guiSetProperty(GUIEditor.button[8], "NormalTextColour", "FFFFFFFF") GUIEditor.button[9] = guiCreateButton(247, 200, 109, 51, "Skins Staff/VIP", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[9], font_0) guiSetProperty(GUIEditor.button[9], "NormalTextColour", "FFFFFFFF") GUIEditor.button[10] = guiCreateButton(131, 201, 106, 50, "Skins Modificados", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[10], font_0) guiSetProperty(GUIEditor.button[10], "NormalTextColour", "FFFFFFFF") GUIEditor.button[11] = guiCreateButton(131, 257, 108, 50, "Panel de Ayuda", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[11], font_0) guiSetProperty(GUIEditor.button[11], "NormalTextColour", "FFFFFFFF") GUIEditor.button[12] = guiCreateButton(131, 338, 108, 50, "Volcar Vehiculo", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[12], font_0) guiSetProperty(GUIEditor.button[12], "NormalTextColour", "FFFFFFFF") --------------------------- -- Set skin window --------------------------- function skinInid () setControlNumber(wndSkin, 'skinid', getElementModel(g_Me)) end function showSkinID(leaf) if leaf.id then setControlNumber(wndSkin, 'skinid', leaf.id) end end function applySkin() local skinID = getControlNumber(wndSkin, 'skinid') if skinID then server.setMySkin(skinID) fadeCamera(true) end end addEventHandler("onClientGUIClick",GUIEditor.button[1], function () wndSkin = { 'wnd', text = 'Poner Skin', width = 250, x = -20, y = 0.3, controls = { { 'lst', id='skinlist', width=230, height=290, columns={ {text="Skins", attr='name'} }, rows={xml='skins.xml', attrs={'id', 'name'}}, onitemclick=showSkinID, onitemdoubleclick=applySkin }, {'txt', id='skinid', text='', width=50}, {'btn', id='Poner', onclick=applySkin}, {'btn', id='Cerrar', closeswindow=true} }, oncreate = skinInit } end ) function setSkinCommand(cmd, skin) skin = skin and tonumber(skin) if skin then server.setMySkin(skin) fadeCamera(true) closeWindow(wndSpawnMap) closeWindow(wndSetPos) end end --------------------------- --- Set animation window --------------------------- function applyAnimation(leaf) if type(leaf) ~= 'table' then leaf = getSelectedGridListLeaf(wndAnim, 'animlist') if not leaf then return end end server.setPedAnimation(g_Me, leaf.parent.name, leaf.name, true, true) end function stopAnimation() server.setPedAnimation(g_Me, false) end addEventHandler("onClientGUIClick",GUIEditor.button[3], function () wndAnim = { 'wnd', text = 'Poner Animacion', width = 250, x = -20, y = 0.3, controls = { { 'lst', id='animlist', width=230, height=290, columns={ {text="Animaciones", attr='name'} }, rows={xml='animations.xml', attrs={'name'}}, expandlastlevel=false, onitemdoubleclick=applyAnimation }, {'btn', id='Poner', onclick=applyAnimation}, {'btn', id='Parar', onclick=stopAnimation}, {'btn', id='Cerrar', closeswindow=true} } } end ) addCommandHandler('anim', function(command, lib, name) server.setPedAnimation(g_Me, lib, name, true, true) end ) --------------------------- -- Weapon window --------------------------- function addWeapon(leaf, amount) if type(leaf) ~= 'table' then leaf = getSelectedGridListLeaf(wndWeapon, 'weaplist') amount = getControlNumber(wndWeapon, 'amount') if not amount or not leaf then return end end server.giveMeWeapon(leaf.id, amount) end addEventHandler("onClientGUIClick",GUIEditor.button[5], function () wndWeapon = { 'wnd', text = 'Escoger Armas', width = 250, controls = { { 'lst', id='weaplist', width=230, height=280, columns={ {text='Arma', attr='name'} }, rows={xml='weapons.xml', attrs={'id', 'name'}}, onitemdoubleclick=function(leaf) addWeapon(leaf, 500) end }, {'br'}, {'txt', id='amount', text='500', width=60}, {'btn', id='Coger', onclick=addWeapon}, {'btn', id='Cerrar', closeswindow=true} } } end ) function giveWeaponCommand(cmd, weapon, amount) weapon = tonumber(weapon) or getWeaponIDFromName(weapon) if not weapon then return end amount = amount and tonumber(amount) or 500 server.giveMeWeapon(math.floor(weapon), amount) end --------------------------- -- Fighting style --------------------------- addCommandHandler('estilo', function(cmd, style) style = style and tonumber(style) if style then server. Link to comment
Castillo Posted May 27, 2013 Share Posted May 27, 2013 That's because you can't just change the GUI to a new one. Link to comment
Lucario Posted May 27, 2013 Author Share Posted May 27, 2013 how can i change the buttons and labels too? Link to comment
Blaawee Posted May 28, 2013 Share Posted May 28, 2013 use these function function guiCreateWindow( x, y, width, height, text, relative ) local window = guiCreateStaticImage ( x, y, width, height, "filePath.png", relative ); -- Dont forget to add here the custome functoin local close = guiCreateStaticImage ( width - 55, 5, 50, 30, "closeButtonFilePath.png", relative, window ); -- And here local header = guiCreateLabel ( 50, 0, 400, 100, text, false, window ); guiSetEnabled ( header, false ); addEventHandler( 'onClientGUIClick', close, function( ) guiSetVisible( window, false ); end ); return window; end function guiCreateButton( x, y, width, height, text, relative ) local button = guiCreateStaticImage ( x, y, width, height, "filePath.png", relative ); -- And here. local buttonText = guiCreateLabel ( x / 2 - width / 2, y / 2 - height / 2, width, height, text, false, button ); guiLabelSetColor( buttonText, 135, 0, 0 ); addEventHandler( 'onClientMouseEnter', guiRoot, function( ) if source == buttonText then guiLabelSetColor( source, 0, 135, 0 ); else guiLabelSetColor( source, 135, 0, 0 ); end end ); return button; end 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