• 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!

Adapt two code

2057623

Member
Joined
Jan 16, 2012
Messages
97
Reaction score
12
Good afternoon, I liked two codes, but they are TFS 0.4 and the one I'm using is 1.4 from nekiro, I wanted to see if someone could adapt it to 1.4.

First Code
--- Sistema de cultivo feito por Killua, XTibia.com

local usableDirt = 103 -- Terra que pode ser arada
local mustBeInHouse = "yes" -- Só pode usar dentro de house [yes/no]
local fruits = {8843, 8845, 8838, 2683, 2682, 2684, 8842} -- Frutas que podem nascer
local failChance = 50 -- Chande em % de falhar e a arvore morrer.

function transformGround(pos, id)
pos.stackpos = 0
return doTransformItem(getThingFromPos(pos).uid, id)
end

function getUnwantedItem(pos)
for i = 1, 5 do
pos.stackpos = i
if getThingFromPos(pos).itemid > 0 and getThingFromPos(pos).itemid ~= 7732 then
return true
end
end
return false
end

function transformTo(pos, fromid, toid)
for s = 1, 5 do
pos.stackpos = s
local item = getThingFromPos(pos)
if item.itemid == fromid then
doTransformItem(item.uid, toid)
end
end
end

function doRemoveMe(pos, id)
for stackpos = 1, 5 do
pos.stackpos = stackpos
local item = getThingFromPos(pos)
if item.itemid == id then
doRemoveItem(item.uid)
end
end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
if mustBeInHouse == "yes" and not getHouseFromPos(toPosition) then
return doPlayerSendCancel(cid, "Voce so pode plantar dentro de houses.")
end

toPosition.stackpos = 0
local tile = getThingFromPos(toPosition)
if tile.itemid == usableDirt and not getUnwantedItem(toPosition) and itemEx.itemid ~= 7732 then
if item.itemid == 2552 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce arou o solo")
doTransformItem(tile.uid, 804)
addEvent(transformGround, math.random(54600, 68600), toPosition, usableDirt)
end
elseif item.itemid == 7732 and tile.itemid == 804 and not getUnwantedItem(toPosition) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce plantou a semente.")
doRemoveItem(item.uid, 1)
doCreateItem(6216, 1, toPosition)
doSendMagicEffect(toPosition, CONST_ME_SMALLPLANTS)
local chance = math.random(1, 100)
local time1 = math.random(8500, 12600)
local time2 = math.random(24500, 28600)
if chance <= failChance then
addEvent(transformTo, time1, toPosition, 6216, 2784)
addEvent(doSendMagicEffect, time1, toPosition, 7)
addEvent(doRemoveMe, time2, toPosition, 2784)
addEvent(doSendMagicEffect, time2, toPosition, CONST_ME_POFF)
else
addEvent(transformTo, time1, toPosition, 6216, 2779)
addEvent(doSendMagicEffect, time1, toPosition, CONST_ME_SMALLPLANTS)
addEvent(doSendMagicEffect, time2, toPosition, CONST_ME_PLANTATTACK)
addEvent(transformTo, time2, toPosition, 2779, fruits[math.random(1, #fruits)])
end
elseif itemEx.itemid == 2784 or itemEx.itemid == 2779 then
if tile.itemid == 804 or tile.itemid == 103 then
doRemoveItem(itemEx.uid, 1)
doSendMagicEffect(toPosition, 3)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce removeu planta")
end
else
doPlayerSendCancel(cid, "Voce nao pode preparar este solo.")
end
return true end

Second Code
function onKill(cid, target, lastHitKiller)
if(isPlayer(target) and isPlayer(lastHitKiller)) then
if getCreatureSkullType(target) == SKULL_NONE then
doPlayerSendTextMessage(cid, 22, "Parabens, voce matou o jogador "..getCreatureName(target).." e tirou seu coraçao")
function additem()
local aditi = doPlayerAddItem(lastHitKiller, 5943, 1)
doItemSetAttribute(aditi, "description", "Este foi retirado de "..getCreatureName(target).."")
end
addEvent(additem, 1000)
end
else
doPlayerSendTextMessage(cid, 22, "Parabens, voce matou o jogador "..getCreatureName(target).." e tirou seu coraçao")
function add2()
local adoto = doPlayerAddItem(lastHitKiller, XXX, 1)
doItemSetAttribute(aditi, "description", "Este foi retirado de "..getCreatureName(target).."")
end
addEvent(add2, 1000)
end
end
 
Back
Top