Zcraks Posted May 31, 2019 Posted May 31, 2019 Hi, i have ERROR. " attempt to call global 'source' (a userdata value). " function giveXP ( player, xp) givePlayerXP (player, xp) end function jobMMM() exports [ "lvlsyt" ]:givePlayerXP (source(getRootElement()), 10) end end addEventHandler("onPlayerMarkerHit",root,jobMMM)
salh Posted May 31, 2019 Posted May 31, 2019 (edited) function jobMMM() exports [ "lvlsyt" ]:givePlayerXP (source(getRootElement()), 10) end end addEventHandler("onPlayerMarkerHit",root,jobMMM) the function name is giveXP not givePlayerXP Edited May 31, 2019 by salh
Moderators IIYAMA Posted May 31, 2019 Moderators Posted May 31, 2019 @Zcraks You can't call an element like you would do with a function. function functionName () -- a function end functionName() -- calling the function So: exports [ "lvlsyt" ]:givePlayerXP (source (getRootElement()) , 10) 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
Zcraks Posted May 31, 2019 Author Posted May 31, 2019 25 minutes ago, IIYAMA said: @Zcraks You can't call an element like you would do with a function. function functionName () -- a function end functionName() -- calling the function So: exports [ "lvlsyt" ]:givePlayerXP (source (getRootElement()) , 10) call: failed to call: givePlayerXP[string "?"] call: failed to call: giveXP[string "?"]
Moderators IIYAMA Posted May 31, 2019 Moderators Posted May 31, 2019 is it set as export function? 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
Zcraks Posted May 31, 2019 Author Posted May 31, 2019 1 hour ago, IIYAMA said: is it set as export function? Resource "Job" - get XP on marker hit and export to "lvlsyt"server.lua exports [ "lvlsyt" ]:givePlayerXP (source, 200) Resource "lvlsyt" - give XP to playerserver.lua function giveXP ( player, xp) givePlayerXP (player, xp) end meta.xml <export function="giveXP" type="server"/>
Moderators IIYAMA Posted May 31, 2019 Moderators Posted May 31, 2019 @Zcraks giveXP is your export function NOT givePlayerXP. as salh said. exports["lvlsyt"]:giveXP(source, 200) -- or call ( getResourceFromName("lvlsyt"), "giveXP", source, 200) 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
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