Metall Posted February 25, 2013 Share Posted February 25, 2013 (edited) How to make and use exports Hello, and welcome to my tutorial, today i will be covering on how to use exports. An example for an export is: exports.RESname.functionName() I'm not experienced in exports, but the ones i'm covering should work properly, otherwise, some more experienced can fix them. So here we go: Begin by creating the actual export, inside a file, server or client. function isPlayerMetall(player) if(getPlayerFromName(player) == "Metall") then return true else return false end end Also, i dont use any handlers or anything, since this is our own check, awesome right? After that go to the actual meta file, and that's the actual export thingy dingy configuration obama dingy hingy. <meta> <export function="isPlayerMetall" type="client" /> <script src="client.lua" type="client" /> </meta> There is the thing. It reads a function, from a file, and checks what type it is "client" or "server". After that, you can use: exports.resname.isPlayerMetall() Not sure if this will work but: function test() if(exports.RESname.isPlayerMetall()) then -- do something else -- do something end end addCommandHandler("yo", test) Have fun in scripting! Edited February 25, 2013 by Guest Link to comment
Anderl Posted February 25, 2013 Share Posted February 25, 2013 Your example function will ever return false in your last code because you're not passing the parameter needed. Anyway, basically, exports is a simple array that stores all exported functions (organized by resources), there isn't much more to say. Also, in my opinion you could comment more things for beginners. Link to comment
Recommended Posts