Neproify Posted March 20, 2015 Share Posted March 20, 2015 Hello. I have code like that: function Player:show(text) triggerClientEvent(self, "notifications:show", root, text) end How to export it? <export function="Player:show" type="server" /> or <export function="show" type="server" /> Link to comment
xXMADEXx Posted March 20, 2015 Share Posted March 20, 2015 You can't export OOP functions. Link to comment
WhoAmI Posted March 21, 2015 Share Posted March 21, 2015 Really? https://wiki.multitheftauto.com/wiki/Call "OOP Syntax Method: resource:call(...)" Link to comment
Gallardo9944 Posted March 21, 2015 Share Posted March 21, 2015 call doesn't allow you to export OOP functions. You have to create replacements and export them (like "myFunction = myData:function" and the export myFunction) Link to comment
Addlibs Posted March 21, 2015 Share Posted March 21, 2015 "OOP SyntaxMethod: resource:call(...)" This is about calling the function. Exports are OOP styled but exported function cannot. The OOP syntax is for the following usage: getResourceFromName("resource"):call("exportedFunction", 1, "2", "three") --or Resource.getFromName("resource"):call("exportedFunction", 1, "2", "three") --instead of call(getResourceFromName("resource"), "exportedFunction", 1, "2", "three") Link to comment
RenanPG Posted March 21, 2015 Share Posted March 21, 2015 There is not possible to export OOP functions(methods), but you can run the class in other resources. local oop_exemple = [[a = {} a.__index = a function a:new() local o = {name = 'test'} setmetatable(o, a) return o end function a:getName() return self.name end]] function getTable() return oop_exemple end loadstring(exports.resource_name:getTable()) () ---- to load the class local x = a:new() print(x:getName()) 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