Leo Messi Posted June 17, 2018 Share Posted June 17, 2018 It's so easy and simple, for example I created function givePlayersMoney(value) blah end function in accounts system, I don't want to make an export for it. I want it to be shared into all resources like givePlayersMoney(5000) without needing an export (exports.AccountsSystem:givePlayersMoney(5000)) Link to comment
itHyperoX Posted June 17, 2018 Share Posted June 17, 2018 (edited) meta.xml <meta> <script src="server.lua" type="server" /> <script src="client.lua" type="client" /> <export function="giveMoney" type="server" /> <export function="giveMoney" type="client" /> </meta> client.lua --[[ CLIENT SIDE ]] function giveMoney(value) triggerServerEvent("source >> giveMoney", getLocalPlayer(), value) end server.lua --[[ SERVER SIDE ]] addEvent("source >> giveMoney",true) addEventHandler("source >> giveMoney", getRootElement(), function(value) givePlayerMoney(source, value) return true end) function giveMoney(element, value) if isElement(element) and tonumber(value) then givePlayerMoney(element, value) return true else return false end end Edited June 17, 2018 by TheMOG Link to comment
Leo Messi Posted June 17, 2018 Author Share Posted June 17, 2018 I won't an exports, and all of the functions that I gave was an example... I want the function to be shared into all resources without needing an export.. got it? Link to comment
Moderators Patrick Posted June 17, 2018 Moderators Share Posted June 17, 2018 8 minutes ago, Leo Messi said: I won't an exports, and all of the functions that I gave was an example... I want the function to be shared into all resources without needing an export.. got it? You can't do that. Link to comment
Moderators IIYAMA Posted June 17, 2018 Moderators Share Posted June 17, 2018 You might attach a function as string on to the root and load per resource the string? Resource 1. setElementData(root, "allFunctions", "function newFunction() end", false) triggerEvent("allFunctions", root) Resource 2, 3, 4, 5, etc. addEvent("allFunctions", false) local function loadAllFunctions () local allFunctions = getElementData(root, "allFunctions") if allFunctions then loadstring(allFunctions)() removeEventHandler("allFunctions", root, loadAllFunctions) end end addEventHandler("onResourceStart", resourceRoot, function () addEventHandler("allFunctions", root, loadAllFunctions) loadAllFunctions() end) I do not recommend it muhahahah but maybe it works for you lol. really bad practice 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