AlphaMark Posted October 21, 2014 Share Posted October 21, 2014 Hey, I'm trying to get an export that checks if the player is staff but i get a error message all the time: Failed to call "{MS}Duty:isStaff" Script i'm trying to export from: function isStaff(name) if ( not name ) then return false; end for i,v in ipairs(staffs) do if getAccountName(name) == v then return true end end return false end addEvent ( getResourceName ( getThisResource ( ) )..":isStaff", true ) addEventHandler ( getResourceName ( getThisResource ( ) )..":isStaff", root, isStaff What i use for exporting: local name = getPlayerName(localPlayer) if exports["{MS}Duty"]:isStaff(name) == true then Btw the export is added to the meta like this: function="isStaff" type="server" /> Link to comment
Controlled Posted October 21, 2014 Share Posted October 21, 2014 You only exported it server side, and from what I can see in what you use it for, you are using it client side with "localPlayer" Link to comment
AlphaMark Posted October 21, 2014 Author Share Posted October 21, 2014 So i should make a client side script for this export? Link to comment
Controlled Posted October 21, 2014 Share Posted October 21, 2014 Wouldn't work as getAccountName is a server function. You could make the file shared and the export shared. Link to comment
Mr_Moose Posted October 21, 2014 Share Posted October 21, 2014 Some functions will only work on either the client or the server, in fact, the highlighter here uses 3 different color codes to show which functions does what. Orange: Server side function Red: Client side function Blue: Shared, i.e. can be used on both sides. Now, the solution would be to add a client file to your resource with the exported function in where you add triggerServerEvent to check this value with the server, and then pass the value back, in that way you can call this exported function from both server and client, here's an example of the opposite case, server to client conversation but the principles are the same: https://github.com/GTWCode/GTW-RPG/tree/master/GTWtopbar 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