ViRuZGamiing Posted December 6, 2016 Share Posted December 6, 2016 Hi guys I was looking into: call and I was wondering, for example; you have the function outputChatBox("") which works both client and server side with the same name. Will I be able to do the same with exports. Example; Client function drawDxStuff () --dx stuff end addEvent("drawDxStuff", true) addEventHandler("drawDxStuff", getRootElement(), drawDxStuff) Server function drawDxStuff() triggerClientEvent(source, "drawDxStuff", source) --source would probably be the player calling the function end Meta <export function="drawDxStuff" type="server"/> <export function="drawDxStuff" type="client"/> Would this work or will this give an error cause they have the same name or for other reasons? Kind Regards Link to comment
ViRuZGamiing Posted December 6, 2016 Author Share Posted December 6, 2016 (edited) can't seem to be able to edit my post on the "new" forum design 50% of the time appearantly Edited December 6, 2016 by ViRuZGamiing Link to comment
Syntrax# Posted December 6, 2016 Share Posted December 6, 2016 Maybe add client and server to the names since you are trying to call one export while there are 2 results for this. Link to comment
ViRuZGamiing Posted December 6, 2016 Author Share Posted December 6, 2016 17 minutes ago, Syntrax# said: Maybe add client and server to the names since you are trying to call one export while there are 2 results for this. So I do have to name them by 2 different names, it's not possible to have 1 name? Link to comment
Walid Posted December 6, 2016 Share Posted December 6, 2016 function drawDxStuff(player) if player and isElement(player) then triggerClientEvent(player, "drawDxStuff", player) end end Then use this server side exports.resourceName:drawDxStuff(player) And in the dx stuff part just added (onClientRender) event Link to comment
ViRuZGamiing Posted December 6, 2016 Author Share Posted December 6, 2016 46 minutes ago, Walid said: function drawDxStuff(player) if player and isElement(player) then triggerClientEvent(player, "drawDxStuff", player) end end Then use this server side exports.resourceName:drawDxStuff(player) And in the dx stuff part just added (onClientRender) event I do know how that works, mine is just an analogue example to show you what I mean, I do know i'd need an onClientRender, etc. it could've been GUI as well, just an example. My question is all about a client OR server sided function which can be called from both client AND server side with the same name 'exported'. For example (as mentioned before): outputChatBox() which is both Server and Client sided (Shared Function) Link to comment
Tails Posted December 6, 2016 Share Posted December 6, 2016 (edited) 2 hours ago, ViRuZGamiing said: Would this work or will this give an error cause they have the same name or for other reasons? Yeah, you can export both functions with the same name as long as the functions are present on both the server and client. I did the same thing on one of my scripts before. Nothing wrong with your example. Edited December 6, 2016 by Tails 1 Link to comment
ViRuZGamiing Posted December 6, 2016 Author Share Posted December 6, 2016 1 hour ago, Tails said: Yeah, you can export both functions with the same name as long as the functions are present on both the server and client. I did the same thing on one of my scripts before. Nothing wrong with your example. Thanks for the clear answer! 1 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