Moderators IIYAMA Posted November 13, 2012 Moderators Share 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) Link to comment
Castillo Posted November 13, 2012 Share Posted November 13, 2012 You are using the function in a server side script? Link to comment
Moderators IIYAMA Posted November 13, 2012 Author Moderators Share Posted November 13, 2012 client: exports.syncro_fixing:gasmaskon(player) server: function gasmaskon (player) aPlayerCheck[player]["gasmask"]=true; end Link to comment
Castillo Posted November 13, 2012 Share Posted November 13, 2012 You are using the exported function in a client side script, but the function is only server side. Link to comment
Moderators IIYAMA Posted November 13, 2012 Author Moderators Share 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 Link to comment
Castillo Posted November 13, 2012 Share 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. Link to comment
Moderators IIYAMA Posted November 13, 2012 Author Moderators Share 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 Link to comment
Castillo Posted November 13, 2012 Share Posted November 13, 2012 Yeah, you can do that. Link to comment
Moderators IIYAMA Posted November 13, 2012 Author Moderators Share 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 Link to comment
Smart. Posted November 13, 2012 Share Posted November 13, 2012 (edited) nevermind Edited November 13, 2012 by Guest Link to comment
Castillo Posted November 13, 2012 Share 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) Link to comment
Moderators IIYAMA Posted November 13, 2012 Author Moderators Share Posted November 13, 2012 I don't get it, sebbe. >--server export end Let me try. Working 100% thx solidsnake Link to comment
myonlake Posted November 13, 2012 Share 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) Link to comment
Moderators IIYAMA Posted November 13, 2012 Author Moderators Share 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. Link to comment
Anderl Posted November 13, 2012 Share Posted November 13, 2012 Players don't download server scripts. Link to comment
myonlake Posted November 14, 2012 Share 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. Link to comment
Anderl Posted November 14, 2012 Share 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. Link to comment
myonlake Posted November 14, 2012 Share 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. Link to comment
Castillo Posted November 14, 2012 Share Posted November 14, 2012 The problem is already solved. Link to comment
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