Jump to content

Problem with a GUI


mouadys

Recommended Posts

Posted (edited)

Hello , i made a gui to change player skin but it doesn't work

Client-side

GUIEditor = { 
    label = {}, 
    edit = {}, 
    button = {}, 
    window = {}, 
    combobox = {}, 
    memo = {} 
} 
  
  
        GUIEditor.window[1] = guiCreateWindow(451, 289, 327, 426, "Skin", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.combobox[1] = guiCreateComboBox(48, 322, 258, 94, "", false, GUIEditor.window[1]) 
        guiComboBoxAddItem(GUIEditor.combobox[1], "285") 
        guiComboBoxAddItem(GUIEditor.combobox[1], "287") 
        GUIEditor.button[1] = guiCreateButton(68, 360, 197, 44, "Get Skin", false, GUIEditor.window[1]) 
        GUIEditor.memo[1] = guiCreateMemo(27, 63, 279, 163, "This GUI allows you to get a custom skin for you or a player name", false, GUIEditor.window[1]) 
        GUIEditor.edit[1] = guiCreateEdit(47, 261, 255, 31, "", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(129, 242, 218, 15, "Player Name :", false, GUIEditor.window[1]) 
        GUIEditor.label[2] = guiCreateLabel(142, 299, 159, 23, "Skin :", false, GUIEditor.window[1])     
         
  
  
        guiSetVisible(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.combobox[1], false) 
        guiSetVisible(GUIEditor.button[1], false) 
        guiSetVisible(GUIEditor.memo[1], false) 
        guiSetVisible(GUIEditor.edit[1], false) 
        guiSetVisible(GUIEditor.label[2], false) 
        guiSetVisible(GUIEditor.label[1], false) 
  
function OpenGUI() 
        guiSetVisible(GUIEditor.window[1], true) 
        guiSetVisible(GUIEditor.combobox[1], true) 
        guiSetVisible(GUIEditor.button[1], true) 
        guiSetVisible(GUIEditor.memo[1], true) 
        guiSetVisible(GUIEditor.edit[1], true) 
        guiSetVisible(GUIEditor.label[2], true) 
        guiSetVisible(GUIEditor.label[1], true) 
        showCursor(true) 
        guiMemoSetReadOnly ( GUIEditor.memo[1], true ) 
        toggleControl (chatbox, false) 
end 
addCommandHandler("skineditor", OpenGUI) 
function editSkin() 
  triggerServerEvent ("changeSkin", localPlayer) 
end 
addEventHandler("onClientGUIClick", GUIEditor.button[1], editSkin, false) 

There is a problem : toggleControl (chatbox, false) isn't working , when i type text , binds are working

Server-side

function changeSkin() 
  local item = guiComboBoxGetSelected(GUIEditor.combobox[1]) 
  local skin = guiComboBoxGetItemText(GUIEditor.combobox[1], item) 
  local player = guiGetText(GUIEditor.edit[1]) 
  local playerh = getPlayerFromName ( player ) 
  setElementModel ( playerh, skin ) 
end 
addEvent("changeSkin", true) 
addEventHandler("editSkin", root, changeSkin) 

I press the button but nothing happens .

Thank you .

Edited by Guest
Posted

Thank you , the problem with chatbox is fixed , but the admin panel still show on when i press P . And @50p , i dont understand what you mean , can you explain more please ?

Posted

The biggest problem is that the script isn't working , i press the button but nothing happens .

And when i restart the resource , the chatbox still disabled .

Posted

- Admin panel will show up because you're running admin resource which binds "p" to open admin panel.

- When you want to send some data to the server you use triggerServerEvent. If you read on wiki https://wiki.multitheftauto.com/wiki/TriggerServerEvent you can pass some arguments => [argument1, ...] - these arguments will be received by the server. Even the example on the wiki shows you how to do that.

Posted

Here is the code (its from Clientside) .

triggerServerEvent ("changeSkin", localPlayer, item, skin, player, playerh) 

Is it correct ? Because it still not working

Posted

Look at this , here is my code :

Server

function changeSkin(player, playerName, item, skin) 
  setElementModel( player, skin ) 
end 
addEvent("changeSkin", true) 
addEventHandler("changeSkin", root, changeSkin) 

Client

GUIEditor = { 
    label = {}, 
    edit = {}, 
    button = {}, 
    window = {}, 
    combobox = {}, 
    memo = {} 
} 
        GUIEditor.window[1] = guiCreateWindow(451, 289, 327, 426, "Skin", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.combobox[1] = guiCreateComboBox(48, 322, 258, 94, "", false, GUIEditor.window[1]) 
        guiComboBoxAddItem(GUIEditor.combobox[1], "285") 
        guiComboBoxAddItem(GUIEditor.combobox[1], "287") 
  
        GUIEditor.button[1] = guiCreateButton(129, 45, 119, 32, "Close", false, GUIEditor.combobox[1]) 
  
        GUIEditor.button[2] = guiCreateButton(48, 367, 108, 32, "Get Skin", false, GUIEditor.window[1]) 
        GUIEditor.memo[1] = guiCreateMemo(27, 63, 279, 163, "This GUI allows you to get a custom skin for you or a player name", false, GUIEditor.window[1]) 
        GUIEditor.edit[1] = guiCreateEdit(47, 261, 255, 31, "", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(129, 242, 218, 15, "Player Name :", false, GUIEditor.window[1]) 
        GUIEditor.label[2] = guiCreateLabel(142, 299, 159, 23, "Skin :", false, GUIEditor.window[1]) 
  
        guiSetVisible(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.combobox[1], false) 
        guiSetVisible(GUIEditor.button[1], false) 
        guiSetVisible(GUIEditor.memo[1], false) 
        guiSetVisible(GUIEditor.edit[1], false) 
        guiSetVisible(GUIEditor.label[2], false) 
        guiSetVisible(GUIEditor.label[1], false) 
        guiSetVisible(GUIEditor.button[2], false) 
  
function OpenGUI() 
        guiSetVisible(GUIEditor.window[1], true) 
        guiSetVisible(GUIEditor.combobox[1], true) 
        guiSetVisible(GUIEditor.button[1], true) 
        guiSetVisible(GUIEditor.memo[1], true) 
        guiSetVisible(GUIEditor.edit[1], true) 
        guiSetVisible(GUIEditor.label[2], true) 
        guiSetVisible(GUIEditor.label[1], true) 
        guiSetVisible(GUIEditor.button[2], true) 
        showCursor(true) 
        guiMemoSetReadOnly ( GUIEditor.memo[1], true ) 
        toggleControl ("chatbox", false) 
end 
addCommandHandler("skineditor", OpenGUI) 
function editSkin() 
  local item = guiComboBoxGetSelected(GUIEditor.combobox[1]) 
  local skin = guiComboBoxGetItemText(GUIEditor.combobox[1], item) 
  local playerName = guiGetText(GUIEditor.edit[1]) 
  local player = getPlayerFromName ( playerName ) 
  triggerServerEvent ("changeSkin", localPlayer, item, skin, player, playerName) 
end 
function Close() 
  guiSetVisible(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.combobox[1], false) 
        guiSetVisible(GUIEditor.button[1], false) 
        guiSetVisible(GUIEditor.memo[1], false) 
        guiSetVisible(GUIEditor.edit[1], false) 
        guiSetVisible(GUIEditor.button[2], false) 
        guiSetVisible(GUIEditor.label[2], false) 
        guiSetVisible(GUIEditor.label[1], false) 
        showCursor(false) 
        toggleControl ("chatbox", true) 
  end 
addEventHandler("onClientGUIClick", GUIEditor.button[1], Close, false) 
addEventHandler("onClientGUIClick", GUIEditor.button[2], editSkin, false) 

I press the button and i get error on Console : Bad Argument @ 'setElementModel' [Expected element at argument , got number '-1' ]

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