Tekken Posted March 6, 2015 Share Posted March 6, 2015 Hi, i need some help with GUI i need to get data from an edit box and pass it to server, and i don't know how My code: Clinet function setPanel() window = guiCreateWindow(472, 206, 288, 329, "Panel", false) button = guiCreateButton(162, 221, 116, 44, "Proceed", false, window) edit = guiCreateEdit(29, 69, 107, 34, "", false,window) end addEventHandler("onClientResourceStart", resourceRoot,setPanel) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function() if (source == button) then triggerServerEvent("onClientProceedToRecover", localPlayer) end end ) Link to comment
JR10 Posted March 6, 2015 Share Posted March 6, 2015 You need to add the event server-side and handle it. addEvent("onClientProceedToRecover", true) addEventHandler("onClientProceedToRecover", root, function() -- code end) Link to comment
Addlibs Posted March 6, 2015 Share Posted March 6, 2015 Start off by getting the edit box's input via guiGetText(edit) triggerServerEvent("onClientProceedToRecover", localPlayer, guiGetText(edit)) Link to comment
Tekken Posted March 6, 2015 Author Share Posted March 6, 2015 (edited) I got this error : recovergui-system\recover_s.lua:16: Bad argument @ 'outputChatBox' [Expected element at argument 2, got string 'mihayy58'] My code: Server function recoverPasswordFromIdAndAccount(accname, Id, thePass) local theAccount = getAccount(accname) if theAccount then local theIDinAcc = getAccountData(theAccount, "AccID") if theIDinAcc then if tonumber(Id) == theIDinAcc then setAccountPassword(theAccount, thePass) outputChatBox("#FF0000[save-System] #00FF00Parola contului a fost schimbata cu succes!", client, 255, 0, 0, true) else outputChatBox("#FF0000[save-System] #00FF00ID_Unic dat nu este corect!", client, 255, 255, 255, true) end else outputChatBox("#FF0000[save-System] #00FF00Incearca cu#FFFFFF '/recover [username] [iD_Unic] [Parola_Noua]' #00FF00!", client, 255, 255, 255, true) end else outputChatBox("#FF0000[save-System] #00FF00Username-ul dat nu este valid!", client, 255, 255, 255, true) end end addEvent("onClientProceedToRecover",true) addEventHandler("onClientProceedToRecover", getResourceRootElement(getThisResource()), recoverPasswordFromIdAndAccount) --GIVE AN Unic_ID rootElement = getRootElement() function setPlayerAccountIdOnLogin() local theAcc = getPlayerAccount(source) if theAcc then local theRecCheck = getAccountData(theAcc, "REC") if theRecCheck == 1 then outputChatBox("#FF0000[save-System] #00FF00IDul tau unic este disponibil la #FFFFFF/myid", source, 255, 255, 255, true) end if theRecCheck == 0 then setAccountData(theAcc, "AccID", math.random(1, 99999)) setAccountData(theAcc, "REC", 1) outputChatBox("#FF0000[save-System] #00FF00IDul tau unic este disponibil la #FFFFFF/myid", source, 255, 255, 255, true) outputChatBox("#00FF00*Nu da acest ID_Unic la nimeni!", source, 255, 255, 255, true) end end end addEventHandler("onPlayerLogin", rootElement, setPlayerAccountIdOnLogin) Client GUIEditor = { button = {}, window = {}, label = {}, edit = {} } function shouRecoverInterface() GUIEditor.window[1] = guiCreateWindow(472, 206, 288, 329, "Recover Password by mihayy5 v2.0", false) guiWindowSetMovable(GUIEditor.window[1], true) guiSetVisible(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(162, 221, 116, 44, "Proceed", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], "default-bold-small") guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF48FF00") GUIEditor.button[2] = guiCreateButton(162, 271, 116, 44, "Close", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[2], "default-bold-small") guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFFF0000") GUIEditor.edit[1] = guiCreateEdit(29, 69, 107, 34, "", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(48, 49, 98, 30, "Username", false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(48, 113, 98, 30, "ID_Unic", false, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(29, 137, 107, 34, "", false, GUIEditor.window[1]) GUIEditor.label[3] = guiCreateLabel(48, 181, 98, 30, "Parola Noua", false, GUIEditor.window[1]) GUIEditor.edit[3] = guiCreateEdit(29, 206, 107, 34, "", false, GUIEditor.window[1]) end addEventHandler("onClientResourceStart", resourceRoot,shouRecoverInterface) function openRecover() guiSetVisible(GUIEditor.window[1],true) showCursor(true) end addCommandHandler("recover", openRecover) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function() if (source == GUIEditor.button[2]) then guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end ) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function() if (source == GUIEditor.button[1]) then local accname = guiGetText(GUIEditor.edit[1]) local Id = guiGetText(GUIEditor.edit[2])) local thePass = guiGetText(GUIEditor.edit[3]) triggerServerEvent(localPlayer, "onClientProceedToRecover", localPlayer, accname, Id, thePass) end ) Edited March 6, 2015 by Guest Link to comment
crismar Posted March 6, 2015 Share Posted March 6, 2015 triggerServerEvent provides a sends to the server the client (element) that triggered the event in the form of the 'client' variable. Replace your 'source' with 'client' in order to get it working properly. Link to comment
Tekken Posted March 6, 2015 Author Share Posted March 6, 2015 Still get the same error. Link to comment
Addlibs Posted March 6, 2015 Share Posted March 6, 2015 The error message states you push a string instead of an element for the 2nd parameter (the player who shall receive the chatbox message). However, it's impossible that 'client' or 'source' contain a string, or anything else other than an element value. My guess is that you haven't corrected the code still, maybe you saved it in the wrong place? Link to comment
Tekken Posted March 6, 2015 Author Share Posted March 6, 2015 Look: Client GUIEditor = { button = {}, window = {}, label = {}, edit = {} } function shouRecoverInterface() GUIEditor.window[1] = guiCreateWindow(472, 206, 288, 329, "Recover Password by mihayy5 v2.0", false) guiWindowSetMovable(GUIEditor.window[1], true) guiSetVisible(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(162, 221, 116, 44, "Proceed", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], "default-bold-small") guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF48FF00") GUIEditor.button[2] = guiCreateButton(162, 271, 116, 44, "Close", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[2], "default-bold-small") guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFFF0000") GUIEditor.edit[1] = guiCreateEdit(29, 69, 107, 34, "", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(48, 49, 98, 30, "Username", false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(48, 113, 98, 30, "ID_Unic", false, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(29, 137, 107, 34, "", false, GUIEditor.window[1]) GUIEditor.label[3] = guiCreateLabel(48, 181, 98, 30, "Parola Noua", false, GUIEditor.window[1]) GUIEditor.edit[3] = guiCreateEdit(29, 206, 107, 34, "", false, GUIEditor.window[1]) end addEventHandler("onClientResourceStart", resourceRoot,shouRecoverInterface) function openRecover() guiSetVisible(GUIEditor.window[1],true) showCursor(true) end addCommandHandler("recover", openRecover) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function() if (source == GUIEditor.button[2]) then guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end ) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function() if (source == GUIEditor.button[1]) then local accname = guiGetText(GUIEditor.edit[1]) local id = guiGetText(GUIEditor.edit[2]) local thePass = guiGetText(GUIEditor.edit[3]) triggerServerEvent("onClientProceedToRecover", localPlayer, accname, id, thePass) end end ) Server function recoverPasswordFromIdAndAccount(player, cmd, accname, Id, thePass) local passAccount = getAccount(accname) if passAccount then local theIDinAcc = getAccountData(passAccount, "AccID") if theIDinAcc then if tonumber(Id) == theIDinAcc then setAccountPassword(passAccount, thePass) outputChatBox("#FF0000[save-System] #00FF00Parola contului a fost schimbata cu succes!", client, 255, 0, 0, true) else outputChatBox("#FF0000[save-System] #00FF00Incearca cu#FFFFFF '/recover [username] [iD_Unic] [Parola_Noua]' #00FF00!", client, 255, 255, 255, true) end else outputChatBox("#FF0000[save-System] #00FF00ID_Unic dat nu este corect!", client, 255, 255, 255, true) end else outputChatBox("#FF0000[save-System] #00FF00Username-ul dat nu exista!", client, 255, 0, 0, true) end end addEvent("onClientProceedToRecover",true) addEventHandler("onClientProceedToRecover", root, recoverPasswordFromIdAndAccount) --GIVE AN Unic_ID rootElement = getRootElement() function setPlayerAccountIdOnLogin() local theAcc = getPlayerAccount(source) if theAcc then local theRecCheck = getAccountData(theAcc, "REC") if theRecCheck == 1 then outputChatBox("#FF0000[save-System] #00FF00IDul tau unic este disponibil la #FFFFFF/myid", source, 255, 255, 255, true) end if theRecCheck == 0 then setAccountData(theAcc, "AccID", math.random(1, 99999)) setAccountData(theAcc, "REC", 1) outputChatBox("#FF0000[save-System] #00FF00IDul tau unic este disponibil la #FFFFFF/myid", source, 255, 255, 255, true) outputChatBox("#00FF00*Nu da acest ID_Unic la nimeni!", source, 255, 255, 255, true) end end end addEventHandler("onPlayerLogin", rootElement, setPlayerAccountIdOnLogin) Link to comment
Tekken Posted March 7, 2015 Author Share Posted March 7, 2015 #SOLVED My guess is that you haven't corrected the code still, maybe you saved it in the wrong place? You were correct. 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