• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Creating functions

Exura ATS

New Member
Joined
Feb 5, 2017
Messages
72
Reaction score
4
Hi!

Can someone create variables that make pick destroy some stones on the map, and small axe destroy small fir trees? And tell me where to put those lines? :s

Here's the details:

Pick:
You see a pick.
It weighs 45.00 oz.
ItemID: [2553].

Stone:
You see a stone.
ItemID: [1285].

Small Axe:
You see a small axe.
It weighs 20.00 oz.
ItemID: [2559].

Small Fir Tree:
You see a small fir tree.
ItemID: [2768].
 
Solution
@Mummrik Hey, bro!
Thanks for helping. Can you have a quick look on my pick.lua?



Is it anything wrong? Pick.lua really contains the other tools inside it?
And, where may I paste your lines?
Ok, it seems like you got a script that take care of all the tools in one script.
We can take this in private converation, if you want.

So let me update your script to take care of the other stuff you wanted aswell.
But the items (stone and fir tree) you want to get destoryed need to have actionid 100 when im done whit this script.
mainly to make it impossible to destory every stone and fir tree on the map
Post tfs version.

15d2bsy.png
 
Hi!

Can someone create variables that make pick destroy some stones on the map, and small axe destroy small fir trees? And tell me where to put those lines? :s

Here's the details:

Pick:


Stone:


Small Axe:


Small Fir Tree:
I made 2 scripts that will take care of this but i did also add an actionid (100) to it that you have to set inside mapeditor. If you want every stone or fir tree to get destoryed, you have to remove this code " and itemEx.actionid == 100" from both scripts. then every stone/fir tree is destoryable.

Anyways, first open data\actions\scripts\tools\pick.lua and add this

Lua:
    if (itemEx.itemid == 1285 and itemEx.actionid == 100) then
       doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
       doRemoveItem(itemEx.uid)
       return true
   end

Then you have to make a new lua file inside the same folder, and name it smallaxe.lua and add this inside that file
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   if (itemEx.itemid == 2768 and itemEx.actionid == 100) then
       doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
       doRemoveItem(itemEx.uid)
       return true
   end

   return false
end

Then open data\actions\actions.xml and add this inside that file
XML:
<action itemid="2559" event="script" value="tools/smallaxe.lua"/>
 
@Mummrik Hey, bro!
Thanks for helping. Can you have a quick look on my pick.lua?

local holes = {468, 481, 483, 7932, 385}
local holeId = {294, 369, 370, 383, 392, 408, 409, 427, 428, 430, 462, 469, 470, 482, 484, 485, 489, 924, 385, 3135, 3136}
function onUse(cid, item, fromPosition, itemEx, toPosition)

-- Shovel
if isInArray(holes, itemEx.itemid) == TRUE then
doTransformItem(itemEx.uid, itemEx.itemid + 1)
doDecayItem(itemEx.uid)
return FALSE

-- Rope
elseif toPosition.x == CONTAINER_POSITION or toPosition.x == 0 and toPosition.y == 0 and toPosition.z == 0 then
return FALSE
end
local groundTile = getThingfromPos(toPosition)
if groundTile.itemid == 384 or groundTile.itemid == 418 or groundTile.itemid == 8278 then
doTeleportThing(cid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z - 1}, FALSE)
elseif isInArray(holeId, itemEx.itemid) == TRUE then
local hole = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE})
if hole.itemid > 0 then
doTeleportThing(hole.uid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, FALSE)
else
doPlayerSendCancel(cid, "Sorry, not possible.")
end
return FALSE

-- Pick
elseif (itemEx.uid <= 65535 or itemEx.actionid > 0) and (itemEx.itemid == 354 or itemEx.itemid == 355 or itemEx.itemid == 9024 or itemEx.itemid == 9025) then
doTransformItem(itemEx.uid, 392)
doDecayItem(itemEx.uid)
return TRUE
elseif itemEx.uid == 60001 then
doTeleportThing(cid, {x=329, y=772, z=10})
doSendMagicEffect({x=329, y=772, z=10},10)
return TRUE

-- Machete
elseif itemEx.itemid == 2782 then
doTransformItem(itemEx.uid, 2781)
doDecayItem(itemEx.uid)
return TRUE
elseif itemEx.itemid == 1499 then
doRemoveItem(itemEx.uid)
return TRUE

-- Scythe
elseif itemEx.itemid == 2739 then
doTransformItem(itemEx.uid, 2737)
doCreateItem(2694, 1, toPosition)
doDecayItem(itemEx.uid)
return TRUE
end
return destroyItem(cid, itemEx, toPosition)
end

Is it anything wrong? Pick.lua really contains the other tools inside it?
And, where may I paste your lines?
 
@Mummrik Hey, bro!
Thanks for helping. Can you have a quick look on my pick.lua?



Is it anything wrong? Pick.lua really contains the other tools inside it?
And, where may I paste your lines?
Ok, it seems like you got a script that take care of all the tools in one script.
We can take this in private converation, if you want.

So let me update your script to take care of the other stuff you wanted aswell.
But the items (stone and fir tree) you want to get destoryed need to have actionid 100 when im done whit this script.
mainly to make it impossible to destory every stone and fir tree on the map
 
Solution
Ok, it seems like you got a script that take care of all the tools in one script.
We can take this in private converation, if you want.

So let me update your script to take care of the other stuff you wanted aswell.
But the items (stone and fir tree) you want to get destoryed need to have actionid 100 when im done whit this script.
mainly to make it impossible to destory every stone and fir tree on the map

Thanks.
 

Similar threads

Back
Top