mjsm4ever 0 Postado Dezembro 16, 2009 Share Postado Dezembro 16, 2009 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 end Gostaria de saber como posso por o nome da guild do player nesta linha: doBroadcastMessage(""..getPlayerName(cid).." has been killed by "..hitKillerName..".") Link para o comentário https://xtibia.com/forum/topic/125311-complemento-de-script-broadcast/ Compartilhar em outros sites More sharing options...
canovas 3 Postado Dezembro 17, 2009 Share Postado Dezembro 17, 2009 É só usar a função getPlayerGuildName(cid) e concatenar ela na string ... Exemplo: "Minha guild é " .. getPlayerGuildName(cid) Link para o comentário https://xtibia.com/forum/topic/125311-complemento-de-script-broadcast/#findComment-829208 Compartilhar em outros sites More sharing options...
mjsm4ever 0 Postado Dezembro 17, 2009 Autor Share Postado Dezembro 17, 2009 É 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) .. ".") Link para o comentário https://xtibia.com/forum/topic/125311-complemento-de-script-broadcast/#findComment-829441 Compartilhar em outros sites More sharing options...
thaleees 2 Postado Dezembro 17, 2009 Share Postado Dezembro 17, 2009 (editado) 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, 2009 por ThaLeeeS Link para o comentário https://xtibia.com/forum/topic/125311-complemento-de-script-broadcast/#findComment-829445 Compartilhar em outros sites More sharing options...
rockstar96 4 Postado Dezembro 17, 2009 Share Postado Dezembro 17, 2009 doBroadcastMessage(getCreatureName(cid).." has been killed by "..hitKillerName.." da guild "..getPlayerGuildName(cid)) fixed Link para o comentário https://xtibia.com/forum/topic/125311-complemento-de-script-broadcast/#findComment-829446 Compartilhar em outros sites More sharing options...
thaleees 2 Postado Dezembro 17, 2009 Share Postado Dezembro 17, 2009 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. Link para o comentário https://xtibia.com/forum/topic/125311-complemento-de-script-broadcast/#findComment-829450 Compartilhar em outros sites More sharing options...
canovas 3 Postado Dezembro 18, 2009 Share Postado Dezembro 18, 2009 (editado) 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, 2009 por Notorious Link para o comentário https://xtibia.com/forum/topic/125311-complemento-de-script-broadcast/#findComment-829665 Compartilhar em outros sites More sharing options...
mjsm4ever 0 Postado Dezembro 18, 2009 Autor Share Postado Dezembro 18, 2009 (editado) 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, 2009 por EncoreNumb Link para o comentário https://xtibia.com/forum/topic/125311-complemento-de-script-broadcast/#findComment-829732 Compartilhar em outros sites More sharing options...
Henrique Moura 193 Postado Dezembro 18, 2009 Share Postado Dezembro 18, 2009 Obrigado à todos que puderem ajudar nosso amigo. Tópico fechado. Link para o comentário https://xtibia.com/forum/topic/125311-complemento-de-script-broadcast/#findComment-829739 Compartilhar em outros sites More sharing options...
Posts Recomendados