Skip to content

Conversation

@raecyst
Copy link
Contributor

@raecyst raecyst commented Mar 29, 2021

Allows classes to have salaries, as per suggestion by Misfit. Feel this can be useful for different ranks/divisions being paid differently.

Allows classes to have salaries, as per suggestion by Misfit. Feel this can be useful for different ranks/divisions being paid differently.
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
Copy link
Contributor

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

raecyst added 2 commits March 29, 2021 13:20
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>
Copy link
Contributor

@TovarischPootis TovarischPootis left a 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

raecyst and others added 6 commits March 29, 2021 17:20
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
Copy link
Contributor

@TovarischPootis TovarischPootis left a 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())
Copy link
Contributor

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>
@TovarischPootis TovarischPootis merged commit 27da3fc into NutScript:1.2-wip Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants