-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Credits/Shop: Add hooks for credit related events. #1451
Conversation
- TTT2ReceivedTeamAwardCredits - TTT2ReceivedKillCredits - TTT2OnGiveFoundCredits - TTT2TransferedCredits
Fixed some errors.
Conflicts: gamemodes/terrortown/gamemode/server/sv_corpse.lua gamemodes/terrortown/gamemode/server/sv_player_ext.lua gamemodes/terrortown/gamemode/server/sv_shop.lua lua/ttt2/libraries/credits.lua
…-merge # Conflicts: # gamemodes/terrortown/gamemode/server/sv_corpse.lua # gamemodes/terrortown/gamemode/server/sv_player_ext.lua # gamemodes/terrortown/gamemode/server/sv_shop.lua # gamemodes/terrortown/gamemode/shared/sh_shop.lua # lua/ttt2/libraries/credits.lua
Sorry, one more commit. I couldn't understand what the remaining error was in CI so I had to go get stylua. |
Yeah, it can be a little confusing what it wants, especially if TTT2 isn't the root of your project (for vscode at least) |
I will review this later, but just to ask, are you aware of TTT2's events? I think you should be able to get all of this data already from the events at the round end |
IMHO these names are inconsistent. It should probably be more like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the suggested name change I'd also like to suggest adding more functionality to those hooks. I'm thinking of "return false to cancel the action".
So this
hook.Add("TTT2OnGiveFoundCredits", "myhook", function(ply, rag, credits)
return false
end
would cancel that action.
But this would probably break your statistics addon, wouldn't it?
In my case I did not want to wait until round end, I wanted to update the database as soon as something had occurred.
I have changed the names. |
…he call location moved to bodysearch)
…-merge # Conflicts: # CHANGELOG.md
Then this is fine with me now, as soon as you undraft it, you can rerequest a review from me. Thanks! |
…-merge # Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This somehow got lost as you never updated the review state and I never checked the code state. LGTM, thanks for contributing!
This change adds some hooks for credit related events that are used by my addon ttt2stats. This addon records stats from my server's games to a database, which is used to populate a dashboard. I've been running these changes for a while and its about time I open a PR.
Added:
GM:TTT2OnGiveFoundCredits()
, which is triggered serverside when a player has been given credits for searching a corpse.GM:TTT2ReceivedKillCredits()
, which is called when a player recieves credits for a kill.GM:TTT2ReceivedTeamAwardCredits()
, which is called when a player recieves credits as a team award.GM:TTT2TransferedCredits()
, which is called when a player has successfully transfered a credit to another player.Changed:
TTT2OrderedEquipment
hook.LMK if there are any suggestions. The thing I'm iffiest on is the TryRerollShop change, maybe a new hook would be better. Thanks!