xTravax Posted September 21, 2014 Share Posted September 21, 2014 hey im trying to call another script from another resource so that i can spawn a player when i want without using original resource to spawn it -- client exports.cspawn:otherTestFunction(localPlayer) -- meta function="otherTestFunction" type="client" /> debugscript 3: call: failed to call: cspawn:otherTestFunction please help idk what im doing wrong Link to comment
Anubhav Posted September 21, 2014 Share Posted September 21, 2014 There can be problem in the exported function, Link to comment
xTravax Posted September 21, 2014 Author Share Posted September 21, 2014 what kind of problem? if you mean that the function itself doesnt work, it does but it doesnt activate when im trying to activate it via exports Link to comment
#DRAGON!FIRE Posted September 21, 2014 Share Posted September 21, 2014 i don't understand .. what the problem ? Link to comment
xTravax Posted September 21, 2014 Author Share Posted September 21, 2014 i don't understand .. what the problem ? debugscript 3: call: failed to call: cspawn:otherTestFunction Link to comment
TAPL Posted September 21, 2014 Share Posted September 21, 2014 -- meta function="otherTestFunction" type="client" /> Did you add it in the meta of the original resource which contains the function otherTestFunction or the resource where you are trying to call the function? Link to comment
xTravax Posted September 21, 2014 Author Share Posted September 21, 2014 original resource Link to comment
#DRAGON!FIRE Posted September 21, 2014 Share Posted September 21, 2014 Check if the ( otherTestFunction ) function at Client Side .. and Check if script running and no errors from resource Link to comment
xTravax Posted September 21, 2014 Author Share Posted September 21, 2014 its running and its exactly that function name and theres no other error than the one that i posted here Link to comment
#DRAGON!FIRE Posted September 21, 2014 Share Posted September 21, 2014 i can see otherTestFunction function ? Link to comment
xTravax Posted September 21, 2014 Author Share Posted September 21, 2014 why do u need that function? that function works fine without any errors but exports arent triggering it because call fails for unknown reason Link to comment
Mr_Moose Posted September 21, 2014 Share Posted September 21, 2014 The reason is usually that you have an error in the exported function, otherwise you get other types of error outputs in the script debugger, try comment everything in "otherTestFunction" and add something simple like outputChatBox("test") just to see if that works and you get the output, if it does then you have a problem in your exported function which you can find by calling it from the same resource while debugging. Link to comment
xTravax Posted September 21, 2014 Author Share Posted September 21, 2014 tried that and nothing debugscript 3 ERROR:failed to call 'cspawn:otherTestFunction' ERROR: attemp to call a nil value Link to comment
#DRAGON!FIRE Posted September 21, 2014 Share Posted September 21, 2014 bro u sure ? try this and Check if resource Name and function name is right . call ( getResourceFromName ( "cspawn" ), "otherTestFunction", getLocalPlayer ( ) ) Link to comment
Mr_Moose Posted September 22, 2014 Share Posted September 22, 2014 Ok so you got this error now: "attempt to call a nil value", that's a clear indicator that something doesn't exist, are you really sure that you have this line: meta.xml <export function="otherTestFunction" type="client" /> in the same resource you have the exported function? Are you completely sure that both these resources are running? Try to refresh all and then reconnect to make sure you get all the files you need. Link to comment
Moderators IIYAMA Posted September 25, 2014 Moderators Share Posted September 25, 2014 (edited) Ever heard of debugging? /debugscript 3 local resource = getResourceFromName ( "cspawn" ) if resource then local state = getResourceState (resource) if state == "running" then call (resource, "otherTestFunction", localPlayer ) else outputDebugString("Resource isn't running but: " .. state) end else outputDebugString("resource doesn't exist, ") end Edited September 25, 2014 by Guest Link to comment
Anubhav Posted September 25, 2014 Share Posted September 25, 2014 IIYAMA running should be "running". Link to comment
Moderators IIYAMA Posted September 25, 2014 Moderators Share Posted September 25, 2014 IIYAMA running should be "running". thx for the correction. Link to comment
xTravax Posted September 25, 2014 Author Share Posted September 25, 2014 Ok so you got this error now: "attempt to call a nil value", that's a clear indicator that something doesn't exist, are you really sure that you have this line:meta.xml <export function="otherTestFunction" type="client" /> in the same resource you have the exported function? Are you completely sure that both these resources are running? Try to refresh all and then reconnect to make sure you get all the files you need. its exactly that line,both resources are running and always gives that error IIYAMA, i really dont know how could you miss my DEBUGSCRIPT 3 LINE on my FIRST POST in this topic obviously i know how to use it. why to script if scripting basics aren't learned? anyway i dont need a script to check if a resource is running because simply i have already checked that long time ago and this thing still does not work.. Link to comment
King12 Posted September 25, 2014 Share Posted September 25, 2014 Ok so you got this error now: "attempt to call a nil value", that's a clear indicator that something doesn't exist, are you really sure that you have this line:meta.xml <export function="otherTestFunction" type="client" /> in the same resource you have the exported function? Are you completely sure that both these resources are running? Try to refresh all and then reconnect to make sure you get all the files you need. its exactly that line,both resources are running and always gives that error IIYAMA, i really dont know how could you miss my DEBUGSCRIPT 3 LINE on my FIRST POST in this topic obviously i know how to use it. why to script if scripting basics aren't learned? anyway i dont need a script to check if a resource is running because simply i have already checked that long time ago and this thing still does not work.. Are you sure that your code isn't mixed with any server-side functions? and you definite your script in meta as a client-side? And you're using the function in a client-side script? and at last, try this tutorial : https://forum.multitheftauto.com/viewtopic.php?f=148&t=46167 Link to comment
Moderators IIYAMA Posted September 25, 2014 Moderators Share Posted September 25, 2014 Because I am not reading every word of the forum? Not sure what kind of super human you are. If you don't want to check if a script is running, then you get warnings and when you get warnings you get a little bit lagg. and not only that little bit lagg, your server logs will be filled with it and your server will be starting slower while accessing the logs. But I won't say anything more about that, it's your own responsibility. bla bla bla..... Post the function you are trying to access. (and what kind of file it is in) Link to comment
xTravax Posted September 25, 2014 Author Share Posted September 25, 2014 @king not sure how can any serverside script mess up my client side as theres not a single part of code which would do that and im calling client function from other script with this client file script iyyama(usually people read first post at topics afaik) [cspawn]\cspawn\script.lua thats an example where a script would be in cspawn is resource name and this is the other client function which im triggering with exports if getElementDimension(localPlayer) == 3 then button = guiCreateButton( 0.45, 0.5, 0.1, 0.1, "Spawn!", true ) fadeCamera ( false ) showCursor ( true ) else outputChatBox("bspawn_c: wrong dimension ") return end function otherTestFunction ( ) if getElementDimension(localPlayer) == 3 then outputChatBox("a") outputDebugString("aa") else outputChatBox("bspawn_c10: wrong dimension ") return end --triggerServerEvent ( "spawnButtonForPlayer",localPlayer ) --showCursor ( false ) --guiSetVisible(button,false) end addEventHandler ( "onClientGUIClick", button, otherTestFunction, false ) Link to comment
Moderators IIYAMA Posted September 25, 2014 Moderators Share Posted September 25, 2014 He means that you can't calling from serverside a client function. Which you aren't doing afaik, but if you haven't checked that, check it. Else. What if you don't attach that event handler? I know it is probably not the problem, but to be honest I have never attached addEventHandlers to my export functions. You also have to mind timing of the scripts. If you start both scripts at the same time, there is always one faster loaded. Which will most of the time go wrong when you have included other resources in the meta.xml. (the first export will fail in this case) Link to comment
darhal Posted September 25, 2014 Share Posted September 25, 2014 Added this to the meta of the resource that contain the exported function : < export="FunctionNameHere" type="server or client" /> or this i m not sure just try < exports="FunctionNameHere" type="server or client" /> 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