Jump to content

Exports


AlphaMark

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...