3B00DG4MER Posted February 23, 2015 Share Posted February 23, 2015 Hi guys, I tried to Export an OOP function like that: function dxEditBox:create() end <export function="dxEditBox:create" type="client" /> i Called it like that : exports.RESOURCENAME:dxEditBox:create() Link to comment
TAPL Posted February 24, 2015 Share Posted February 24, 2015 https://forum.multitheftauto.com/viewtopic.php?f=91&t=85392 https://bugs.multitheftauto.com/view.php?id=8774 Link to comment
3B00DG4MER Posted February 24, 2015 Author Share Posted February 24, 2015 so I've to define it as variable first ? Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 That's one possible solution, it's annoying but makes it possible. That topic has everything you need. Link to comment
3B00DG4MER Posted February 24, 2015 Author Share Posted February 24, 2015 local menu = exports[ "SAFMenu" ].Menu_create( localPlayer, bot:getData("name"),155,0, 0 ) loadstring(exports[ "SAFMenu" ].Menu_open( localPlayer,absoluteX, absoluteY ))(menu) failed to call 'SAFMenu:Menu_open' [string "?"] Bad Argument 1 [Expected String got Boolean] attempt to call a boolean Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 Why are you using loadstring? loadstring is used to run code, you're passing the returned value of Menu_open to loadstring. Link to comment
3B00DG4MER Posted February 24, 2015 Author Share Posted February 24, 2015 if i don't use loadstring, same problem Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 Did you export the open function with the correct type? Link to comment
3B00DG4MER Posted February 24, 2015 Author Share Posted February 24, 2015 Menu = {} Menu.__index = Menu Menu.instances = {} Menu_open = Menu.open function Menu:open(x, y) ... return self end <export function="Menu_open" type="client" /> Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 You assign Menu_open before you define Menu.open? Move the line below the function. Link to comment
3B00DG4MER Posted February 24, 2015 Author Share Posted February 24, 2015 Do you want me to send you the Resource on PM ? Link to comment
Addlibs Posted February 24, 2015 Share Posted February 24, 2015 local menu = exports[ "SAFMenu" ].Menu_create( localPlayer, bot:getData("name"),155,0, 0 ) As far as I know, exports is a table, but exports["SAFMenu"] is more like a class... I think you were meant to put a semi-colon ( : ) instead of the period ( . ) between exports["SAFMenu"] and Menu_create Link to comment
3B00DG4MER Posted February 24, 2015 Author Share Posted February 24, 2015 i think they're the same ? Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 Not really. Just replace the dot with a semi-colon. local menu = exports[ "SAFMenu" ]:Menu_create( localPlayer, bot:getData("name"),155,0, 0 ) exports[ "SAFMenu" ]:Menu_open( localPlayer,absoluteX, absoluteY ) Link to comment
3B00DG4MER Posted February 24, 2015 Author Share Posted February 24, 2015 (edited) Menus = {} Menus.main = exports[ "SAFMenu" ]:Menu_create("Test",155,0, 0 ) That Line Works That one is killing ME ! exports[ "SAFMenu" ]:Menu_open(Menus.main,absoluteX, absoluteY ) Failed to call:"SAFMenu:Menu_open" [string: ?] Edited February 24, 2015 by Guest Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 Did you even read the replies in the topic TAPL linked you to? Meta tables are resource specific not global. If you don't understand then it's time to learn more about OOP or just drop it and use procedural syntax. Link to comment
3B00DG4MER Posted February 24, 2015 Author Share Posted February 24, 2015 i can't , i made more than 40 OOP function in One resource Link to comment
JR10 Posted February 24, 2015 Share Posted February 24, 2015 Well, you can't export OOP functions right now, a bug is reported (again, TAPL's links) so you just have to wait or try something different. The topic covered a possible work around, check it. 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