Yie 1 Report post Posted March 6, 2022 How can i create a function when the boss died that announces who killed it. Thanks Quote Share this post Link to post Share on other sites
cpworkerz 24 Report post Posted March 6, 2022 3 hours ago, Yie said: How can i create a function when the boss died that announces who killed it. Thanks resource\script\calculate\exp_and_level.lua search for: function GetExp_New(dead , atk ) Under this: function GetExp_New(dead , atk ) if ValidCha(atk) == 0 then LG ( "exp_atker=NIL" , "function GetExp_New : atker = nil " ) return end local a = Check_Combat_Mod(dead , atk ) if a==1 then GetExp_PKM( dead , atk ) --[[player kill monster]]-- elseif a==2 then GetExp_MKP(dead , atk) --[[monster kill player]]-- elseif a==3 then GetExp_PKP(dead , atk) --[[player kill player]]-- elseif a==4 then GetExp_Noexp(dead , atk) --[[monster kill monster]]-- else end Add the following: local id = GetChaID(dead) -- Retrieve ID of killed monster local monstername = GetChaDefaultName(dead) -- Retrieve name of killed monster local cha_name = GetChaDefaultName ( atk ) -- Retrieve name of the player killed the monster if id ==973 then -- Check for monster ID ( characterinfo.txt ID ) GMNotice(string.format('<%s> has killed, <%s> !!', cha_name, monstername)); -- Announce a GMNotice -- ( Requires GameServer and GroupServer with enabled GMNotice function, otherwise use the normal Notice Function ) Notice("<".cha_name."> has killed, <".monstername."> !!") end Goodluck. Quote Share this post Link to post Share on other sites
Yie 1 Report post Posted March 6, 2022 33 minutes ago, cpworkerz said: resource\script\calculate\exp_and_level.lua search for: function GetExp_New(dead , atk ) Under this: function GetExp_New(dead , atk ) if ValidCha(atk) == 0 then LG ( "exp_atker=NIL" , "function GetExp_New : atker = nil " ) return end local a = Check_Combat_Mod(dead , atk ) if a==1 then GetExp_PKM( dead , atk ) --[[player kill monster]]-- elseif a==2 then GetExp_MKP(dead , atk) --[[monster kill player]]-- elseif a==3 then GetExp_PKP(dead , atk) --[[player kill player]]-- elseif a==4 then GetExp_Noexp(dead , atk) --[[monster kill monster]]-- else end Add the following: local id = GetChaID(dead) -- Retrieve ID of killed monster local monstername = GetChaDefaultName(dead) -- Retrieve name of killed monster local cha_name = GetChaDefaultName ( atk ) -- Retrieve name of the player killed the monster if id ==973 then -- Check for monster ID ( characterinfo.txt ID ) GMNotice(string.format('<%s> has killed, <%s> !!', cha_name, monstername)); -- Announce a GMNotice -- ( Requires GameServer and GroupServer with enabled GMNotice function, otherwise use the normal Notice Function ) Notice("<".cha_name."> has killed, <".monstername."> !!") end Goodluck. Thanks alot! 1 Quote Share this post Link to post Share on other sites
cpworkerz 24 Report post Posted March 6, 2022 1 minute ago, Yie said: Thanks alot! welcome to pkodev 1 Quote Share this post Link to post Share on other sites
V3ct0r 2,117 Report post Posted March 7, 2022 Hello @Yie and @cpworkerz, one more solution: Add this script to file functions.lua -- Player killed monster event GetExp_PKM__Original = GetExp_PKM GetExp_PKM = function(monster, role) -- Call original function GetExp_PKM() GetExp_PKM__Original(monster, role) -- Get ID of the killed monster local mob_id = GetChaID(monster) -- Check the monster ID if (mob_id == 789) then -- Black Dragon -- Show a message Notice( string.format("%s has killed %s!", GetChaDefaultName(role), GetChaDefaultName(monster)) ) end end 1 1 Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
Angelix 374 Report post Posted March 12, 2022 (edited) Adding onto what @V3ct0r said using hooks, this is a somewhat better version of his which allows more simplistic usage without adding more conditions within the function, just new variables. BossKillNotice = {} BossKillNotice[789] = '[&MONSTER&] was killed by [&PLAYER&]!' OriginalGetExp_PKM = GetExp_PKM GetExp_PKM = function(Monster, Player) OriginalGetExp_PKM(Monster, Player) -- Call original function GetExp_PKM() local MonsterID = GetChaID(Monster) -- Get ID of the killed monster. local MonsterName = GetChaDefaultName(Monster) -- Get monster name. local PlayerName = GetChaDefaultName(Player) -- Get player name. if not BossKillNotice[MonsterID] then return -- No point in continuing function if a notice is not declared for this ID. end local Message = BossKillNotice[MonsterID] Message = Message:gsub('&MONSTER&', MonsterName) -- Replace placeholder with actual monster name. Message = Message:gsub('&PLAYER&', PlayerName) -- Replace placeholder with actual player name. Notice(Message) end Essentially just add a new variable under "BossKillNotice" as the example shown. The "&MONSTER&" and "&PLAYER&" are placeholders, meaning you can move them aroiund for more creative notices at your liking. For example, this shows the monster was killed by the player: BossKillNotice[789] = '[&MONSTER&] was killed by [&PLAYER&]!' You can also do the player killed the monster: BossKillNotice[789] = '[&PLAYER&] killed [&MONSTER&]!' And the "[789]" correspond to the monster ID, so to add a new notice, just change the ID. Like this: BossKillNotice[989] = '[&MONSTER&] was killed by [&PLAYER&]!' This should be compatible with all lua versions I think. Edited March 12, 2022 by Angelix 1 Quote Share this post Link to post Share on other sites