Jump to content

GUI to choose skin.


Shazzimal

Recommended Posts

  • Replies 77
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted
gridlist using table, so they can chose out of 10 skins or wathever

You can choose the skin you want set it but edit box will be better for you .

U kunt kiezen voor de huid die u wilt instellen, maar edit box zal beter voor je.

Posted

got this as output from GUIEditor:

GUIEditor = { 
    gridlist = {}, 
    button = {}, 
    memo = {}, 
    window = {}, 
} 
GUIEditor.window[1] = guiCreateWindow(387, 207, 243, 312, "Select a skin please", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
  
GUIEditor.gridlist[1] = guiCreateGridList(9, 25, 135, 269, false, GUIEditor.window[1]) 
guiGridListAddColumn(GUIEditor.gridlist[1], "Skin-name", 0.9) 
for i = 1, 10 do 
    guiGridListAddRow(GUIEditor.gridlist[1]) 
end 
guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "CJ", false, false) 
guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "Hooker", false, false) 
guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "Firefighter", false, false) 
guiGridListSetItemText(GUIEditor.gridlist[1], 3, 1, "Gangster", false, false) 
guiGridListSetItemText(GUIEditor.gridlist[1], 4, 1, "School Girl", false, false) 
guiGridListSetItemText(GUIEditor.gridlist[1], 5, 1, "Ninja", false, false) 
guiGridListSetItemText(GUIEditor.gridlist[1], 6, 1, "Mafia", false, false) 
guiGridListSetItemText(GUIEditor.gridlist[1], 7, 1, "Farmer", false, false) 
guiGridListSetItemText(GUIEditor.gridlist[1], 8, 1, "Chicken", false, false) 
guiGridListSetItemText(GUIEditor.gridlist[1], 9, 1, "Elvis", false, false) 
GUIEditor.button[1] = guiCreateButton(153, 251, 77, 26, "Select", false, GUIEditor.window[1]) 
GUIEditor.memo[1] = guiCreateMemo(155, 66, 73, 127, "You can change the skin, when you login and when you die.", false, GUIEditor.window[1]) 
  

Posted

== Client Side ==

GUIEditor = { 
    gridlist = {}, 
    button = {}, 
    memo = {}, 
    window = {}, 
} 
GUIEditor.window[1] = guiCreateWindow(387, 207, 243, 312, "Select a skin please", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
  
GUIEditor.gridlist[1] = guiCreateGridList(9, 25, 135, 269, false, GUIEditor.window[1]) 
local Column = guiGridListAddColumn(GUIEditor.gridlist[1], "Skin Name", 0.4) 
local Column1 = guiGridListAddColumn(GUIEditor.gridlist[1], "id", 0.4) 
  
GUIEditor.button[1] = guiCreateButton(153, 251, 77, 26, "Select", false, GUIEditor.window[1]) 
guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") 
GUIEditor.memo[1] = guiCreateMemo(155, 66, 73, 127, "You can change the skin, when you login and when you die.", false, GUIEditor.window[1]) 
  
Skins = { 
{"CJ",skinid},  
{"Hooker",skinid},  
{"Firefighter",skinid}, 
{"Gangster",skinid}, 
{"SchoolGirl",skinid}, 
{"Ninja",skinid}, 
{"Mafia",skinid}, 
{"Farmer",skinid}, 
{"Chicken",skinid}, 
{"Elvis",skinid} 
} 
  
for i,v in ipairs (Skins) do 
  local row = guiGridListAddRow (GUIEditor.gridlist[1]) 
  guiGridListSetItemText (GUIEditor.gridlist[1], row, 1, v[1], false, true) 
  guiGridListSetItemText (GUIEditor.gridlist[1], row, 2, v[2], false, true) 
end 
  
addEventHandler("onClientGUIClick",root, 
    function() 
                if (source == GUIEditor.button[1]) then 
                        local row,Column = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) 
                        local id = tostring ( guiGridListGetItemText(GUIEditor.gridlist[1], row, 2 )) 
                        if ( row and Column and row ~= -1 and Column ~= -1 ) then  
                            triggerServerEvent("onChose", localPlayer,  id) 
                        end 
                end 
        end 
) 

== Server Side ==

addEvent("onChose", true) 
addEventHandler("onChose", root, 
    function(id) 
         setElementModel(source,tonumber(id)) 
    end 
) 

Has not been tested but should work!

Posted

but my script that should give all admins skin 286, doesn't work i tryed to change but always doesn't work:

  
rootElement = getRootElement() 
  
function setAdminSkin() 
    if hasObjectPermissionTo(thePlayer, "command.ban", false) then 
        setElementModel(thePlayer, 286) 
        outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",thePlayer) 
    end 
end 
addEvent("setAdminSkin", true) 
addEventHandler("onPlayerSpawn", rootElement, setAdminSkin) 

allready fixed, now going to try it.

Posted

This should work

  
function setAdminSkin(thePlayer) 
    if hasObjectPermissionTo(thePlayer, "command.ban", true) then 
        setPlayerSkin(thePlayer, 286) 
        outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",thePlayer) 
    end 
end 
  

Posted

function setAdminSkin() 
    if hasObjectPermissionTo(source, "command.ban", true) then 
        setElementModel(source,268) 
        outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",source,255,0,0) 
    end 
end 
Posted

@Mr.Pres[T]ege

The script doesn't show up a GUI.

What i've got in the files:

meta.xml

<meta> 
    <info author="Shazzimal" name="SkinChooser" disc="When you log on, you can select a skin, admin does automaticaly get skin ID286." Version="1.1"/> 
    <script src="server.lua" type="server"/> 
              <script src="gui.lua" type="client"/> 
</meta> 

gui.lua

  
GUIEditor = { 
    gridlist = {}, 
    button = {}, 
    memo = {}, 
    window = {}, 
} 
GUIEditor.window[1] = guiCreateWindow(387, 207, 243, 312, "Select a skin please", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
  
GUIEditor.gridlist[1] = guiCreateGridList(9, 25, 135, 269, false, GUIEditor.window[1]) 
local Column = guiGridListAddColumn(GUIEditor.gridlist[1], "Skin Name", 0.4) 
local Column1 = guiGridListAddColumn(GUIEditor.gridlist[1], "id", 0.4) 
  
GUIEditor.button[1] = guiCreateButton(153, 251, 77, 26, "Select", false, GUIEditor.window[1]) 
guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") 
GUIEditor.memo[1] = guiCreateMemo(155, 66, 73, 127, "You can change the skin, when you login and when you die.", false, GUIEditor.window[1]) 
  
Skins = { 
{"CJ",0},  
{"Hooker",178},  
{"Firefighter",277}, 
{"Gangster",115}, 
{"SchoolGirl",152}, 
{"Ninja",204}, 
{"Mafia",166}, 
{"Farmer",161}, 
{"Chicken",167}, 
{"Elvis",82} 
} 
  
for i,v in ipairs (Skins) do 
  local row = guiGridListAddRow (GUIEditor.gridlist[1]) 
  guiGridListSetItemText (GUIEditor.gridlist[1], row, 1, v[1], false, true) 
  guiGridListSetItemText (GUIEditor.gridlist[1], row, 2, v[2], false, true) 
end 
  
addEventHandler("onClientGUIClick",root, 
    function() 
                if (source == GUIEditor.button[1]) then 
                        local row,Column = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) 
                        local id = tostring ( guiGridListGetItemText(GUIEditor.gridlist[1], row, 2 )) 
                        if ( row and Column and row ~= -1 and Column ~= -1 ) then  
                            triggerServerEvent("onPlayerLogin", localPlayer,  id) 
                        end 
                end 
        end 
) 
  

server.lua

  
addEvent("onPlayerLogin", true) 
addEventHandler("onPlayerLogin", root, 
    function(id) 
         setElementModel(source,tonumber(id)) 
    end 
) 
  

It does show up a GUI but when i select one and click the select button, nothing happens. And i must first pres t, so i get a cursor, and then i can select things. But doesn't work.

Posted

== Client Side ==

 GUIEditor = { 
    gridlist = {}, 
    button = {}, 
    memo = {}, 
    window = {}, 
} 
GUIEditor.window[1] = guiCreateWindow(387, 207, 243, 312, "Select a skin please", false) 
guiSetVisible(GUIEditor.window[1], false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
  
GUIEditor.gridlist[1] = guiCreateGridList(9, 25, 135, 269, false, GUIEditor.window[1]) 
local Column = guiGridListAddColumn(GUIEditor.gridlist[1], "Skin Name", 0.4) 
local Column1 = guiGridListAddColumn(GUIEditor.gridlist[1], "id", 0.4) 
  
GUIEditor.button[1] = guiCreateButton(153, 251, 77, 26, "Select", false, GUIEditor.window[1]) 
guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") 
GUIEditor.memo[1] = guiCreateMemo(155, 66, 73, 127, "You can change the skin, when you login and when you die.", false, GUIEditor.window[1]) 
  
Skins = { 
{"CJ",0},  
{"Hooker",178},  
{"Firefighter",277}, 
{"Gangster",115}, 
{"SchoolGirl",152}, 
{"Ninja",204}, 
{"Mafia",166}, 
{"Farmer",161}, 
{"Chicken",167}, 
{"Elvis",82} 
} 
  
for i,v in ipairs (Skins) do 
  local row = guiGridListAddRow (GUIEditor.gridlist[1]) 
  guiGridListSetItemText (GUIEditor.gridlist[1], row, 1, v[1], false, true) 
  guiGridListSetItemText (GUIEditor.gridlist[1], row, 2, v[2], false, true) 
end 
  
addEventHandler("onClientGUIClick",root, 
    function() 
                if (source == GUIEditor.button[1]) then 
                        local row,Column = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) 
                        local id = tostring ( guiGridListGetItemText(GUIEditor.gridlist[1], row, 2 )) 
                        if ( row and Column and row ~= -1 and Column ~= -1 ) then  
                            triggerServerEvent("onClick", localPlayer,  id) 
                        end 
                end 
        end 
) 
  
addEvent("show",true) 
addEventHandler("show",root, 
function () 
guiSetVisible(GUIEditor.window[1], true) 
showCursor(true) 
end) 
  

== Server Side ==

addEvent("onClick", true) 
addEventHandler("onClick", root, 
    function(id) 
         setElementModel(source,tonumber(id)) 
    end 
) 
  
addEventHandler("onPlayerLogin", root, 
function () 
triggerClientEvent("show",root) 
end) 

Login To The Server And The GUI Will Start .

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