MetaGamer Posted November 4, 2011 Posted November 4, 2011 Well my question is how to return a function value in TriggerClientEvent. For example client.lua function Example() return "Hey Brown Cow!" end addEvent("TheExample", true) addEventHandler("TheExample", getRootElement(), Example) server.lua local msg = triggerClientEvent("TheExample", getRootElement()) ouputChatBox(tostring(msg)) The output should be "Hey Brown Cow!" not "true".
Castillo Posted November 4, 2011 Posted November 4, 2011 That's because it doesn't work that way. Wiki quote: Returns true if the event trigger has been sent, false if invalid arguments were specified. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
MetaGamer Posted November 4, 2011 Author Posted November 4, 2011 Ya I know that. But how to return that string "Hey Brown Cow!" to the server?
Castillo Posted November 4, 2011 Posted November 4, 2011 -- client side: function Example() triggerServerEvent("returnData",localPlayer,"Hey Brown Cow!") end addEvent("TheExample", true) addEventHandler("TheExample", getRootElement(), Example) -- server side: triggerClientEvent("TheExample", getRootElement()) addEvent("returnData",true) addEventHandler("returnData",root, function (msg) outputChatBox(tostring(msg)) end) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted November 4, 2011 Posted November 4, 2011 You're welcome . San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
MetaGamer Posted November 4, 2011 Author Posted November 4, 2011 BTW how to bypass or ignore a function parameter or argument?
MetaGamer Posted November 4, 2011 Author Posted November 4, 2011 plus your code will create an unconditional or never ending loop between the two sides
MetaGamer Posted November 5, 2011 Author Posted November 5, 2011 I got it fixed at last! The first problem can be fixed using nil The second problem can be fixed using if\else statement
Jaysds1 Posted November 5, 2011 Posted November 5, 2011 sorry, but you should have used the "edit" button, instead of making new posts My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
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