FSXTim Posted May 26, 2012 Share Posted May 26, 2012 Hello, I created an edit in my GUI. The player can put a text in it and he can also sent it to all the players. clientside: function sendenButton (state) if state == "left" then if source == senden_button then local localp = getLocalPlayer() local memoText = guiGetText(edit_memo) if memoText ~= "" then triggerServerEvent("userpanelText", getLocalPlayer(), localp, memoText) guiSetText(edit_memo, "") else outoutChatBox("Du hast keinen Text eingegeben!", 255, 48, 48) end end end end addEventHandler("onClientGUIClick", getRootElement(), sendenButton) serverside: function userpanelText (localp, memoText) local name = getPlayerName(localp) outputChatBox("#FF0000"..name.."#FFFFFF: "..memoText.."", getRootElement(), 255, 255, 255, true) end addEvent ( "userpanelText", true ) addEventHandler ( "userpanelText", getRootElement(), userpanelText ) Problem: When I put a text in the edit and press the button 'Senden', everything is working, example: "FSXTim: Hello!" But when I do only press on the button 'Senden" and when I don't put a text in the edit, the chatbox sais that: "Tim:" But it has to tell the local player: "Du hast keinen Text eingegeben!": if memoText ~= "" then triggerServerEvent("userpanelText", getLocalPlayer(), localp, memoText) guiSetText(edit_memo, "") else outoutChatBox("Du hast keinen Text eingegeben!", 255, 48, 48) Greets Link to comment
Guest Guest4401 Posted May 26, 2012 Share Posted May 26, 2012 Change outoutChatBox to outputChatBox Link to comment
FSXTim Posted May 26, 2012 Author Share Posted May 26, 2012 What the fu**? Sorry, but I didn't see that. My mistake. Thank you! Greets Link to comment
FSXTim Posted May 26, 2012 Author Share Posted May 26, 2012 But it's still not working! Greets Link to comment
abu5lf Posted May 26, 2012 Share Posted May 26, 2012 function sendenButton (state) if state == "left" then if source == senden_button then local localp = getLocalPlayer() local memoText = guiGetText(edit_memo) if memoText ~= "" then triggerServerEvent("userpanelText", getLocalPlayer(), localp, memoText) guiSetText(edit_memo, "") elseif memoText ~= nil then outputChatBox("Du hast keinen Text eingegeben!", 255, 48, 48) end end end end addEventHandler("onClientGUIClick", getRootElement(), sendenButton) Link to comment
FSXTim Posted May 26, 2012 Author Share Posted May 26, 2012 function sendenButton (state) if state == "left" then if source == senden_button then local localp = getLocalPlayer() local memoText = guiGetText(edit_memo) if memoText ~= "" then triggerServerEvent("userpanelText", getLocalPlayer(), localp, memoText) guiSetText(edit_memo, "") elseif memoText ~= nil then outputChatBox("Du hast keinen Text eingegeben!", 255, 48, 48) end end end end addEventHandler("onClientGUIClick", getRootElement(), sendenButton) Thanks, but still not working. When I don't put a text in the edit, the chatbox sais: "Tim:" Link to comment
Alpha Posted May 26, 2012 Share Posted May 26, 2012 Maybe try: function sendenButton (state) if state == "left" then if source == senden_button then local localp = getLocalPlayer() local memoText = guiGetText(edit_memo) if memoText ~= "" and memoText:len() > 1 then triggerServerEvent("userpanelText", getLocalPlayer(), localp, memoText) guiSetText(edit_memo, "") else outoutChatBox("Du hast keinen Text eingegeben!", 255, 48, 48) end end end end addEventHandler("onClientGUIClick", getRootElement(), sendenButton) Link to comment
FSXTim Posted May 26, 2012 Author Share Posted May 26, 2012 That's working. Thanks, sir! Greets 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