hello, here i'm posting my new script.. a auto-feed, like in the botter :]
You can add more food if you want, i don't have added all food because i was so tired of the school
Here is :]
Create a file in talkactions called autofeed.lua and put this:
Later, add this to your talkaction.xml
Create a file in creaturescripts and put this:
Add this to creaturescripts.xml
Add this to your login.lua
NOTE: If you don't add the creature-script, then it will give error if the player don't off the auto-feed system
Explain:
How use the command?
Enjoy it.
You can add more food if you want, i don't have added all food because i was so tired of the school
Here is :]
Create a file in talkactions called autofeed.lua and put this:
Lua:
local storage = 65535
local food =
{
["carrot of doom"] = {2362, 8, "Crunch"},
["meat"] = {2666, 15, "Munch"},
["fish"] = {2667, 12, "Munch"},
["salmon"] = {2668, 10, "Mmmm"},
["northern pike"] = {2669, 17, "Munch"},
["shrimp"] = {2670, 4, "Gulp"},
["ham"] = {2671, 30, "Chomp."},
["dragon ham"] = {2672, 60, "Chomp"},
["pear"] = {2673, 5, "Yum"},
["red apple"] = {2674, 6, "Yum"},
["orange"] = {2675, 13, "Yum"},
["banana"] = {2676, 8, "Yum"},
["blueberry"] = {2677, 1, "Yum"},
["coconut"] = {2678, 18, "Slurp"},
["cherry"] = {2679, 1, "Yum"},
["brown mushroom"] = {2789, 22, "Munch"}
}
function onSay(cid, words, param, channel)
if(param == "") then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") and true end
local t = string.explode(param, ",")
if food[t[1]] then
if(t[2]:lower() == "on") then
if getCreatureStorage(cid, storage) < 1 then
local event = addEvent(feed, (food[t[1]][2] * 4) * 1000, cid, t)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Auto feed on.")
doCreatureSetStorage(cid, storage, 1)
return true
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You already have auto feed on.")
return true
end
elseif(t[2]:lower() == "off") then
if getCreatureStorage(cid, storage) > 0 then
stopEvent(event)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Auto feed off.")
doCreatureSetStorage(cid, storage, 0)
return true
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have auto feed on.")
return true
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Please say (!autofeed foodName, on/off).")
return true
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This food is not available in auto feed system.")
return true
end
end
function feed(cid, t)
if getPlayerStorageValue(cid, storage) > 0 then
if getPlayerItemCount(cid, food[t[1]][1]) < 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have food.")
return true
end
if(getPlayerFood(cid) + food[t[1]][2]) >= 400 then
doPlayerSendCancel(cid, "You are full.")
return true
end
doPlayerFeed(cid, food[t[1]][2] * 4)
doCreatureSay(cid, food[t[1]][3], TALKTYPE_MONSTER)
doPlayerTakeItem(cid, food[t[1]][1], 1)
local event = addEvent(feed, (food[t[1]][2] * 4) * 1000, cid, t)
return true
else
stopEvent(event)
return true
end
end
Later, add this to your talkaction.xml
Lua:
<talkaction log="yes" words="!autofeed" event="script" value="SCRIPT_NAME.lua" />
Create a file in creaturescripts and put this:
Lua:
local storage = 65535
function onLogout(cid)
doCreatureSetStorage(cid, storage, 0)
return true
end
Add this to creaturescripts.xml
Lua:
<event type="logout" name="AutoFeed" event="script" value="autofeed.lua"/>
Add this to your login.lua
Lua:
registerCreatureEvent(cid, "AutoFeed")
NOTE: If you don't add the creature-script, then it will give error if the player don't off the auto-feed system
Explain:
Lua:
["ham"] = -- food name..
{
2671, -- ham id
30, -- how seconds you will be full (formula = (30 * 4) -- 120 seconds, 3 hams are 360 seconds(full). in function addEvent, the formula is = (30 * 4) * 1000 = 120000 = 120 secons.)
"Chomp." -- Sound when you eat.
}
storage = 65535 --storage used for the system. DO NOT USE THIS STORAGE FOR OTHER SCRIPTS.
How use the command?
Lua:
!autofeed foodName, on/off
an example is !autofeed ham, on
Enjoy it.
Last edited: