BR
pedido

Script de Fome :O

Por BrenoNeto, 13 de mar. de 2013 em Scripts

tibia
script
otserv
50
5.5k
BrenoNetoB
14 de março de 2013 às 19:10

A creature script n funfo, sempre q morro, relogo e continuo morrendo se eu n comer :c

Como coonfiguro a script pro player perder o life em porcentagem, exemplo, 5% ao invez de perder 25 de life ? para não beneficiar players com level mais alto

Editado Março 14 por BrenoNeto

SlicerS
14 de março de 2013 às 19:26

@rok

tire isso..

isPlayer(cid)

isso eh uma ondeath... a funçao isPlayer verifica se o player ta online...

RoksasR
14 de março de 2013 às 19:27

Perdão, aqui está:

 

function onDeath(cid, corpse, killer)
if getPlayerFood(cid) < 1000 then
doPlayerFeed(cid, 1000)
end
return true
end

 

Aonde você quer essa porcentagem?

BrenoNetoB
14 de março de 2013 às 19:34

@Edit Mentiraaa! e no globalevents ! vo pegar aki

 

 

function onThink(interval, lastExecution)

morre = 400 -- com mas ou menos 600 ja começa a morrer

life = 25 -- quanto de life player vai perdendo

time = 1100 -- (tempo 1000 por segundos)

sto = 15725 --

if death() then -- não mexe

end

return 1

end

function death()

for _, name in ipairs(getOnlinePlayers()) do

if getPlayerStorageValue(getPlayerByName(name), sto) >= os.time() then return true end

if isCreature(getPlayerByName(name)) then

if getPlayerFood(getPlayerByName(name)) <= morre then

doCreatureAddHealth(getPlayerByName(name), -life)

addEvent(death, 2000,getPlayerByName(name))

doSendAnimatedText(getPlayerPosition(getPlayerByName(name)),""..life.."", math.random(144,145))

setPlayerStorageValue(getPlayerByName(name), sto, os.time() + time / 1000)

end

end

return true

end

end

Editado Março 14 por BrenoNeto

SlicerS
14 de março de 2013 às 19:43

eu sinceramente achu melhor usar onLogin doq globalevent pra isso.. sei la.. eu fiz um sistema aki n testei mas... sei la..

actions/scripts/other/food.lua

 

local max = 500 --maximo de food
local food = {
[2362] = {80, "Crunch."},
[2666] = {50, "Munch."},
[2667] = {100, "Munch."},
[2668] = {100, "Mmmm."},
[2669] = {100, "Munch."},
[2670] = {40, "Gulp."},
[2671] = {100, "Chomp."},
[2672] = {100, "Chomp."},
[2673] = {50, "Yum."},
[2674] = {60, "Yum."},
[2675] = {100, "Yum."},
[2676] = {80, "Yum."},
[2677] = {10, "Yum."},
[2678] = {100, "Slurp."},
[2679] = {10, "Yum."},
[2680] = {20, "Yum."},
[2681] = {90, "Yum."},
[2682] = {100, "Yum."},
[2683] = {100, "Munch."},
[2684] = {80, "Crunch."},
[2685] = {60, "Munch."},
[2686] = {90, "Crunch."},
[2687] = {20, "Crunch."},
[2688] = {90, "Munch."},
[2689] = {100, "Crunch."},
[2690] = {30, "Crunch."},
[2691] = {80, "Crunch."},
[2792] = {60, "Munch."},
[2793] = {90, "Munch."},
[2695] = {60, "Gulp."},
[2696] = {90, "Smack."},
[2787] = {90, "Munch."},
[2788] = {40, "Munch."},
[2789] = {100, "Munch."},
[2790] = {100, "Munch."},
[2791] = {100, "Munch."},
[2792] = {60, "Munch."},
[2794] = {30, "Munch."},
[2795] = {100, "Munch."},
[2796] = {50, "Munch."},
[2793] = {90, "Munch."},
[5097] = {40, "Yum."},
[6125] = {80, "Gulp."},
[6278] = {100, "Mmmm."},
[6279] = {100, "Mmmm."},
[6393] = {100, "Mmmm."},
[6394] = {100, "Mmmm."},
[6501] = {100, "Mmmm."},
[6541] = {60, "Gulp."},
[6542] = {60, "Gulp."},
[6543] = {60, "Gulp."},
[6544] = {60, "Gulp."},
[6545] = {60, "Gulp."},
[6569] = {10, "Mmmm."},
[6574] = {40, "Mmmm."},
[7158] = {100, "Munch."},
[7159] = {100, "Munch."},
[7372] = {70, "Yum."},
[7373] = {70, "Yum."},
[7374] = {70, "Yum."},
[7375] = {70, "Yum."},
[7376] = {70, "Yum."},
[7377] = {70, "Yum."},
[7909] = {40, "Crunch."},
[8838] = {70, "Gulp."},
[8839] = {50, "Yum."},
[8840] = {20, "Yum."},
[8841] = {30, "Urgh."},
[8842] = {30, "Munch."},
[8843] = {30, "Crunch."},
[8844] = {30, "Gulp."},
[8845] = {20, "Munch."},
[8847] = {100, "Yum."},
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(food[item.itemid] == true) then
if(getPlayerFood(cid) + food[item.itemid][1]) >= max then
doPlayerSendCancel(cid, "You are full.")
else
doPlayerFeed(cid, food[item.itemid][1] /2.7)
doCreatureSay(cid, food[item.itemid][2], TALKTYPE_ORANGE_1)
doRemoveItem(item.uid, 1)
end
return TRUE
end
return FALSE
end

 

 

creaturescripts/scripts/Food.lua

 

local min = 50 --apartir de 50 de fome começa a perde life
local time = 3 --qnts em qnts segs vai checar a fome do player
local percent = 5 --qnts % de life o player vai perder

local function checkFood(cid)
if not isCreature(cid) then return true end
if getPlayerFood(cid) <= min then
  doCreatureAddHealth(cid, -(getCreatureMaxHealth(cid) * (percent/100)))
  doPlayerSendTextMessage(cid, 27, "You need to eat some food or you will die!")
end
addEvent(checkFood, time*1000, cid)
end

function onLogin(cid)
checkFood(cid)
registerCreatureEvent(cid, "Food_Death")
return true
end

 

 

tag:

<event type="login" name="Food" event="script" value="Food.lua"/>

 

creaturescripts/scripts/Food_Death.lua

 

local max = 500 --maximo de food

function onDeath(cid, corpse, killer)
if getPlayerFood(cid) < max then
  doPlayerFeed(cid, max)
end
return true
end

 

 

tag:

<event type="death" name="Food_Death" event="script" value="Food_Death.lua"/>

Editado Março 14 por Slicer

BrenoNetoB
14 de março de 2013 às 19:52

Não precisa colocar nada em login.lua ?

SlicerS
14 de março de 2013 às 19:55

nao pq ja ta no onLogin ali...

BrenoNetoB
14 de março de 2013 às 20:03

Duas coisas, uma deu error quando dou use no food, mais não aparece nada no console e outra, outra como vou saber em quanto está minha fome ?

 

Se vc puder me adc no skype, breno.ale21

SlicerS
14 de março de 2013 às 20:08

como q da error se n aparece nd no console o.O oq q deu? eu soh copiei o food q postaram ae...

 

sobre como saber, pode usar a talk q postaram ali na 1** pag..

 

talkactions/scripts/Check_Food.lua

 

local max = 500
function onSay(cid, words, param, channel)  
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "His hunger is [".. getPlayerFood(cid).."/"..max.."]")
end

 

 

tag:

<talkaction words="/checkFood" event="script" value="Check_Food.lua"/>

Editado Março 14 por Slicer

BrenoNetoB
14 de março de 2013 às 20:20

Não sei pq ta dando esse error tbm, não aparece nada no console do server só you cannot use this object. :X

 

Versão do OT é 8.6 caso precise u.u

SlicerS
14 de março de 2013 às 20:24

eh q tas tentando usar uma food q n ta na tabela... ;x

eh soh adicionar outra linha ali na tabela com o id dessa food q tas usando...

BrenoNetoB
14 de março de 2013 às 21:03

Estou usando sim uma food da tabela (meat) id 2666, está na tag das actions tbm.

 

Bom vou usar o do notle12 mesmo, o unico que funcionou, só preciso que alguem me ajude numa coisa, quando o player morrer, o tempo para comer voltar :x

notle2012N
14 de março de 2013 às 21:27

vai em

data\creaturescripts\scripts

cria arquivo com nome

deathfood.lua

coloca isso

death = 200 -- quando morre vai nascer com 200 de fome só edita
function onLogin(cid)
death_food(cid)
registerCreatureEvent(cid, "deathfood")
return 1
end
function death_food(cid)
if isCreature(cid) and getPlayerFood(cid) <= 10 then
doPlayerFeed(cid,death/2.8)
end
end

creaturescripts.xml

<event type="login" name="deathfood" event="script" value="deathfood.lua"/>

espero ter ajudado :)

BrenoNetoB
15 de março de 2013 às 00:06

Agora sim! 100% resolvido. Valeu Notle12 u.u quando tiver fanbar me passar kkk'

 

Valeu tbm aos outros, Slicer, Roksas e OrochiELF :D

 

Como faço pra script de fome ao inves de perder 25 de life a cada segundo, perder 5% do life total ?

Editado Março 15 por BrenoNeto

notle2012N
15 de março de 2013 às 00:47

vai em data\globalevents\scripts\death.lua

troca por esse

só editar

life = 5 -- porcentagens

function onThink(interval, lastExecution)
morre = 600  -- com mas ou menos 600 ja começa a morrer
life = 5 -- porcentagens
time = 1100 -- (tempo 1000 por segundos)
sto = 15725 --
death()   -- não mexe
return 1
end
function death()
for _, name in ipairs(getOnlinePlayers()) do
if getPlayerStorageValue(getPlayerByName(name), sto) >= os.time() then return true end
if isCreature(getPlayerByName(name)) then
if getPlayerFood(getPlayerByName(name)) <= morre then
pc = getCreatureMaxHealth(getPlayerByName(name))/100
doCreatureAddHealth(getPlayerByName(name), -math.floor((pc*life)))
addEvent(death, 2000,getPlayerByName(name))
doSendAnimatedText(getPlayerPosition(getPlayerByName(name)),""..math.floor(pc*life).."", math.random(144,145))
setPlayerStorageValue(getPlayerByName(name), sto, os.time() + time / 1000)
end
end
end
end