mouadys Posted January 19, 2014 Share Posted January 19, 2014 (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 January 19, 2014 by Guest Link to comment
Gallardo9944 Posted January 19, 2014 Share Posted January 19, 2014 toggleControl (chatbox, false) -- WRONG toggleControl("chatbox",false) -- CORRECT Link to comment
50p Posted January 19, 2014 Share Posted January 19, 2014 - chatbox needs to be string: toggleControl( "chatbox", false ); - Server doesn't have any GUI functions. You have to send the skin ID to the server instead. Link to comment
mouadys Posted January 19, 2014 Author Share Posted January 19, 2014 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 ? Link to comment
Gallardo9944 Posted January 19, 2014 Share Posted January 19, 2014 admin panel WILL open no matter what, only if you change the admin panel code. Set your element data to true when it's opened and to false when it isn't and check it in the admin panel code (can't exactly say what file, but you can find it with "bindKey" and the function inside it) Link to comment
mouadys Posted January 19, 2014 Author Share Posted January 19, 2014 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 . Link to comment
50p Posted January 19, 2014 Share Posted January 19, 2014 - 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. Link to comment
mouadys Posted January 19, 2014 Author Share Posted January 19, 2014 Here is the code (its from Clientside) . triggerServerEvent ("changeSkin", localPlayer, item, skin, player, playerh) Is it correct ? Because it still not working Link to comment
50p Posted January 19, 2014 Share Posted January 19, 2014 Because you still need to change the code in the server-side script. Read the wiki code sample again and see. Your changeSkin function doesn't have any parameters so it doesn't know about the data you're sending. Remove any GUI code from server-side script. Link to comment
mouadys Posted January 20, 2014 Author Share Posted January 20, 2014 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' ] 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