-
Notifications
You must be signed in to change notification settings - Fork 30
Alteration to salary #42
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
Conversation
Allows classes to have salaries, as per suggestion by Misfit. Feel this can be useful for different ranks/divisions being paid differently.
gamemode/core/hooks/sv_hooks.lua
Outdated
| local faction = nut.faction.indices[character:getFaction()] | ||
| if (not faction or not isnumber(faction.pay) or faction.pay <= 0) then | ||
| local class = nut.class.indices[character:getClass()] | ||
| if ((not faction or not isnumber(faction.pay) or faction.pay <= 0) and (not class or not isnumber(class.pay) or class.pay <= 0)) then |
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.
Wouldn't this return if the character is not part of a class or the class in question doesn't have a custom pay?
By default, characters are not assigned to a class. That will pass in the "not class" and simply return.
If the character is part of a class, but its pay is not defined (for instance the class is supposed to use the default faction pay), it will pass the "not isnumber(class.pay) or class.pay <= 0)" and also return
Fixed class salary commit
Simplifies the return if there's no money to give.
Works better in the long run. Co-authored-by: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com>
TovarischPootis
left a comment
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.
An empty table would still return true in an if check, which may cause errors
Co-authored-by: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com>
Co-authored-by: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com>
A very simple hook that hides certain factions in the scoreboard if conditions are met. Good for hiding admin factions or event factions.
Figured out how to optimize the hiding code.
Another small fix to the code, prevents faction appearing if amount is 0
TovarischPootis
left a comment
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 pull became 2 things
1st: Made class specific pay possible, all issues fixed
2nd: Adds a hook that allows factions to not be visible on the scoreboard, looks simple enough
|
|
||
| if (amount != 0) then | ||
| v:SetVisible(hook.Run("HideFactionInScoreboard",faction) != false or LocalPlayer():IsAdmin()) | ||
| v:SetVisible(hook.Run("HideFactionInScoreboard", faction) or LocalPlayer():IsAdmin()) |
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.
hook.Run("HideFactionInScoreboard", faction) by itself would return nil, which is not what we want as that would cause nothing to draw on the scoreboard unless the player is an admin, we want to specifically check if false was returned or not.
Co-authored-by: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com>
Co-authored-by: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com>
Allows classes to have salaries, as per suggestion by Misfit. Feel this can be useful for different ranks/divisions being paid differently.