CreatureScripts TFS 1.X [Events] Stamina Regen On Target
-
Quem Está Navegando 0 membros estão online
Nenhum usuário registrado visualizando esta página.
-
Conteúdo Similar
-
Por Under
Precisei dessa função e não achei em lugar nem um aqui está uma versão funcional para tfs 1.2 +.
Listando o monstro ou player que o jogador morreu.
Data/Creaturescript/XML
<event type="login" name="LoginDeath" script="death_tp.lua" /> <event type="preparedeath" name="DeathTeleport" script="death_tp.lua"/> Data/Creaturescript/death_tp.lua
function onLogin(player) player:registerEvent("DeathTeleport") return true end local maxDeathRecords = 5 -- By Underewar function onPrepareDeath(player, killer) -- Update Death DB local byPlayer = 0 local killerName if killer ~= nil then if killer:isPlayer() then byPlayer = 1 else local master = killer:getMaster() if master and master ~= killer and master:isPlayer() then killer = master byPlayer = 1 end end killerName = killer:getName() else killerName = "field item" end local byPlayerMostDamage = 0 local mostDamageKillerName if mostDamageKiller ~= nil then if mostDamageKiller:isPlayer() then byPlayerMostDamage = 1 else local master = mostDamageKiller:getMaster() if master and master ~= mostDamageKiller and master:isPlayer() then mostDamageKiller = master byPlayerMostDamage = 1 end end mostDamageName = mostDamageKiller:getName() else mostDamageName = "field item" end local playerGuid = player:getGuid() db.query("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`) VALUES (" .. playerGuid .. ", " .. os.time() .. ", " .. player:getLevel() .. ", " .. db.escapeString(killerName) .. ", " .. byPlayer .. ", " .. db.escapeString(mostDamageName) .. ", " .. byPlayerMostDamage .. ", " .. (unjustified and 1 or 0) .. ", " .. (mostDamageUnjustified and 1 or 0) .. ")") local resultId = db.storeQuery("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. playerGuid) local deathRecords = 0 local tmpResultId = resultId while tmpResultId ~= false do tmpResultId = result.next(resultId) deathRecords = deathRecords + 1 end if resultId ~= false then result.free(resultId) end local limit = deathRecords - maxDeathRecords if limit > 0 then db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit) end if byPlayer == 1 then local targetGuild = player:getGuild() targetGuild = targetGuild and targetGuild:getId() or 0 if targetGuild ~= 0 then local killerGuild = killer:getGuild() killerGuild = killerGuild and killerGuild:getId() or 0 if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(playerId, killer:getId()) then local warId = false resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = " .. killerGuild .. " AND `guild2` = " .. targetGuild .. ") OR (`guild1` = " .. targetGuild .. " AND `guild2` = " .. killerGuild .. "))") if resultId ~= false then warId = result.getDataInt(resultId, "id") result.free(resultId) end if warId ~= false then db.asyncQuery("INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES (" .. db.escapeString(killerName) .. ", " .. db.escapeString(player:getName()) .. ", " .. killerGuild .. ", " .. targetGuild .. ", " .. os.time() .. ", " .. warId .. ")") end end end end -- teleportando o player para o templo player:teleportTo(player:getTown():getTemplePosition()) -- enchenco life e mana player:addHealth(player:getMaxHealth()) player:addMana(player:getMaxMana()) -- Remove EXP local level = player:getLevel() player:removeExperience(level * 10 * 100, true) -- DEATH MSG player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are dead.") -- criando efeito de teleport player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) return false end
-
Por Vorkhon
Ola pessoal. Eu quero fazer uma modificação no sistema de autoloot que encontrei. O gold vai direto para o banco, mas eu quero que ele só va direto para a BP do player.
Aqui é o código que eu tenho:
-- Sistema de auto loot criado por Vitor Bertolucci - Killua
local aloot_boost = {[2406] = 36, [2537] = 4800, [2377] = 480, [2663] = 600, [2472] = 195000, [2398] = 36, [2475] = 7200, [2519] = 6500, [2497] = 10700, [2523] = 180000, [2494] = 325000, [2400] = 144000, [2491] = 6000, [2421] = 325000, [2646] = 260000, [2477] = 7200, [2413] = 84, [2656] = 18000, [2498] = 52000, [2647] = 600, [2534] = 32500, [7402] = 19500, [2466] = 26000, [2465] = 240, [2408] = 120000, [2518] = 1800, [2500] = 3000, [2376] = 30, [2470] = 91000, [2388] = 24, [2645] = 26000, [2434] = 2400, [2463] = 480, [2536] = 11700, [2387] = 240, [2396] = 4800, [2381] = 240, [2528] = 4800, [2409] = 1800, [2414] = 12000, [2427] = 9000, [2407] = 7200, [2458] = 42, [2383] = 960, [2392] = 3600, [2488] = 18000, [2525] = 120, [2423] = 240, [7382] = 13000, [2462] = 1300, [2520] = 39000, [2390] = 180000, [2417] = 72, [2436] = 1200, [5741] = 52000, [2378] = 120, [2487] = 24000, [2476] = 6500, [8891] = 36000, [2459] = 36, [2195] = 52000, [2391] = 7200, [2464] = 120, [8889] = 72000, [2432] = 13000, [2431] = 108000, [2492] = 52000, [2515] = 240, [2430] = 2400, [2393] = 13000, [7419] = 36000, [2522] = 130000, [2514] = 65000}
local function getPlayerStorageZero(cid, storage) -- By Killua
local sto = getPlayerStorageValue(cid, storage)
if tonumber(sto) then
return tonumber(sto) > tonumber(0) and tonumber(sto) or tonumber(0)
end
return tonumber(0)
end
local tabela = {}
local function getPlayerList(cid)
local tab = {}
if getPlayerStorageValue(cid, 04420021) ~= -1 then
table.insert(tab, getPlayerStorageValue(cid, 04420021))
end
if getPlayerStorageValue(cid, 04420031) ~= -1 then
table.insert(tab, getPlayerStorageValue(cid, 04420031))
end
if getPlayerStorageValue(cid, 04420041) ~= -1 then
table.insert(tab, getPlayerStorageValue(cid, 04420041))
end
if getPlayerStorageValue(cid, 04420051) ~= -1 then
table.insert(tab, getPlayerStorageValue(cid, 04420051))
end
if #tab > 0 then
return tab
end
return {}
end
local function boost(cid)
return tonumber(getPlayerStorageValue(cid,722381)) >= os.time()
end
local function autoLoot(cid, pos)
if not isPlayer(cid) then return end
local check = false
local str = ""
local position = {}
for i = 1, 255 do
pos.stackpos = i
if getThingFromPos(pos).uid and getThingFromPos(pos).uid > 0 and isContainer(getThingFromPos(pos).uid) then
position = pos
check = true
break
end
end
if check then
local corpse = getContainerItemsInfo(getThingFromPos(position).uid)
if corpse then
for index, info in pairs(corpse) do
if index < countTable(corpse) then
if info.uid and info.itemid then
if isContainer(info.uid) then
local bag = getContainerItemsInfo(info.uid)
for i = 1, countTable(bag) do
if isInArray(getPlayerList(cid), bag.itemid) then
if bag.quant > 1 then
doRemoveItem(bag.uid, bag.quant)
doPlayerAddItem(cid, bag.itemid, bag.quant)
str = str.." "..bag.quant.." "..getItemNameById(bag.itemid).." +"
else
doRemoveItem(bag.uid)
if boost(cid) then
if aloot_boost[bag.itemid] then
doPlayerSetBalance(cid,getPlayerBalance(cid) + aloot_boost[bag.itemid])
str = str.." 1 "..getItemNameById(bag.itemid).." ("..aloot_boost[bag.itemid].."gp no banco) +"
else
doPlayerAddItem(cid, bag.itemid, 1)
str = str.." 1 "..getItemNameById(bag.itemid).." +"
end
else
doPlayerAddItem(cid, bag.itemid, 1)
str = str.." 1 "..getItemNameById(bag.itemid).." +"
end
end
end
end
end
end
end
if isInArray(getPlayerList(cid), info.itemid) then
if info.quant > 1 then
doRemoveItem(info.uid, info.quant)
doPlayerAddItem(cid, info.itemid, info.quant)
str = str.." "..info.quant.." "..getItemNameById(info.itemid).." +"
else
doRemoveItem(info.uid)
if boost(cid) then
if aloot_boost[info.itemid] then
doPlayerSetBalance(cid,getPlayerBalance(cid) + aloot_boost[info.itemid])
str = str.." 1 "..getItemNameById(info.itemid).." ("..aloot_boost[info.itemid].."gps no banco) +"
else
doPlayerAddItem(cid, info.itemid, 1)
str = str.." 1 "..getItemNameById(info.itemid).." +"
end
else
doPlayerAddItem(cid, info.itemid, 1)
str = str.." 1 "..getItemNameById(info.itemid).." +"
end
end
end
end
end
end
setPlayerTableStorage(cid,822564,{[1] = str, [2] = 0})
end
local function autoGold(cid, pos)
if not isPlayer(cid) then return end
local check = false
local total = 0
local position = {}
for i = 1, 255 do
pos.stackpos = i
if getThingFromPos(pos).uid and getThingFromPos(pos).uid > 0 and isContainer(getThingFromPos(pos).uid) then
position = pos
check = true
break
end
end
if check then
local corpse = getContainerItemsInfo(getThingFromPos(position).uid)
if corpse then
for index, info in pairs(corpse) do
if info.uid and info.itemid then
if index < countTable(corpse) then
if isContainer(info.uid) then
local bag = getContainerItemsInfo(info.uid)
for i = 1, countTable(bag) do
if isInArray({2148, 2152, 2160}, bag.itemid) then
local multiplie = 1
if bag.itemid == 2148 then
multiplie = 1
elseif bag.itemid == 2152 then
multiplie = 100
elseif bag.itemid == 2160 then
multiplie = 10000
end
doRemoveItem(bag.uid, bag.quant)
doPlayerSetBalance(cid, getPlayerBalance(cid) + tonumber(bag.quant) * multiplie)
total = total + bag.quant * multiplie
doPlayerSetStorageValue(cid, 04421021, tonumber(getPlayerStorageZero(cid, 04421021)) + tonumber(info.quant) * tonumber(multiplie))
end
end
end
end
if isInArray({2148, 2152, 2160}, info.itemid) then
local multiplie = 1
if info.itemid == 2148 then
multiplie = 1
elseif info.itemid == 2152 then
multiplie = 100
elseif info.itemid == 2160 then
multiplie = 10000
end
doRemoveItem(info.uid, info.quant)
doPlayerSetBalance(cid, getPlayerBalance(cid) + info.quant * multiplie)
doPlayerSetStorageValue(cid, 04421021, tonumber(getPlayerStorageZero(cid, 04421021)) + tonumber(info.quant) * tonumber(multiplie))
total = total + info.quant * multiplie
end
end
end
end
end
if total > 0 then
total = total - (total * 0.2)
total = math.ceil(total)
doPlayerSetBalance(cid,getPlayerBalance(cid) + total)
local tab = getPlayerTableStorage(cid,822564)
tab[2] = total
setPlayerTableStorage(cid,822564,tab)
end
end
local function sendMsg(cid)
if not isPlayer(cid) then return end
local tab = getPlayerTableStorage(cid,822564)
if countTable(tab) >= 1 then
if tab[1] then
if tab[2] and tab[2] > 0 then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[Auto Loot System] Coletados: ".. tab[1] .." ".. tab[2] .." gold coins.")
else
if type(tab[1]) == "string" and string.len(tab[1]) > 1 then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[Auto Loot System] Coletados: "..tab[1])
end
end
elseif not tab[1] then
if tab[2] then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "[Auto Loot System] Coletados: "..tab[2].." gold coins.")
end
end
end
doPlayerSetStorageValue(cid,822564,-1)
end
function onKill(cid, target, lastHit)
if isPlayer(cid) and isMonster(target) then
if getPlayerStorageValue(cid, 04421001) == 1 and #getPlayerList(cid) > 0 then
local pos = getCreaturePosition(target)
addEvent(autoLoot, 500, cid, pos)
end
if getPlayerStorageValue(cid, 04421011) == 1 then
local pos = getCreaturePosition(target)
addEvent(autoGold, 540, cid, pos)
end
if getPlayerStorageValue(cid, 04421001) == 1 or getPlayerStorageValue(cid, 04421011) == 1 then
addEvent(sendMsg, 560, cid)
end
end
return true
end
-
Por Mor3nao
Fiz esse script, pra tentar "balancear" as vocations de uma maneira diferente: Melhorar oque eu acho fraco, sem piorar oque está "forte".
Por exemplo: Sorcerers que deveriam ser a vocation de dano, bate menos que um druid, visto que ele tem o exevo gran frigo hur, então ao invés de eu editar o gran frigo hur, ou adicionar um "exevo gran flam hur", eu fiz com que os sorceres tenham uma % de chance de dar burn/electrify/curse quando bater com fire, energy e death (respectivamente). Aí deixei varias possibilidades de configurações, e cada um vai editando oq achar necessario até achar um ponto de "equilibrio" ?
Oque cada vocation pode fazer:
Adicionando o Script
em data/creaturescripts/creaturescripts.xml adicione a tag:
<event type="healthchange" name="balancevoc" script="vocation_balance.lua"/>
em data/creaturescript/scripts/login.lua (ou login_events, depende do teu sv) coloque a tag:
player:registerEvent("balancevoc)
em data/creaturescript/scripts adicione o arquivo vocation_balance.lua, abra-o e coloque o seguinte script:
Então vá até data/events/events.xml, procure por:
<event class="Creature" method="onTargetCombat" enabled="0" /> E mude enabled="0" para enabled="1"
Aí abra data/events/scripts/creature.lua, procure por function Creature:onTargetCombat(target) e abaixo, coloque a tag:
target:registerEvent("balancevoc")
E pronto, tá feito o sorvetinho ?
-
Por pergher
Fala galera, beleza?
Eu tenho o script tudo pronto já, porem quando dou trade no NPC ele não me deixa comprar o item "Store Coins", no meu outro server, funcionava.
Alguns detalhes:
- O item está na lista dos items.xml;
- existe o tibiacoin.lua, para que quando você dê use no item ele credite os 250 tibia coins no jogo, funcionando normalmente;
Só não consigo comprar do NPC, alguém tem alguma ideia do que falta?
-
Por Heitorzera13
Estou tentando colocar um sistema pra quando algum Player mata o outro ele manda uma mensagem pra todo servidor falando!
Usei essas scripts:
if killer:isPlayer() then Game.broadcastMessage(player:getName().."["..player:getLevel().."] acabou de ser morto pelo jogador "..killer:getName().."["..killer:getLevel().."].", MESSAGE_STATUS_DEFAULT) end Mas apresenta o seguinte erro no terminal:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/playerdeath.lua:onDeath
data/creaturescripts/scripts/playerdeath.lua:10: attempt to index field 'SvargrondArena' (a nil value)
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/playerdeath.lua:10: in function <data/creaturescripts/scripts/playerdeath.lua:3>
playerdeath:
local deathListEnabled = true
function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
local playerId = player:getId()
if nextUseStaminaTime[playerId] ~= nil then
nextUseStaminaTime[playerId] = nil
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are dead.')
if player:getStorageValue(Storage.SvargrondArena.Pit) > 0 then
player:setStorageValue(Storage.SvargrondArena.Pit, 0)
end
if not deathListEnabled then
return
end
local byPlayer = 0
local killerName
if killer ~= nil then
if killer:isPlayer() then
byPlayer = 1
else
local master = killer:getMaster()
if master and master ~= killer and master:isPlayer() then
killer = master
byPlayer = 1
end
end
killerName = killer:isMonster() and killer:getType():getNameDescription() or killer:getName()
else
killerName = 'field item'
end
local byPlayerMostDamage = 0
local mostDamageKillerName
if mostDamageKiller ~= nil then
if mostDamageKiller:isPlayer() then
byPlayerMostDamage = 1
else
local master = mostDamageKiller:getMaster()
if master and master ~= mostDamageKiller and master:isPlayer() then
mostDamageKiller = master
byPlayerMostDamage = 1
end
end
mostDamageName = mostDamageKiller:isMonster() and mostDamageKiller:getType():getNameDescription() or mostDamageKiller:getName()
else
mostDamageName = 'field item'
end
local playerGuid = player:getGuid()
db.query('INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`) VALUES (' .. playerGuid .. ', ' .. os.time() .. ', ' .. player:getLevel() .. ', ' .. db.escapeString(killerName) .. ', ' .. byPlayer .. ', ' .. db.escapeString(mostDamageName) .. ', ' .. byPlayerMostDamage .. ', ' .. (unjustified and 1 or 0) .. ', ' .. (mostDamageUnjustified and 1 or 0) .. ')')
local resultId = db.storeQuery('SELECT `player_id` FROM `player_deaths` WHERE `player_id` = ' .. playerGuid)
local deathRecords = 0
local tmpResultId = resultId
while tmpResultId ~= false do
tmpResultId = result.next(resultId)
deathRecords = deathRecords + 1
end
if resultId ~= false then
result.free(resultId)
end
if byPlayer == 1 then
local targetGuild = player:getGuild()
targetGuild = targetGuild and targetGuild:getId() or 0
if targetGuild ~= 0 then
local killerGuild = killer:getGuild()
killerGuild = killerGuild and killerGuild:getId() or 0
if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(playerId, killer.uid) then
local warId = false
resultId = db.storeQuery('SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = ' .. killerGuild .. ' AND `guild2` = ' .. targetGuild .. ') OR (`guild1` = ' .. targetGuild .. ' AND `guild2` = ' .. killerGuild .. '))')
if resultId ~= false then
warId = result.getNumber(resultId, 'id')
result.free(resultId)
end
if warId ~= false then
db.asyncQuery('INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES (' .. db.escapeString(killerName) .. ', ' .. db.escapeString(player:getName()) .. ', ' .. killerGuild .. ', ' .. targetGuild .. ', ' .. os.time() .. ', ' .. warId .. ')')
end
end
end
end
end
-
-
Estatísticas dos Fóruns
96849
Tópicos519614
Posts
Posts Recomendados
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.