Jump to content

Creating exports


FlyingSpoon

Recommended Posts

I am trying to create exports.. I am failing D: My resource is called 'ctfSys'

I am trying to create exports to trigger on the Client Side -

SERVER SIDED

function createFlagMarker(x, y, z, r, g, b) 
   createMarker(x, y, z, "cylinder", 2, r, g, b) 
end 
addEvent("createFlagMarker", true) 
addEventHandler("createFlagMarker", root, createFlagMarker) 
  
function createFlag(x, y, z, rx, ry, rz) 
   createObject ( x, y, z, rx, ry, rz ) 
end 
addEvent("createFlag", true) 
addEventHandler("createFlag", root, createFlag) 

META.XML


CLIENT SIDE

exports.ctfSys:createFlagMarker(2003.61475, 1543.82678, 13.59075) 

Link to comment
Can you help me D:

I am really stuck.. I never used export functions before.

there is nothing wrong in your code just try to call it from an other server side.

Example:

function createFlagMarker(x, y, z, r, g, b) 
    if x and y and z then  
        if not r or not g or not b then 
            r, g, b = 255, 255, 255 
        end 
        createMarker(x, y, z, "cylinder", 2, r, g, b) 
    end  
end 
addEvent("createFlagMarker", true) 
addEventHandler("createFlagMarker", root, createFlagMarker) 

From an other resource (server side) use this :

exports.ctfSys:createFlagMarker(2003.61475, 1543.82678, 13.59075) 

Link to comment
Can you help me D:

I am really stuck.. I never used export functions before.

Exports are not for communication between the client and the server. They are a means of communication between resources, a way to expose an interface to its functionality. In fact, you can't even call client exports from the server. The only way, and the proper way, to do what you want is through remote events.

Link to comment

Thanks,

Now it creates multiple markers on the server side :o

function startTheMap() 
exports.ctfSys:createFlagMarker(583.61676, -3545.85083, 14.31875, 255, 0, 0) 
exports.ctfSys:createFlag(2993, 583.61676, -3545.85083, 15.31875) 
end 
addEventHandler("onResourceStart", root, startTheMap) 

Og4FIcm.png

Link to comment
function createFlagMarker(x, y, z, r, g, b) 
    if x and y and z then 
        if not r or not g or not b then 
            r, g, b = 255, 255, 255 
        end 
        local one = createMarker(x, y, z, "cylinder", 1.5, r, g, b) 
    end 
end 
addEvent("createFlagMarker", true) 
addEventHandler("createFlagMarker", root, createFlagMarker) 
  
function createFlag(id, x, y, z, rx, ry, rz) 
   local two = createObject ( id, x, y, z, rx, ry, rz ) 
end 
addEvent("createFlag", true) 
addEventHandler("createFlag", root, createFlag) 
  
function getFlags(thePlayer) 
  if (thePlayer == one) then  
    outputChatBox("works") 
  else 
    outputChatBox("dont work") 
  end 
end 
addEventHandler("onMarkerHit", getRootElement(), getFlags) 

It keeps outputting dont work

Link to comment

It keeps outputting dont work

Simply because it's a local variable.

Remove the word local.

or you can use sth like this

function createFlagMarker(x, y, z, r, g, b) 
    if x and y and z then 
        if not r or not g or not b then 
            r, g, b = 255, 255, 255 
        end 
        local one = createMarker(x, y, z, "cylinder", 1.5, r, g, b) 
        addEventHandler( "onMarkerHit", one, MarkerHit ) 
    end 
end 
addEvent("createFlagMarker", true) 
addEventHandler("createFlagMarker", root, createFlagMarker) 
  
function createFlag(id, x, y, z, rx, ry, rz) 
   local two = createObject ( id, x, y, z, rx, ry, rz ) 
end 
addEvent("createFlag", true) 
addEventHandler("createFlag", root, createFlag) 
  
function MarkerHit( hitElement, matchingDimension ) 
    if matchingDimension and isElement(hitElement) and getElementType( hitElement ) == "player" then  
        outputChatBox("Works", hitElement, 255, 255, 0 )  
    end  
end 

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...