Jump to content

How can I make my export function work?


IIYAMA

Recommended Posts

  • Moderators

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
  • Moderators

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 by Guest
Link to comment
  • Moderators

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 by Guest
Link to comment
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

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

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

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