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

Use This @ Server Side Sorry :mrgreen:

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

@Mr.Pres[T]ege

The script works well, i added something, so when you click te select button, the window will also get away.

Now i added a 2nd button, when you click on it, it will preview the skin, this is the new code.

===Server-side===

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

===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[2] = guiCreateButton(156, 31, 77, 26, "Preview", false, GUIEditor.window[1]) 
guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") 
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[2]",root, 
    function() 
                if (source == GUIEditor.button[2]) 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[2]", localPlayer,  id)                   
                        end 
                end 
        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) 
                            guiSetVisible(GUIEditor.window[1], false) 
                            showCursor(false) 
                        end 
                end 
        end 
) 
  
addEvent("show",true) 
addEventHandler("show",root, 
function () 
guiSetVisible(GUIEditor.window[1], true) 
showCursor(true) 
end) 
  

But now when i click the "preview" button, nothing will happen, how can i fix this?

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[2] = guiCreateButton(156, 31, 77, 26, "Preview", false, GUIEditor.window[1]) 
guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") 
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[2]) 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[2]", localPlayer,  id)                   
                        end 
                end 
        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) 
                            guiSetVisible(GUIEditor.window[1], false) 
                            showCursor(false) 
                        end 
                end 
        end 
) 
  
addEvent("show",true) 
addEventHandler("show",root, 
function () 
guiSetVisible(GUIEditor.window[1], true) 
showCursor(true) 
end) 
  

You don,t have to change event name onClientGUIClick and onClientGUIClick[2] make no sense .

Posted

But this still not work?

  
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
But this still not work?
  
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 
  

When you want to happen when admin log in?

Posted

I tried to add something, so the gui does only showup on a non-admin player.

It doesn't work, i tried to add this function:

hasObjectPermissionTo 

on this:

  
addEvent("show",true) 
addEventHandler("show",root, 
function () 
guiSetVisible(GUIEditor.window[1], true) 
showCursor(true) 
end) 
  

How must i get it to work.

Posted
I tried to add something, so the gui does only showup on a non-admin player.

It doesn't work, i tried to add this function:

hasObjectPermissionTo 

on this:

  
addEvent("show",true) 
addEventHandler("show",root, 
function () 
guiSetVisible(GUIEditor.window[1], true) 
showCursor(true) 
end) 
  

How must i get it to work.

You Want The GUI For Admin Only ?

Posted
  
    function setAdminSkin() 
        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 
  

When do you trigger this function?

Posted
  
    function setAdminSkin() 
        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 
  

When do you trigger this function?

A bit late, it's almost fixed.

Posted
So You Want It For Admin Only I Mean The GUI ?

I want the GUI for non-admins.

For this:

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

It will not give me the skin i want, everytime i die and get alive, i will get another skin, not ID 286.

Posted

addEventHandler("onPlayerSpawn", root, 
function () 
    if hasObjectPermissionTo(source, "command.ban", true) then 
    setElementModel(source,math.random (1,400)) 
    outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",source,255,0,0) 
    end 
end) 
  
Posted
addEventHandler("onPlayerSpawn", root, 
function () 
    if hasObjectPermissionTo(source, "command.ban", true) then 
    setElementModel(source,math.random (1,400)) 
    outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",source,255,0,0) 
    end 
end) 
  

That's not what i mean, i mean that i will not get the skin i want, when i get alive, after i died.

How can i fix it.

===server-side===

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

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