Skip to content

Commit

Permalink
fix(server/player): convert grade to number (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
solareon authored Aug 18, 2024
1 parent c6f2b96 commit 81390de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ function CreatePlayer(playerData, Offline)
---@return ErrorResult? errorResult
function self.Functions.SetJob(jobName, grade)
jobName = jobName:lower()
grade = grade or 0
grade = tonumber(grade or 0)
local job = GetJob(jobName)
if not job then
lib.print.error(('cannot set job. Job %s does not exist'):format(jobName))
Expand Down Expand Up @@ -622,7 +622,7 @@ function CreatePlayer(playerData, Offline)
---@return ErrorResult? errorResult
function self.Functions.SetGang(gangName, grade)
gangName = gangName:lower()
grade = grade or 0
grade = tonumber(grade or 0)
local gang = GetGang(gangName)
if not gang then
lib.print.error(('cannot set gang. Gang %s does not exist'):format(gangName))
Expand Down

2 comments on commit 81390de

@BerkieBb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The or 0 should be outside of the tonumber statement as tonumber can return nil as well if someone sent the wrong thing

@BerkieBb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The or 0 should be outside of the tonumber statement as tonumber can return nil as well if someone sent the wrong thing

And you know that WILL happen

Please sign in to comment.