Shinmaru
エロルアー Scripter!
Script 5 is [UPDATED] Thanks to "Your Master" for idea.
Also anyone have any suggestions or ideas about the scripts let me know i can try to remake it.
OK! So i have a few scripts that will help a lot of people that want to add farming, mining and wood cutting to their servers, well now you can and im going to share
Now let's begin:
1. make a file in actions/script folder and name it farming.lua and copy this:
2. now make a file in the same said location and name it hoesoil.lua and copy this:
3.now again make a file and name it harvest plants.lua and copy this in it:
4. same, name it mining.lua and copy:
5. last one, name it woodcutting.lua and copy: [UPDATED]
6. Now to give use to all the wood you collect from chopping down trees, make a file in actions/scripts and name it fletching.lua and copy this:
Now copy this to your actions.xml:
[Screen Shot]
[EXPLANATION]
Order is:
1 = Script 1
2 = Script 2
3 = Script 3
4 = Script 4
5 = Script 5
6 = script 6
Now for explanations let's start by:
1. is a farming script in which you place a fruit(mango, coconut, blueberry, banana and orange) on the ground and use a shovel(5710) and it will grow to a tree with no fruits then after the specified amount of time elapses, the tree grows fruits then after a while it dies.
2. is a land plowing script in which you plow the soil(103) with a hoe(2552) to make it ready for planting, it turns to plowed soil(804).
3. is a script that allows the specified trees to give you their respective fruits(you can add more) when you click use on that particular tree.
4. is a mining script in with you use a pick(2553) to break stones in order to get iron and other precious stones, including some gold.
[UPDATED]
5. is a woodcutting script that...well... cuts trees down with an axe(2386) in order to get wood and in 5 minutes a new tree grows in its place.
6. is a script in which you use a knife(2403) on a piece of wood(5901) to create arrows, spears, bolts and such, all according to the level required to create them.
well i hope you guys like it and please leave a comment.
[NOTE]
the mining script is made by Cykotitan and the woodcutting is the same only re-configured to cut down wood, and the farming script is made by me using Kakashi~sensei and Nirer's script structure as the base of the farming script, so thanks to that, this script can be made, oh yea, all of the scripts consume soul points in order so players don't abuse of the benefits that these scripts give players ingame.
Also anyone have any suggestions or ideas about the scripts let me know i can try to remake it.
OK! So i have a few scripts that will help a lot of people that want to add farming, mining and wood cutting to their servers, well now you can and im going to share
Now let's begin:
1. make a file in actions/script folder and name it farming.lua and copy this:
Lua:
----------------Script Structure By Nirer/Kakashi~Sensei-----------------
-------------Enhancements and configurablility by 375311-------------
-----------Ask before you re-distribute to other sites-----------
local config = {
grounds = {804},
sMin = 2
}
--To add more plants to grow just copy this example:
--[{XXXX}] = {NFTree = XXXX, bloomInSec = XX, t_DthInSec = XX, FTree = XXXX, tname = ""},--
--Ref: NFTree = Non Fruit Tree, FTree = Fruit Tree, bloomInSec = time that it takes to bloom, t_DthInSec = time that it takes for plant to die,
--tname = tree name and [{XXXX}] = Seed(fruit) itemid, all XXXX are itemids--
--and paste it under:
local t = { --HERE--
[{2675}] = {NFTree = 4008, bloomInSec = 60, t_DthInSec = 120, FTree = 4006, tname = "orange tree"},
[{2676}] = {NFTree = 5092, bloomInSec = 45, t_DthInSec = 30, FTree = 5094, tname = "banana tree"},
[{2678}] = {NFTree = 2726, bloomInSec = 70, t_DthInSec = 50, FTree = 5096, tname = "coconut tree"},
[{2677}] = {NFTree = 2786, bloomInSec = 20, t_DthInSec = 45, FTree = 2785, tname = "blueberry bush"},
[{5097}] = {NFTree = 5156, bloomInSec = 40, t_DthInSec = 20, FTree = 5157, tname = "mango tree"}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local soul = getPlayerSoul(cid)
for i, k in pairs(t) do
if (isInArray(i, itemEx.itemid) == true) and itemEx.type == 1 and (soul >= config.sMin) then
local ground_position = {x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 0}
local ground_information = getThingfromPos(ground_position)
if(isInArray(config.grounds, ground_information.itemid) == TRUE) then
doPlayerAddSoul(cid, -config.sMin)
doTransformItem(itemEx.uid, k.NFTree)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your "..k.tname.." has grown!")
addEvent(Bloom, k.bloomInSec*1000, {position = toPosition, cid = cid, t_Dth = k.t_DthInSec})
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This is not the proper ground for farming.")
end
elseif(soul < config.sMin) then
doPlayerSendCancel(cid, "You do not have enough soul to farm.")
elseif(itemEx.type ~= 1) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You may only grow one plant at a time.")
end
end
return TRUE
end
function Bloom(parameter)
local tree = getThingfromPos{x = parameter.position.x, y = parameter.position.y, z = parameter.position.z, stackpos = 1}
for i, k in pairs(t) do
if (tree.itemid == k.NFTree) then
doTransformItem(tree.uid, k.FTree)
doPlayerSendTextMessage(parameter.cid, MESSAGE_INFO_DESCR, "Your "..k.tname.." has fully grown! Harvest it before it withers!")
addEvent(t_Die, parameter.t_Dth*1000, {position = {x = parameter.position.x, y = parameter.position.y, z = parameter.position.z }, cid = parameter.cid})
end
end
end
function t_Die(parameter)
local tree = getThingfromPos{x = parameter.position.x, y = parameter.position.y, z = parameter.position.z, stackpos = 1}
doRemoveItem(tree.uid)
doPlayerSendTextMessage(parameter.cid, MESSAGE_INFO_DESCR, "Your crop has withered.")
end
2. now make a file in the same said location and name it hoesoil.lua and copy this:
Lua:
local cfg = {
level = 15,
soul = 4,
Mon = "Rat",
Lx = "You do not meet the level required to plow the land.",
Sx = "You do not have enough soul to plow the land.",
soil = 103
}
function onUse(cid, item, fromposition, item2, toposition)
local R = math.random(1,500)
local S = getPlayerSoul(cid)
local L = getPlayerLevel(cid)
if (L >= cfg.level) and (S >= cfg.soul) and (item2.itemid == cfg.soil) then
if R <= 100 then
doSummonCreature(cfg.Mon, toposition)
doPlayerAddSoul(cid, -cfg.soul)
doTransformItem(item2.uid, 804)
doDecayItem(item2.uid)
elseif R <= 200 then
doPlayerAddItem(cid, 3976, 3)
doPlayerAddSoul(cid, -cfg.soul)
doTransformItem(item2.uid, 804)
doDecayItem(item2.uid)
elseif R <= 500 then
doTransformItem(item2.uid, 804)
doDecayItem(item2.uid)
doPlayerAddSoul(cid, -cfg.soul)
end
elseif(L < cfg.level) then
doPlayerSendCancel(cid, cfg.Lx)
elseif(S < cfg.soul) then
doPlayerSendCancel(cid, cfg.Sx)
end
return true
end
3.now again make a file and name it harvest plants.lua and copy this in it:
Lua:
local cfg = {
soul = 1,
level = 10
}
local t = {
[{4006}] = {fruit = 2675, NFTree = 4008, amount = 3, fName = "Orange"},
[{5094}] = {fruit = 2676, NFTree = 5092, amount = 3, fName = "Banana"},
[{5096}] = {fruit = 2678, NFTree = 2726, amount = 3, fName = "Coconut"},
[{5157}] = {fruit = 5097, NFTree = 5156, amount = 3, fName = "Mango"}
}
function onUse(cid, item, frompos, item2, topos)
local S = getPlayerSoul(cid)
local L = getPlayerLevel(cid)
for i, k in pairs(t) do
if (isInArray(i, item.itemid) == true) and (S >= cfg.soul) and (L >= cfg.level) then
doTransformItem(item.uid, k.NFTree)
doPlayerAddItem(cid, k.fruit, k.amount)
doPlayerAddSoul(cid, -cfg.soul)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got some "..k.fName..".")
elseif (S < cfg.soul) then
doPlayerSendCancel(cid, "You do not have soul to harvest the plant.")
elseif (L < cfg.level) then
doPLayerSendCancel(cid, "You are not in the requiered level to harvest.")
end
end
end
4. same, name it mining.lua and copy:
Lua:
--By:Cykotitan Improvised Version--
local config = {
stones = {1285, 1356, 1357, 1358, 1359, 3608, 3615, 3607, 3609, 3616, 3666, 3667, 3668, 3670, 1295, 1290},
level = 20,
skill = SKILL_CLUB,
skillReq = 15,
effect = CONST_ME_BLOCKHIT,
addTries = 100,
debris = 1336,
msgType = MESSAGE_EVENT_ADVANCE,
soul = 5
}
local t = {
[{1, 100}] = {msg = "Oh no, you missed and picked a hole in the ground and a rat came out of it!", summon = "Rat"},
[{101, 200}] = {msg = "You found %A %N.", item = 2157, amountmax = 10},
[{201, 300}] = {msg = "You found %A %N.", item = 2145, amountmax = 10},
[{301, 400}] = {msg = "You found %A %N.", item = 2225},
[{401, 500}] = {msg = "You found %A %N.", item = 2148, amountmax = 100},
[{501, 600}] = {msg = "You found %A %N.", item = 2146, amountmax = 10},
[{601, 700}] = {msg = "You found %A %N.", item = 2149, amountmax = 10},
[{701, 800}] = {msg = "You found %A %N.", item = 2150, amountmax = 10},
[{801, 900}] = {msg = "You found %A %N.", item = 5880},
[{901, 1000}] = {msg = "You lost %D hitpoints due to exhaustion of mining.", damage = {1, 100}},
[{1001, 1100}] = {msg = "You found %A %N.", item = 2147, amountmax = 10},
[{1101, 1200}] = {msg = "You found %A %N.", item = 2143, amountmax = 10},
[{1201, 1300}] = {msg = "You found %A %N.", item = 2144, amountmax = 10},
[{1301, 1400}] = {msg = "An angry dwarf came out of the rock piles!", summon = "Dwarf"},
[{1401, 1500}] = {msg = "A badger got unstuck and it looks angry!", summon = "Badger"},
[{1501, 1600}] = {msg = "A rotworm came from a hole you made on the ground!", summon = "Rotworm"},
[{1601, 1700}] = {msg = "You suffered %D hitpoints due to an earthquake!", damage = {1, 100}},
[{1701, 1800}] = {msg = "A weak troll has appeared from the pile of rocks!", summon = "Troll"},
[{1801, 1900}] = {msg = "Woah! A skeleton just appeared from the pile of rocks!", summon = "Skeleton"},
[{1901, 2000}] = {msg = "Your pick has been heavily damaged and it broke...", destroy = true}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isInArray(config.stones, itemEx.itemid) and config.level <= getPlayerLevel(cid) and config.skillReq <= getPlayerSkill(cid, config.skill) and config.soul <= getPlayerSoul(cid) then
local v, amount, damage = math.random(2000), 1, nil
for i, k in pairs(t) do
if v >= i[1] and v <= i[2] then
if k.destroy then
doRemoveItem(item.uid)
end
if k.summon then
doCreateMonster(k.summon, toPosition)
end
if k.damage then
damage = math.random(k.damage[1], k.damage[2])
doCreatureAddHealth(cid, - damage)
doSendMagicEffect(getThingPos(cid), CONST_ME_DRAWBLOOD)
doSendAnimatedText(getThingPos(cid), damage, TEXTCOLOR_RED)
end
if k.item then
if k.amountmax then
amount = math.random(k.amountmax)
end
doPlayerAddItem(cid, k.item, amount)
end
if k.msg then
local msg = k.msg
if msg:find("%%") then
if msg:find("%%A") and k.item then
msg = msg:gsub("%%A", amount > 1 and amount or getItemDescriptionsById(k.item).article)
end
if msg:find("%%N") and k.item then
msg = msg:gsub("%%N", amount > 1 and getItemDescriptionsById(k.item).plural or getItemNameById(k.item))
end
if msg:find("%%D") and damage then
msg = msg:gsub("%%D", damage)
end
end
doPlayerSendTextMessage(cid, config.msgType, msg)
end
doTransformItem(itemEx.uid, config.debris)
doPlayerAddSoul(cid, -config.soul)
doSendMagicEffect(toPosition, k.destroy and CONST_ME_HITAREA or config.effect)
return doPlayerAddSkillTry(cid, config.skill, config.addTries)
end
end
end
return doPlayerSendCancel(cid, "You either aren't experienced, skilled or don't have enough soul, or this isn't a breakable rock.")
end
Lua:
local config = {
trees = {2701,2702,2703,2704,2705,2706,2707,2708,2709,2710,2712,2717,2718,2720,2722},
t = {
[{1, 100}] = {tree = 2701},
[{101, 200}] = {tree = 2702},
[{201, 300}] = {tree = 2703},
[{301, 400}] = {tree = 2704},
[{401, 500}] = {tree = 2705},
[{501, 600}] = {tree = 2706},
[{601, 700}] = {tree = 2707},
[{701, 800}] = {tree = 2708},
[{801, 900}] = {tree = 2709},
[{901, 1000}] = {tree = 2710},
[{1001, 1100}] = {tree = 2712},
[{1101, 1200}] = {tree = 2717},
[{1201, 1300}] = {tree = 2718},
[{1301, 1400}] = {tree = 2720},
[{1401, 1500}] = {tree = 2722}
},
level = 15,
skill = SKILL_AXE,
skillReq = 10,
effect = CONST_ME_BLOCKHIT,
addTries = 100,
branches = 6432,
msgType = MESSAGE_EVENT_ADVANCE,
soul = 3,
minutes = 5
}
local t = {
[{1, 500}] = {msg = "You choped the tree and got some wood", item = 5901, amountmax = 3},
[{501, 750}] = {msg = "You have damaged your axe and it broke!", destroy = true},
[{751, 1550}] = {msg = "You choped the tree down, but the the wood was not good."},
[{1551, 1650}] = {msg = "oh no the tree had a Wasps nest in it!", summon = "Wasp"},
[{1651, 1750}] = {msg = "You hurt your self while choping the tree down", damage = {1, 100}},
[{1751, 2000}] = {msg = "You choped the tree and got some wood", item = 5901, amountmax = 5},
[{2001, 2250}] = {msg = "A cat that was stuck jumped from the choped tree", summon = "Cat"},
[{2251, 2500}] = {msg = "There was a bird's nest in the tree and you took some eggs from the nest", item = 2695, amountmax = 5},
[{2501, 2750}] = {msg = "Hahaa! You found a sack with coins in it!", item = 2148, amountmax = 50},
[{2751, 3000}] = {msg = "A rat jumped at you!", summon = "Rat"}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isInArray(config.trees, itemEx.itemid) and config.level <= getPlayerLevel(cid) and config.skillReq <= getPlayerSkill(cid, config.skill) and config.soul <= getPlayerSoul(cid) then
local v, amount, damage = math.random(3000), 1, nil
for i, k in pairs(t) do
if v >= i[1] and v <= i[2] then
if k.destroy then
doRemoveItem(item.uid)
end
if k.summon then
doCreateMonster(k.summon, toPosition)
end
if k.damage then
damage = math.random(k.damage[1], k.damage[2])
doCreatureAddHealth(cid, - damage)
doSendMagicEffect(getThingPos(cid), CONST_ME_DRAWBLOOD)
doSendAnimatedText(getThingPos(cid), damage, TEXTCOLOR_RED)
end
if k.item then
if k.amountmax then
amount = math.random(k.amountmax)
end
doPlayerAddItem(cid, k.item, amount)
end
if k.msg then
local msg = k.msg
doPlayerSendTextMessage(cid, config.msgType, msg)
end
local function newTrees(parameter)
local tree = getThingfromPos{x = parameter.position.x, y = parameter.position.y, z = parameter.position.z, stackpos = 1}
for i2, k2 in pairs(config.t) do
local v2 = math.random(1500), 1, nil
if v2 >= i2[1] and v2 <= i2[2] then
if k2.tree then
if (tree.itemid == config.branches) then
doTransformItem(tree.uid, k2.tree)
end
end
end
end
end
addEvent(newTrees, config.minutes*60*1000, {position = toPosition, cid = cid})
doTransformItem(itemEx.uid, config.branches)
doPlayerAddSoul(cid, -config.soul)
doSendMagicEffect(toPosition, k.destroy and CONST_ME_HITAREA or config.effect)
return doPlayerAddSkillTry(cid, config.skill, config.addTries)
end
end
end
return doPlayerSendCancel(cid, "Either this tree can't be choped or you don't have enough experience, skill or soul to chop this tree.")
end
6. Now to give use to all the wood you collect from chopping down trees, make a file in actions/scripts and name it fletching.lua and copy this:
Lua:
local cfg = {
msgType = MESSAGE_INFO_DESCR,
cancel = "You don't have the requiered level."
}
local t = {
[{1, 200}] = {level = 15, item = 2389, name = "spear"},
[{201, 300}] = {level = 20, item = 2544, name = "arrow"},
[{301, 400}] = {level = 25, item = 2543, name = "bolt"},
[{401, 500}] = {level = 30, item = 2547, name = "power bolt"},
[{501, 1000}] = {level = 1, destroy = "You attemted to craft something and broke the piece of wood"},
[{1001, 1200}] = {level = 35, item = 7363, name = "piercing bolt"},
[{1201, 1300}] = {level = 40, item = 7365, name = "onyx arrow"},
[{1301, 1400}] = {level = 45, item = 7364, name = "sniper arrow"},
[{1401, 1500}] = {level = 1, destroyknife = "Your knife broke."}
}
function onUse(cid, item, frompos, item2, item3, topos)
if item2.itemid == 0 then
return 0
end
if item2.itemid == 5901 then
local r = math.random(1500), 1, nil
local level = getPlayerLevel(cid)
for i, k in pairs(t) do
if r >= i[1] and r <= i[2] then
if level >= k.level then
if k.item then
doPlayerAddItem(cid, k.item, 1)
doRemoveItem(item2.uid, 1)
doPlayerSendTextMessage(cid, cfg.msgType, "You crafted "..k.name..".")
end
if k.destroy then
doRemoveItem(item2.uid, 1)
doPlayerSendTextMessage(cid, cfg.msgType, k.destroy)
end
if k.destroyknife then
doRemoveItem(item2.uid, 1)
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid, cfg.msgType, k.destroyknife)
end
else
doPlayerSendCancel(cid, cfg.cancel)
end
end
end
else
return 0
end
return 1
end
Now copy this to your actions.xml:
PHP:
<!-- Farming -->
<action itemid="5710" script="farming.lua"/>
<action itemid="2552" script="hoesoil.lua"/>
<!-- Fruit Trees -->
<action itemid="5157;4006;5094;5096" event="script" value="harvest plants.lua"/>
<action itemid="2553" event="script" value="mining.lua"/>
<action itemid="2386" event="script" value="woodcutting.lua"/>
<action itemid="2403" event="script" value="fletching.lua"/>
[EXPLANATION]
Order is:
1 = Script 1
2 = Script 2
3 = Script 3
4 = Script 4
5 = Script 5
6 = script 6
Now for explanations let's start by:
1. is a farming script in which you place a fruit(mango, coconut, blueberry, banana and orange) on the ground and use a shovel(5710) and it will grow to a tree with no fruits then after the specified amount of time elapses, the tree grows fruits then after a while it dies.
2. is a land plowing script in which you plow the soil(103) with a hoe(2552) to make it ready for planting, it turns to plowed soil(804).
3. is a script that allows the specified trees to give you their respective fruits(you can add more) when you click use on that particular tree.
4. is a mining script in with you use a pick(2553) to break stones in order to get iron and other precious stones, including some gold.
[UPDATED]
5. is a woodcutting script that...well... cuts trees down with an axe(2386) in order to get wood and in 5 minutes a new tree grows in its place.
6. is a script in which you use a knife(2403) on a piece of wood(5901) to create arrows, spears, bolts and such, all according to the level required to create them.
well i hope you guys like it and please leave a comment.
[NOTE]
the mining script is made by Cykotitan and the woodcutting is the same only re-configured to cut down wood, and the farming script is made by me using Kakashi~sensei and Nirer's script structure as the base of the farming script, so thanks to that, this script can be made, oh yea, all of the scripts consume soul points in order so players don't abuse of the benefits that these scripts give players ingame.
Last edited: