mehmet145 Posted August 24, 2015 Share Posted August 24, 2015 Hi Guys. how to triggerClientEvent for label ? Server-side function; https://wiki.multitheftauto.com/wiki/GetServerName My Label Element Code; GUIEditor = { button = {}, window = {}, edit = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(0.35, 0.32, 0.35, 0.31, "MTA:SA Admin Announce GUI Panel", true) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.edit[1] = guiCreateEdit(0.06, 0.15, 0.87, 0.13, "", true, GUIEditor.window[1]) GUIEditor.button[1] = guiCreateButton(0.21, 0.35, 0.54, 0.21, "Give Announce!", true, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], "default-bold-small") guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF48FE00") label = guiCreateLabel(0.01, 0.31, 0.20, 0.39, "", true) end ) addEventHandler("onClientGUIClick",root, function() if source == GUIEditor.button[1] then guiSetText(label, "[ANNOUNCE]; \n" .. guiGetText ( GUIEditor.edit[1] ) ) end end ) Link to comment
Walid Posted August 24, 2015 Share Posted August 24, 2015 Help. triggerClientEvent ( [table/element sendTo=getRootElement()], string name, element sourceElement, [arguments...] ) Example local text = "bla bla bla" triggerClientEvent ( client, "EventName",client, text) Link to comment
mehmet145 Posted August 24, 2015 Author Share Posted August 24, 2015 Help. triggerClientEvent ( [table/element sendTo=getRootElement()], string name, element sourceElement, [arguments...] ) Example local text = "bla bla bla" triggerClientEvent ( client, "EventName",client, text) ??? addEvent("test", true) addEventHandler("test",getRootElement(), function() guiSetText(label, "" ) end end ) function test() local text = "bla bla bla" triggerClientEvent ( client, "test",getRootElement(), text) end Link to comment
mehmet145 Posted August 24, 2015 Author Share Posted August 24, 2015 my code example work ?? Link to comment
pa3ck Posted August 24, 2015 Share Posted August 24, 2015 Your code is not going to work. * You just used an empty string in guiSetText, never actually used the variable from server-side. * The variable client is never defined. * You must define the variable that is being sent over in the brackets -- CLIENT addEvent("test", true) addEventHandler("test",getRootElement(),function( myText ) -- make sure you define the variable from server-side up here in the brackets local label = guiCreateLabel ( 0, 0, 1, 1, "", true ) guiSetText(label, myText ) -- just use the variable as if it was created here, client-side end) -- SERVER local text = "bla bla bla" triggerClientEvent ( root, "test", root, text) -- make sure you include the variable in the triggerClientEvent Link to comment
mehmet145 Posted August 24, 2015 Author Share Posted August 24, 2015 Don't work.. Can you do it test_c.lua addEvent("test", true) addEventHandler("test",getRootElement(),function( myText ) -- make sure you define the variable from server-side up here in the brackets local label = guiCreateLabel ( 0, 0, 1, 1, "", true ) guiSetText(label, myText ) -- just use the variable as if it was created here, client-side end) test_s.lua local text = "bla bla bla" triggerClientEvent ( root, "test", root, text) -- make sure you include the variable in the triggerClientEvent Link to comment
Walid Posted August 24, 2015 Share Posted August 24, 2015 try to do it by yourself then post your code here Link to comment
mehmet145 Posted August 24, 2015 Author Share Posted August 24, 2015 Thanks for all ! Succesfully work!! i'm fixed code addEvent("test", true) addEventHandler("test",root, function( myText ) local label = guiCreateLabel ( 0, 0, 1, 1, "", true ) guiSetText(label, myText ) -- just use the variable as if it was created here, client-side end) function testt ( playerSource, commandName, playerName ) local text = "bla bla bla" triggerClientEvent ( root, "test", root, text) end addCommandHandler ( "test", testt ) Link to comment
Mr.Loki Posted August 24, 2015 Share Posted August 24, 2015 Succesfully work!! i'm fixed code local label = guiCreateLabel ( 0, 0, 1, 1, "", true ) guiSetText(label, myText ) -- just use the variable as if it was created here, client-side) instead of creating a blank label and then entering the text why not just create the label with the text? local label = guiCreateLabel ( 0, 0, 1, 1, myText, true ) Link to comment
mehmet145 Posted August 24, 2015 Author Share Posted August 24, 2015 Yes. Thanks for all Link to comment
pa3ck Posted August 24, 2015 Share Posted August 24, 2015 Don't work..Can you do it test_c.lua addEvent("test", true) addEventHandler("test",getRootElement(),function( myText ) -- make sure you define the variable from server-side up here in the brackets local label = guiCreateLabel ( 0, 0, 1, 1, "", true ) guiSetText(label, myText ) -- just use the variable as if it was created here, client-side end) test_s.lua local text = "bla bla bla" triggerClientEvent ( root, "test", root, text) -- make sure you include the variable in the triggerClientEvent Just for future reference, PLEASE read the debug before asking for help. It says in plain english that you triggered an event called "testa" ( yes, an extra A in the end ) but it was not added client-side, it was a typo. Link to comment
mehmet145 Posted August 24, 2015 Author Share Posted August 24, 2015 Solvedd!!!! Thank you for your help Link to comment
Walid Posted August 24, 2015 Share Posted August 24, 2015 Solvedd!!!! Thank you for your help it should be like this function testt ( playerSource, commandName ) local text = "You text here" triggerClientEvent (playerSource, "test",playerSource, text) end addCommandHandler ( "test", testt ) only who type the command can see it. 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