patriot Posted December 25, 2012 Posted December 25, 2012 Hi there, I've got a client-side function that I export to other resources. Everything is fine, until I need this function to be triggered by serverside event. When I want to export this clientside function to clientside resource, I simply use this: exports["text"]:showText("My text", "4000", 20 ) But what should I do if I want to "showText" to "thePlayer", by serverside? function getPosition(thePlayer, commandName) local x, y, z = getElementPosition(thePlayer) local rotation = getPedRotation(thePlayer) local dimension = getElementDimension(thePlayer) local interior = getElementInterior(thePlayer) outputChatBox("Position: " .. x .. ", " .. y .. ", " .. z, thePlayer, 255, 194, 14) outputChatBox("Rotation: " .. rotation, thePlayer, 255, 194, 14) outputChatBox("Dimension: " .. dimension, thePlayer, 255, 194, 14) outputChatBox("Interior: " .. interior, thePlayer, 255, 194, 14) end addCommandHandler("getpos", getPosition, false, false) I want to use my exported clientside function inside the function above. In what way exactly can I do this?
Anderl Posted December 25, 2012 Posted December 25, 2012 triggerClientEvent -> showText. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
patriot Posted December 25, 2012 Author Posted December 25, 2012 Should I simply use this in any server-side resource, without first exporting it to the client-side part of the entire resource? Do I need to use the "exports" thing in the client-side part of the resource before triggering it using triggerClientEvent?
Anderl Posted December 25, 2012 Posted December 25, 2012 What? Simply create an event with ability for remote triggering in client-side which will call that exported function just the way you wrote above in the first post and call the event in server-side. Example - Client-side: addEvent( "onGetPosition", true ); addEventHandler( "onGetPosition", root, function( szText, var1, var2 ) exports.text:showText( tostring( szText ), tostring( var1 ), tonumber( var2 ) ); end ) Server-side: triggerClientEvent( ele, "onGetPosition", ele, "My text", "4000", 20 ); "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Anderl Posted December 25, 2012 Posted December 25, 2012 You're welcome. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
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