FlyingSpoon Posted August 20, 2015 Posted August 20, 2015 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) GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
Walid Posted August 20, 2015 Posted August 20, 2015 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
FlyingSpoon Posted August 20, 2015 Author Posted August 20, 2015 Can you help me D: I am really stuck.. I never used export functions before. GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
Walid Posted August 20, 2015 Posted August 20, 2015 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
ixjf Posted August 20, 2015 Posted August 20, 2015 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
FlyingSpoon Posted August 20, 2015 Author Posted August 20, 2015 Thanks, Now it creates multiple markers on the server side 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) GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
FlyingSpoon Posted August 20, 2015 Author Posted August 20, 2015 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 GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
Walid Posted August 20, 2015 Posted August 20, 2015 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
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