É só usar a função getPlayerGuildName(cid) e concatenar ela na string ...
Exemplo: "Minha guild é " .. getPlayerGuildName(cid)
É só usar a função getPlayerGuildName(cid) e concatenar ela na string ...
Exemplo: "Minha guild é " .. getPlayerGuildName(cid)
É só usar a função getPlayerGuildName(cid) e concatenar ela na string ...Exemplo: "Minha guild é " .. getPlayerGuildName(cid)
Da isso
[17/12/2009 15:38:06] data/creaturescripts/scripts/killer.lua:23: attempt to concatenate a boolean value [17/12/2009 15:38:06] stack traceback: [17/12/2009 15:38:06] data/creaturescripts/scripts/killer.lua:23: in function <data/creaturescripts/scripts/killer.lua:9>
E na linha eu coloquei
doBroadcastMessage(""..getCreatureName(cid).." has been killed by "..hitKillerName.." da guild " .. getPlayerGuildName(cid) .. ".")
Olá,
Tente desta forma:
local config = {deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
sqlType = getConfigInfo('sqlType'),
maxDeathRecords = getConfigInfo('maxDeathRecords')
}
config.sqlType = config.sqlType == "sqlite" and DATABASE_ENGINE_SQLITE or DATABASE_ENGINE_MYSQL
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
if(config.deathListEnabled ~= TRUE) then
return
end
local hitKillerName = "field item"
local damageKillerName = ""
if(lastHitKiller ~= FALSE) then
if(isPlayer(lastHitKiller) == TRUE) then
hitKillerName = getCreatureName(lastHitKiller)
else
hitKillerName = getCreatureName(lastHitKiller)
end
local playerguild = getPlayerGuildName(lastHitKiller)
doBroadcastMessage(""..getPlayerName(cid).." has been killed by "..hitKillerName.." da guild "..playerguild..".")
if(mostDamageKiller ~= FALSE and mostDamageKiller ~= lastHitKiller and getCreatureName(mostDamageKiller) ~= getCreatureName(lastHitKiller)) then
if(isPlayer(mostDamageKiller) == TRUE) then
damageKillerName = getPlayerGUID(mostDamageKiller)
else
damageKillerName = getCreatureName(mostDamageKiller)
end
end
end
db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");")
local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
if(rows:getID() ~= -1) then
local amount = rows:getRows(true) - config.maxDeathRecords
if(amount > 0) then
if(config.sqlType == DATABASE_ENGINE_SQLITE) then
for i = 1, amount do
db.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
end
else
db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")
end
end
end
end
Caso não dê certo, me retorne o erro que eu arrumo pois não testei.. Mas creio que vai dar certo sim.
A dificuldade que você vai encontrar é quando o jogador for morto com um monstro ou um "field item".
Pois nao mostrará a guild.
Para que seja feito o broadcast só em caso de mortes por jogadores tente adaptar isto:
if isPlayer(lastHitKiller) then
Ficando assim:
local config = {deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
sqlType = getConfigInfo('sqlType'),
maxDeathRecords = getConfigInfo('maxDeathRecords')
}
config.sqlType = config.sqlType == "sqlite" and DATABASE_ENGINE_SQLITE or DATABASE_ENGINE_MYSQL
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
if(config.deathListEnabled ~= TRUE) then
return
end
local hitKillerName = "field item"
local damageKillerName = ""
if(lastHitKiller ~= FALSE) then
if(isPlayer(lastHitKiller) == TRUE) then
hitKillerName = getCreatureName(lastHitKiller)
else
hitKillerName = getCreatureName(lastHitKiller)
end
if(isPlayer(lastHitKiller) == TRUE) then
local playerguild = getPlayerGuildName(lastHitKiller)
doBroadcastMessage(""..getPlayerName(cid).." has been killed by "..hitKillerName.." da guild "..playerguild..".")
else
doBroadcastMessage(""..getPlayerName(cid).." has been killed by "..hitKillerName..".")
if(mostDamageKiller ~= FALSE and mostDamageKiller ~= lastHitKiller and getCreatureName(mostDamageKiller) ~= getCreatureName(lastHitKiller)) then
if(isPlayer(mostDamageKiller) == TRUE) then
damageKillerName = getPlayerGUID(mostDamageKiller)
else
damageKillerName = getCreatureName(mostDamageKiller)
end
end
end
db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");")
local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
if(rows:getID() ~= -1) then
local amount = rows:getRows(true) - config.maxDeathRecords
if(amount > 0) then
if(config.sqlType == DATABASE_ENGINE_SQLITE) then
for i = 1, amount do
db.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
end
else
db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")
end
end
end
end
Espero ter ajudado !
Editado Dezembro 17 por ThaLeeeS
info
Grupo: Barão
Registrado: 01/07/09
Posts: 216
Reputação: +4

doBroadcastMessage(getCreatureName(cid).." has been killed by "..hitKillerName.." da guild "..getPlayerGuildName(cid))
fixed
iRockStar noseu exemplo vai mostrar a guild do player que foi morto..
O nosso amigo quer que mostre a guild do matador.
Por isso deixei ali o script completo e caso ele preferir com reconhecimento caso for um jogador que tenha matado o player. Pois monstros e field items não tem guild (obviamente).
Abraços.
Cara, é só trocar o cid no que eu mandei por hitKillerName ( algo assim ), mas lembrando que se o player nao tiver guild, vai dar esse erro ai que voce citou, porque ele vai retornar false ( booleano ).
Então teria que fazer uma checagem antes, exemplo: if getPlayerGuild(lastHitKiller) etc ...
Editado Dezembro 18 por Notorious
Cara, é só trocar o cid no que eu mandei por hitKillerName ( algo assim ), mas lembrando que se o player nao tiver guild, vai dar esse erro ai que voce citou, porque ele vai retornar false ( booleano ).Então teria que fazer uma checagem antes, exemplo: if getPlayerGuild(lastHitKiller) etc ...
Mas antes de chegar no monster, tem um TILE que só passa quem tem guild
SOBRE O TÓPICO:
Bom gente, eu coloquei de outro jeito e funcionou!
Mudei o:
hitKillerName = getPlayerGuildName(lastHitKiller) else hitKillerName = getPlayerGuildName(lastHitKiller) end
E coloquei:
doBroadcastMessage("A guild "..hitKillerName.." Venceu!.")
Obrigado a todos !
Tópico Reportado
Editado Dezembro 18 por EncoreNumb
info
Grupo: Herói
Registrado: 17/02/08
Posts: 2.5k
Reputação: +193

Obrigado à todos que puderem ajudar nosso amigo.
Tópico fechado.
info
Grupo: Campones
Registrado: 03/11/09
Posts: 0
Reputação: 0
Olá Xtibianos, eu peguei um script daqui mesmo do Xtibia sobre "Anuncidor de quem mata e quem morre"
Creaturescript:
local config = { deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')), sqlType = getConfigInfo('sqlType'), maxDeathRecords = getConfigInfo('maxDeathRecords') } config.sqlType = config.sqlType == "sqlite" and DATABASE_ENGINE_SQLITE or DATABASE_ENGINE_MYSQL function onDeath(cid, corpse, lastHitKiller, mostDamageKiller) if(config.deathListEnabled ~= TRUE) then return end local hitKillerName = "field item" local damageKillerName = "" if(lastHitKiller ~= FALSE) then if(isPlayer(lastHitKiller) == TRUE) then hitKillerName = getCreatureName(lastHitKiller) else hitKillerName = getCreatureName(lastHitKiller) end doBroadcastMessage(""..getPlayerName(cid).." has been killed by "..hitKillerName..".") if(mostDamageKiller ~= FALSE and mostDamageKiller ~= lastHitKiller and getCreatureName(mostDamageKiller) ~= getCreatureName(lastHitKiller)) then if(isPlayer(mostDamageKiller) == TRUE) then damageKillerName = getPlayerGUID(mostDamageKiller) else damageKillerName = getCreatureName(mostDamageKiller) end end end db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");") local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";") if(rows:getID() ~= -1) then local amount = rows:getRows(true) - config.maxDeathRecords if(amount > 0) then if(config.sqlType == DATABASE_ENGINE_SQLITE) then for i = 1, amount do db.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);") end else db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";") end end end endGostaria de saber como posso por o nome da guild do player nesta linha:
doBroadcastMessage(""..getPlayerName(cid).." has been killed by "..hitKillerName..".")