Jump to content

GUI help


Evil#

Recommended Posts

Hi there, i was trying to make a script in which i click grid list item "Punk" and it will set my skin to 181 but i could not so please help me.

Another help that i need is the window is enabled when the resource starts and the bindkey is not working.

  
window = guiCreateWindow(266, 121, 184, 287, "Skin Panel", false) 
guiWindowSetSizable(window, false) 
bindKey( "F1", "down", guiSetVisible(window)) 
showCursor(true) 
gridlist = guiCreateGridList(9, 20, 165, 257, false, window) 
guiGridListAddColumn(gridlist, "Skins", 0.9) 
guiGridListAddRow(gridlist) 
guiGridListSetItemText(gridlist, 0, 1, "Punk", false, false) 
  

Link to comment

Untested.

addEventHandler("onClientResourceStart", resourceRoot, 
function() 
window = guiCreateWindow(266, 121, 184, 287, "Skin Panel", false) 
guiWindowSetSizable(window, false) 
gridlist = guiCreateGridList(9, 20, 165, 257, false, window) 
column = guiGridListAddColumn(gridlist, "Skins", 0.9) 
for i = 1, 1 do 
guiGridListAddRow(window) 
end 
guiGridListSetItemText(gridlist, 0, 1, "Punk", false, false) 
--you need to create a button here as well. Name it something like "Select". 
guiSetVisible(window, false) 
end 
) 
  
function showTheGui() 
local v = guiGetVisible( window ) 
guiSetVisible(window, not v ) 
showCursor ( not isCursorShowing ( ) ) 
end 
addCommandHandler("opengui", showTheGui) 
bindKey("F1", "down", showTheGui)  
  
function setTheSkin() 
if ( source == yourButtonElement ) then 
    local row = guiGridListGetSelectedItem( gridlist ) 
    local name = guiGridListGetItemText( window, row, column) 
    if name == "Punk" then 
        setElementModel(localPlayer, skinID)  
end 
end 
end 
addEventHandler("onClientGUIClick", root, setTheSkin) 

Next time, no one is going to make the whole code for you. Take it as an example and learn.

Link to comment

Not Working, I've also added a button

  
addEventHandler("onClientResourceStart", resourceRoot, 
function() 
window = guiCreateWindow(266, 121, 184, 287, "Skin Panel", false) 
guiWindowSetSizable(window, false) 
gridlist = guiCreateGridList(9, 20, 165, 257, false, window) 
column = guiGridListAddColumn(gridlist, "Skins", 0.9) 
for i = 1, 1 do 
guiGridListAddRow(window) 
end 
guiGridListSetItemText(gridlist, 0, 1, "Punk", false, false) 
button = guiCreateButton(23, 205, 121, 42, "SELECT", false, gridlist) 
guiSetVisible(window, false) 
end 
) 
  
function showTheGui() 
local v = guiGetVisible( window ) 
guiSetVisible(window, not v ) 
showCursor(v) 
end 
addCommandHandler("opengui", showTheGui) 
bindKey("F1", "down", showTheGui) 
  
function setTheSkin() 
if ( source == button ) then 
    local row = guiGridListGetSelectedItem( gridlist ) 
    local name = guiGridListGetItemText( window, row, column) 
    if name == "Punk" then 
        setElementModel(localPlayer, 181) 
end 
end 
end 
addEventHandler("onClientGUIClick", root, setTheSkin) 
  

Link to comment
  
      
    addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
    window = guiCreateWindow(266, 121, 184, 287, "Skin Panel", false) 
    guiWindowSetSizable(window, false) 
    gridlist = guiCreateGridList(9, 20, 165, 257, false, window) 
    column = guiGridListAddColumn(gridlist, "Skins", 0.9) 
    local row = guiGridListAddRow(gridlist) 
    guiGridListSetItemText(gridlist, row, column, "Punk", false, false) 
    button = guiCreateButton(23, 205, 121, 42, "SELECT", false, gridlist) 
    addEventHandler("onClientGUIClick", button, setTheSkin) 
    guiSetVisible(window, false) 
    end 
    ) 
      
    function showTheGui() 
    local v = guiGetVisible( window ) 
    guiSetVisible(window, not v ) 
    showCursor(v) 
    end 
    addCommandHandler("opengui", showTheGui) 
    bindKey("F1", "down", showTheGui) 
      
    function setTheSkin(button, state) 
    if ( source == button ) and (button =="left") then 
        local row, col = guiGridListGetSelectedItem( gridlist ) 
        local name = guiGridListGetItemText( gridlist , row, col) 
        if (row==-1) or (col==-1) then return end 
        if name == "Punk" then 
            setElementModel(localPlayer, 181) 
    end 
    end 
    end 
    addEventHandler("onClientGUIClick", root, setTheSkin) 
      
  

Try this, didn't test but seems ok

Link to comment
Not Working, I've also added a button
  
addEventHandler("onClientResourceStart", resourceRoot, 
function() 
window = guiCreateWindow(266, 121, 184, 287, "Skin Panel", false) 
guiWindowSetSizable(window, false) 
gridlist = guiCreateGridList(9, 20, 165, 257, false, window) 
column = guiGridListAddColumn(gridlist, "Skins", 0.9) 
for i = 1, 1 do 
guiGridListAddRow(window) 
end 
guiGridListSetItemText(gridlist, 0, 1, "Punk", false, false) 
button = guiCreateButton(23, 205, 121, 42, "SELECT", false, gridlist) 
guiSetVisible(window, false) 
end 
) 
  
function showTheGui() 
local v = guiGetVisible( window ) 
guiSetVisible(window, not v ) 
showCursor(v) 
end 
addCommandHandler("opengui", showTheGui) 
bindKey("F1", "down", showTheGui) 
  
function setTheSkin() 
if ( source == button ) then 
    local row = guiGridListGetSelectedItem( gridlist ) 
    local name = guiGridListGetItemText( window, row, column) 
    if name == "Punk" then 
        setElementModel(localPlayer, 181) 
end 
end 
end 
addEventHandler("onClientGUIClick", root, setTheSkin) 
  

Change this:

button = guiCreateButton(23, 205, 121, 42, "SELECT", false, gridlist) 

to:

button = guiCreateButton(23, 205, 121, 42, "SELECT", false, window) 

My code was correct, your arguments to add a button were a bit wrong.

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