Moderators IIYAMA Posted November 13, 2012 Moderators Posted November 13, 2012 Export from Stealth: (player does exist) exports.syncro_fixing:gasmaskon(player) Other script: <export function="gasmaskon" type="server"/> function gasmaskon (player) aPlayerCheck[player]["gasmask"]=true; end Error: ERROR: call: failed to call 'syncro_fixing:gasmaskon' [string "?"] (both are running/no other errors) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Castillo Posted November 13, 2012 Posted November 13, 2012 You are using the function in a server side script? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Moderators IIYAMA Posted November 13, 2012 Author Moderators Posted November 13, 2012 client: exports.syncro_fixing:gasmaskon(player) server: function gasmaskon (player) aPlayerCheck[player]["gasmask"]=true; end Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Castillo Posted November 13, 2012 Posted November 13, 2012 You are using the exported function in a client side script, but the function is only server side. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Moderators IIYAMA Posted November 13, 2012 Author Moderators Posted November 13, 2012 (edited) So I have to trigger first the server function in the same folder. then export? Edited November 13, 2012 by Guest Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Castillo Posted November 13, 2012 Posted November 13, 2012 I don't understand what do you mean. But you can't use a exported function which is server side in a client side script. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Moderators IIYAMA Posted November 13, 2012 Author Moderators Posted November 13, 2012 (edited) I mean: --client triggerServerEvent ( string event, element theElement, [arguments...] ) --1 --server addEvent... --2 addEventHandler etc.. Function .. () exports.syncro_fixing:gasmaskon(player) --3 end --export function Edited November 13, 2012 by Guest Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Castillo Posted November 13, 2012 Posted November 13, 2012 Yeah, you can do that. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Moderators IIYAMA Posted November 13, 2012 Author Moderators Posted November 13, 2012 (edited) Almost: --client triggerServerEvent ( "gasmaskexport", player ) outputChatBox(player)-- user data visible --server addEvent ("gasmaskexport", true ) function gasmaskexporter (player) exports.syncro_fixing:gasmaskon(player) end addEventHandler ("gasmaskexport", getRootElement(), gasmaskexporter) Error: --server export end function gasmaskon (player) aPlayerCheck[player]["gasmask"]=true; end ERROR: [ouder_server]\syncro_fixing\syncro_server.lua:1250: attempt to index field '?' ( a nil value) ERROR: call: failed to call 'syncro_fixing:gasmaskon' [string "?"] Edited November 13, 2012 by Guest Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Smart. Posted November 13, 2012 Posted November 13, 2012 (edited) nevermind Edited November 13, 2012 by Guest lol
Castillo Posted November 13, 2012 Posted November 13, 2012 Almost: --client triggerServerEvent ( "gasmaskexport", player ) outputChatBox(player)-- user data visible --server addEvent ("gasmaskexport", true ) function gasmaskexporter (player) exports.syncro_fixing:gasmaskon(player) end addEventHandler ("gasmaskexport", getRootElement(), gasmaskexporter) Error: --server export end function gasmaskon (player) aPlayerCheck[player]["gasmask"]=true; end ERROR: [ouder_server]\syncro_fixing\syncro_server.lua:1250: attempt to index field '?' ( a nil value) ERROR: call: failed to call 'syncro_fixing:gasmaskon' [string "?"] -- client side: triggerServerEvent ( "gasmaskexport", localPlayer ) -- server side: addEvent ("gasmaskexport", true ) function gasmaskexporter ( ) exports.syncro_fixing:gasmaskon ( source ) end addEventHandler ("gasmaskexport", getRootElement(), gasmaskexporter) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Moderators IIYAMA Posted November 13, 2012 Author Moderators Posted November 13, 2012 I don't get it, sebbe. >--server export end Let me try. Working 100% thx solidsnake Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
myonlake Posted November 13, 2012 Posted November 13, 2012 Why use triggers when you can just set the lua file to both types: server, client. syncro_fixing/meta.xml <meta> <script src="exports.lua" type="server" /> <script src="exports.lua" type="client" /> <export function="gasmaskon" type="server" /> <export function="gasmaskon" type="client" /> </meta> You never returned a value. syncro_fixing/exports.lua function gasmaskon(player) return aPlayerCheck[player]["gasmask"]=true end s_gasmask.lua exports.syncro_fixing:gasmaskon(player) If I helped you, please click the like button on the right Thanks!
Moderators IIYAMA Posted November 13, 2012 Author Moderators Posted November 13, 2012 Heh? You sure that won't give trouble? People will have to download client and server scripts, don't they? The client script does already have arround 800 lines, the server is 2 times more. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Anderl Posted November 13, 2012 Posted November 13, 2012 Players don't download server scripts. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
myonlake Posted November 14, 2012 Posted November 14, 2012 Heh? You sure that won't give trouble?People will have to download client and server scripts, don't they? The client script does already have arround 800 lines, the server is 2 times more. This is used by all professional servers. There's simply no need to make multiple files instead of one. If I helped you, please click the like button on the right Thanks!
Anderl Posted November 14, 2012 Posted November 14, 2012 It just makes no sense to put a file client and server-sided just because he wants to call a function from server-side. You don't even know if IIYAMA has more code in that file and making it server-side when it has client-side code will make it not work server-sided as it will throw errors. If you want to use a server function in client code, use triggerServerEvent or just make a file with both types where you'll add all functions that can be client and server-sided. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
myonlake Posted November 14, 2012 Posted November 14, 2012 It just makes no sense to put a file client and server-sided just because he wants to call a function from server-side. You don't even know if IIYAMA has more code in that file and making it server-side when it has client-side code will make it not work server-sided as it will throw errors. If you want to use a server function in client code, use triggerServerEvent or just make a file with both types where you'll add all functions that can be client and server-sided. I thought he is making an export system, which allows him to get functions from that system in another resources. Do forget my posts if I was wrong, but if he's going to use that function all over again in other resources many times then he should put it to a separate lua file and then set it both client and server-side. If I helped you, please click the like button on the right Thanks!
Castillo Posted November 14, 2012 Posted November 14, 2012 The problem is already solved. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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