ModWorkshop
[Custom Achievement] Functions for counting kills - Printable Version

+- ModWorkshop (https://modworkshop.net)
+-- Forum: Discussion (https://modworkshop.net/forumdisplay.php?fid=1)
+--- Forum: Help (https://modworkshop.net/forumdisplay.php?fid=9)
+--- Thread: [Custom Achievement] Functions for counting kills (/showthread.php?tid=7947)



[Custom Achievement] Functions for counting kills - SCP-5666-Akira.exe - 07-10-2019

Greetings,
I'm asking here because I didn't found a solution for this:
Since Beardlib got the Custom Achievement API, I wanted to do Weapons kills but the problem is I don't know what hooks, function and source hooks I have to use to count the kills.
If anyone have a tutoriel, a guide or know how to do, i'll be very grateful.


RE: [Custom Achievement] Functions for counting kills - SCP-5666-Akira.exe - 12-07-2019

Uping the subject since I made my own research and tried something.

I found the Lua for those achievement.
"statisticsmanager.lua"

And I think, I need to use these functions:
"StatisticsManager:killed", "StatisticsManager:_add_to_killed_by_weapon" and "StatisticsManager:_get_name_id_and_throwable_id"

In this case, I don't know where to place them in the "statisticsmanager.lua" in my custom achievements' hook.
Can someone help for this ?
Thank you.


RE: [Custom Achievement] Functions for counting kills - SCP-5666-Akira.exe - 04-11-2020

Reuping the topic after a while.

Got my actuel function and it's working on a single weapon. but for multiples weapons, 1 kill on a weapon will count for all.

Hooks:PostHook( StatisticsManager, "killed", "firearmskills_achievement_package", function(self)
local package = CustomAchievementPackage:new("firearmskills_achievement_package")

-- Pistols + Akimbos
if self._global.killed_by_weapon["lemming"] then -- Fiveseven
package:Achievement("s_ach_lemming_bronzekill"):IncreaseAmount(1)
package:Achievement("s_ach_lemming_silverkill"):IncreaseAmount(1)
package:Achievement("s_ach_lemming_goldkill"):IncreaseAmount(1)
package:Achievement("s_ach_lemming_platinumkill"):IncreaseAmount(1)
end

-- Submachine Guns + Akimbos
if self._global.killed_by_weapon["tec9"] or self._global.killed_by_weapon["x_tec9"] then -- Blaster 9mm
package:Achievement("s_ach_tec9_bronzekill"):IncreaseAmount(1)
package:Achievement("s_ach_tec9_silverkill"):IncreaseAmount(1)
package:Achievement("s_ach_tec9_goldkill"):IncreaseAmount(1)
package:Achievement("s_ach_tec9_platinumkill"):IncreaseAmount(1)
end

-- Rifles
if self._global.killed_by_weapon["famas"] then -- Clarion Rifle
package:Achievement("s_ach_famas_bronzekill"):IncreaseAmount(1)
package:Achievement("s_ach_famas_silverkill"):IncreaseAmount(1)
package:Achievement("s_ach_famas_goldkill"):IncreaseAmount(1)
package:Achievement("s_ach_famas_platinumkill"):IncreaseAmount(1)
end
end)


I really don't want to go for the alternative one file for each gun solutions, It's really bad x')
Any ideas how to fix it ? I'll really appreciate that.