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

[ CreatureEvent ] When monster dies, gives player Storage

Takayaki

New Member
Joined
Mar 28, 2012
Messages
4
Reaction score
0
Hello ppl, what's up?
Well.. I need a script to make player own the storage I wanted if he kill any monster on the server...
I'm planning on doin' something like another EXP system with this...
Then for example I get 1 point in Storage = "2222222" if I kill any monster on the server, and when i reach certain ammount of points in that storage, I do gain 3 point in other Storage... Storage = "2222223".
Can u ppl help me? I just got the idea, but don't know how to make it >.<"
Sorry for english errors :3.
 
LUA:
local monsterName = 'demon'
local needStorage = true
local storage = 8000
local valueNeeded = -1
local valueGiven = 1


function onKill(cid, target)
   if isMonster(target) and getCreatureName(target):lower() == monsterName then
       if getPlayerStorageValue(cid,storage) == valueNeeded or not needStorage then
       setPlayerStorageValue(cid,storage,valueGiven)
	end
   end
   return true
end

Something like that, not tested
 
LUA:
local monsterName = 'demon'
local needStorage = true
local storage = 8000
local valueNeeded = -1
local valueGiven = 1


function onKill(cid, target)
   if isMonster(target) and getCreatureName(target):lower() == monsterName then
       if getPlayerStorageValue(cid,storage) == valueNeeded or not needStorage then
       setPlayerStorageValue(cid,storage,valueGiven)
	end
   end
   return true
end

Something like that, not tested

tested and works.
 
Thanks man, but unfortunately it doesn't work as i expected. I'm trying to modify the code I have, but it is a forge system with level and exp on storages, so i thought : "Well I just need to put it as creature event, and do some changes!..." But for certain I were wrong about doin' this kind of magic, transforming a code with Libs and >>Action Scripts<< to a Creature Event. I guess that if i could take off the part of the Lib that ask for the use of the itens and the recipes, keepin' the mathematic and scripting parts. It would be very easy to make the Creature Event happens... By the way!? How should I do this?... I'm very bad making scripts, but I can modify them if they are close to my expectations u know?
The thing i was asking here was about a Creature Event to every monster in the sever, not only one specific monster :3

Anyway, if you ppl wanted to check the Libs and Action for the Forge system I have, and try to help me. Then here it is... The owner of the script is "Author: Maxwell Denisson(MaXwEllDeN)". If you find it interesting, then be sure to thanks this guy, I just modified some little things ^^. So here we go...

...Data\Actions\scripts...
Code:
--[[
################################################
## Smith System ##
## Author: Maxwell Denisson(MaXwEllDeN) ##
## Version: 1.0 ##
################################################
]]

function onUse(cid, item, frompos, item2, topos)
local tekz, takz, tikz, XTz = {}, {}, {}, {}
for _, v in pairs(getAllItemsInPos(topos, {1642, 1643, 1644, 1645, 1617, 1618, 1620, 1621})) do
table.insert(takz, v)
end

for _, v in pairs(takz) do
if not isInArray(tikz, v.uid) then
if (v.itemid ~= 2555) then
table.insert(XTz, v)
end
table.insert(tikz, v.uid)
table.insert(tekz, v.itemid)
end
end

if not (isInArray(tekz, 2555)) then
return false
end

local u, d = _SMITHY_.getRevenue(topos)
if (u == 0) then
for i, v in pairs(d) do
if (math.random(100) > 100) then
local tp = (v.type > 0) and v.type or 1
doRemoveItem(v.uid, tp)
end
end
if (#d > 0) then
doSendMagicEffect(topos, 2)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Por favor, cheque os itens.")
end
return true
end

local rec = _SMITHY_.receitas[u]

if getPlayerStorageValue(cid, 58912) < rec.lvl then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você ainda não é um Blacksmith tão bom! Se foque em melhorar!")
else
if (math.random(100.0) + _SMITHY_.getLevel(cid) < (rec.dif - 10 - (_SMITHY_.getLevel(cid)*0.2 ) )) then
for i, v in pairs(d) do
if (math.random(100.0) > 0) then
local tp = (v.type > 0) and v.type or 1
doRemoveItem(v.uid, tp)
end
end
doSendMagicEffect(topos, 6)
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você falhou na criação de ".. getItemNameById(rec.ma[1]) .. ".")
end
end

local xp = math.random(rec.dif)
doCreatureSay(cid, "Feito! - EXP : " .. xp .. "", TALKTYPE_MONSTER)
_SMITHY_.addExp(cid, xp)

if (_SMITHY_.getExp(cid) >= _SMITHY_.getExpToNextLevel(cid)) then
setPlayerStorageValue(cid, 58913, 0)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você avançou do nível ".. _SMITHY_.getLevel(cid) .. " para o nível ".. _SMITHY_.getLevel(cid) + 1 .. ", de Blacksmith. Parabéns ferreiro!")
end

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Experiencia: ".. _SMITHY_.getExp(cid) .. "/".. _SMITHY_.getExpLevel(_SMITHY_.getLevel(cid) * 2) ..".")
for _, v in pairs(d) do
local tp = (v.type > 0) and v.type or 1
doRemoveItem(v.uid, tp)
end

doSendMagicEffect(topos, 15)
doItemSetAttribute(doCreateItem(rec.ma[1], rec.ma[2], topos), "description", "Forjado por ".. getCreatureName(cid) .."")
doPlayerSendTextMessage(cid, 25, "Você forjou uma ".. getItemNameById(rec.ma[1]) .. "!")

return TRUE
end

...Data\Lib\...

Code:
--[[
################################################
## Smith System ##
## Author: Maxwell Denisson(MaXwEllDeN) ##
## Version: 1.0 ##
################################################
]]

_SMITHY_ = {
exp_b = 13,
receitas = {
--dif = Dificuldade
[1] = {dif = 5, -- Staff
lvl = 0,
re = {{5892, 1},
},
ma = {2401, 1}
},
[2] = {dif = 100.0, -- staff
lvl = 0,
re = {{5901, 5},
{5880, 1},
},
ma = {2401, 1}
},

}

}

_SMITHY_.getRevenue = function (pos)
local recs = {}
local ipos = {}
local posi = {}

local block = {1642, 1643, 1644, 1645, 1617, 1618, 1620, 1621, 2555}

local IDEx = 0

for i, v in pairs(_SMITHY_.receitas) do
recs[i] = {}
for _, a in pairs(v.re) do
for b = 1, a[2] do
table.insert(recs[i], a[1])
end
end
end

local Zk = {}
for _, v in pairs(getAllItemsInPos(pos, block)) do
if not isInArray(Zk, v.uid) then
table.insert(ipos, v)
table.insert(Zk, v.uid)
end
end

for _, v in pairs(ipos) do
local t = (v.type > 0) and v.type or 1
for te = 1, t do
table.insert(posi, v.itemid)
end
end

for _, v in pairs(recs) do
local AE = true
for x, i in pairs(posi) do
if (AE) then
if (not isInArray(v, i)) or (#v ~= #posi) then
AE = false
else
IDEx = _
end
end
end
end

if (#recs < 1) then
return 0, ipos
else
return IDEx, ipos
end
end

_SMITHY_.getExp = function (uid)
if (getPlayerStorageValue(uid, 58913) < 1) then
setPlayerStorageValue(uid, 58913, 0)
end
return getPlayerStorageValue(uid, 58913)
end

_SMITHY_.getLevel = function (uid)
if (getPlayerStorageValue(uid, 58912) < 1) then
setPlayerStorageValue(uid, 58912, 1)
end
return getPlayerStorageValue(uid, 58912)
end

_SMITHY_.addLevel = function (uid, ammount)
local level = _SMITHY_.getLevel(uid)
return setPlayerStorageValue(uid, 58912, level + ammount)
end

_SMITHY_.getExpToNextLevel = function (uid)
return _SMITHY_.getExpLevel(_SMITHY_.getLevel(uid) * 2)
end

_SMITHY_.getExpLevel = function (level)
return level * (_SMITHY_.exp_b) + (level - 1* (_SMITHY_.exp_b))
end

_SMITHY_.setExp = function (uid, ammount)
return setPlayerStorageValue(uid, 58913, ammount)
end

_SMITHY_.addExp = function (uid, ammount)
local xp = _SMITHY_.getExp(uid)
return _SMITHY_.setExp(uid, xp + ammount)
end

function getAllItemsInPos(pos, block)
local results = {}

for _ = 1, 255 do
local findPos = {x = pos.x, y = pos.y, z = pos.z, stackpos = _}
local item = getThingFromPos(findPos)
if (not isInArray(block, item.itemid)) and (item.uid > 1) then
table.insert(results, item)
end
end

return results
end

Oh and my Server Version is TFS 3.7.0 [Tibia 9.60] xD. Just to make it clear~
 
Last edited:
I need to kill a monster and get +exp on one Storage... something that returns me in the console a message like...
"You own 100 exp and you need 350 for the next points"
"Congratulations you reach 350 exp, now u need 650 and u have 50 points left"
and the points thing need to be in other Storage number... And it need to have an EXP formula so i could balance it with the server's rate.
 
of course you can, setPlayerStorageValue(cid, get.the.respective.exp + new.exp)
not time now, but maybe tomorrow.
 
Last edited:
Back
Top