Alteration to salary#42
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.
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 <[email protected]>
TovarischPootis
left a comment
There was a problem hiding this comment.
An empty table would still return true in an if check, which may cause errors
Co-authored-by: TovarischPootis <[email protected]>
Co-authored-by: TovarischPootis <[email protected]>
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.
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.
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 <[email protected]>
Co-authored-by: TovarischPootis <[email protected]>
Allows classes to have salaries, as per suggestion by Misfit. Feel this can be useful for different ranks/divisions being paid differently.