Jump to content

Creating exports


FlyingSpoon

Recommended Posts

Posted

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) 

Posted

lol the function server side and u want to call it from the client side ????

you need to use triggerServerEvent.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
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) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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

I used to know how to code, but then I took an arrow in the knee.

Project Redivivus - Remaking Old School MTA With New Code

MTA 0.6 Nightly 1 released

Posted
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

Posted

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 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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