Preciso de um script para meu ot 8.60 que, quando um player morre aparece uma mensagem encima do corpo.
Testei o script desse tópico, porém não deu certo
http://www.xtibia.com/forum/topic/153908-mensagem-ao-morrer-owned/
Preciso de um script para meu ot 8.60 que, quando um player morre aparece uma mensagem encima do corpo.
Testei o script desse tópico, porém não deu certo
http://www.xtibia.com/forum/topic/153908-mensagem-ao-morrer-owned/
Vá em Pasta do seu OT/data/creaturescripts/scripts/playerdeath.lua, apague o quê está lá dentro e coloque isso:
dofile("./config.lua")
function onDeath(cid, corpse, killer)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
if deathListEnabled == "yes" then
doSendAnimatedText(getPlayerPosition(cid),"OwNeD",35)
if sqlType == "mysql" then
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
else -- sqlite
env = assert(luasql.sqlite3())
con = assert(env:connect(sqliteDatabase))
end
local byPlayer = FALSE
if killer == FALSE then
killerName = "field item"
else
if isPlayer(killer) == TRUE then
byPlayer = TRUE
end
killerName = getCreatureName(killer)
end
assert(con:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. escapeString(killerName) .. "', " .. byPlayer .. ");"))
local cursor = assert(con:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";"))
local deathRecords = numRows(cursor)
if sqlType == "mysql" then
while deathRecords > maxDeathRecords do
delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1;"))
deathRecords = deathRecords - 1
end
else
while deathRecords > maxDeathRecords do
delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);"))
deathRecords = deathRecords - 1
end
end
con:close()
env:close()
end
end
Se você não quiser trocar seu playerdeath.lua por esse que eu passei, olhe o tópico oficial do script -> http://www.xtibia.com/forum/topic/134949-creature-owned/
No meu creaturescript.xml não tem a tag desse playerdeath.lua, porém o playerdeath.lua tinha. Que tag eu coloco ? E tenque colocar algo no login.lua ?
Tenta assim, data/creaturescripts/scripts, crie um arquivo chamado prepareowned.lua e adicione isso dentro:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
if isPlayer(cid) then
doSendMagicEffect(getCreaturePosition(cid),"OWNED!",math.random(1,255))
end
return true
end
Em data/creaturescipts, com o bloco de notas, abra o arquivo creaturescripts.xml e adicione essa tag:
<event type="preparedeath" name="OwnedDeath" event="script" value="prepareowned.lua"/>
Em login.lua, antes da última linha de todas ponha isso:
registerCreatureEvent(cid, "OwnedDeath")
Vá em Pasta do seu OT/data/creaturescripts/scripts/login.lua e adicione:
registerCreatureEvent(cid, "PlayerDeath")
Agora em Pasta do seu OT/data/creaturescripts/creaturescripts.xml, adicione:
<event type="death" name="PlayerDeath" script="playerdeath.lua"/>
Não foi bem oq eu queria, mas esse serve :] +REP
Tópico movido para a seção de dúvidas e pedidos resolvidos.