CyberShaman21
New Member
- Joined
- Dec 9, 2017
- Messages
- 52
- Reaction score
- 4
Hi
I want rebuild foods script . After you eat food you can't logout for xx seconds.
i found this script
and try to connect with food script
a I get error "attempt to call global 'onLogout' <a nil value>
I is good code?
I want rebuild foods script . After you eat food you can't logout for xx seconds.
i found this script
Code:
local storage = 102
function onLogout(cid)
if (getCreatureStorage(cid, storage) == 1) then
doPlayerSendCancel(cid, "You can not log out during these effects.")
return false
end
return true
end
and try to connect with food script
Code:
local foods = {
[26413] = {5, "Crunch.", 100}, -- carrot
}
local storage = 102
function onLogout(cid)
if (getCreatureStorage(cid, food[3]) == 1) then
doPlayerSendCancel(cid, "You can not log out during these effects.")
return false
end
return true
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local food = foods[item.itemid]
if not food then
return false
end
local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
if condition and math.floor(condition:getTicks() / 1000 + (food[1] * 12)) >= 1200 then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are full.")
else
player:feed(food[1] * 12)
player:say(food[2], TALKTYPE_MONSTER_SAY)
item:remove(1)
onLogout(cid)
end
return true
end
a I get error "attempt to call global 'onLogout' <a nil value>
I is good code?