Yan18
Member
- Joined
- Jun 14, 2014
- Messages
- 104
- Solutions
- 3
- Reaction score
- 17
Hello Everyone! The first of all, Happy New Year folks!!!
My doubt as the title says, how can I use creture functions in addEvent? For example, I want to use the following function inside addEvent:
I made a local function to return player:getPosition():sendMagicEffect to I can use that function inside addEvent:
When I use like below, it generates am error on console:
And I was searching about this error and I saw that is dangerous use Userdata in addEvent parameters, but I don't know how to do to works my script.
My doubt as the title says, how can I use creture functions in addEvent? For example, I want to use the following function inside addEvent:
Lua:
player:getPosition():sendMagicEffect(effect)
I made a local function to return player:getPosition():sendMagicEffect to I can use that function inside addEvent:
Lua:
local effect = 25
-- LOCAL FUNCTION TO USE SENDMAGICEFFECT IN ADDEVENT--
local function returnMagic(cid, effect)
local player = Player(cid)
return player:getPosition():sendMagicEffect(effect)
end
function onSay(player, words, param)
for i = 1, 5 do
addEvent(returnMagic, 60000, player, effect)
end
end
When I use like below, it generates am error on console:
Lua:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/repeat_effect.lua:onSay
LuaScriptInterface::luaAddEvent(). Argument #3 is unsafe
stack traceback:
[C]: in function 'addEvent'
data/talkactions/scripts/repeat_effect.lua:15: in function <data/talkactions/scripts/repeat_effect.lua:11>
And I was searching about this error and I saw that is dangerous use Userdata in addEvent parameters, but I don't know how to do to works my script.