FSXTim Posted May 26, 2012 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
FSXTim Posted May 26, 2012 Author Posted May 26, 2012 What the fu**? Sorry, but I didn't see that. My mistake. Thank you! Greets
abu5lf Posted May 26, 2012 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) ╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗ ║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║ ║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║ ║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║ ╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝ «سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك» M7mdAl7arthy : لتواصل سكايب
FSXTim Posted May 26, 2012 Author 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:"
Alpha Posted May 26, 2012 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) My Resources: [REL] Support System v1.0.2
Alpha Posted May 26, 2012 Posted May 26, 2012 You're welcome. My Resources: [REL] Support System v1.0.2
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