Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local job, job_title
- if not parameters then
- local jobs = {}
- for i, v in next, data.jobs do
- if v.available and data.money[v.boss] > 9 and data.money[v.boss] >= v.money_range[2] then
- jobs[#jobs + 1] = {i, v}
- end
- end
- job_title, job = table.unpack(jobs[math.random(#jobs)])
- else
- if parameters:match("(%S+) (.+)") then
- local search_type, search = parameters:match("(%S+) (.+)")
- if search_type:lower() == "at" then
- job = data.jobs[search:lower()]
- if (not job) or (not job.available) then
- print("Job not found or not available: `" .. search:lower() .. "`")
- return
- end
- job_title = search:lower()
- elseif search_type:lower() == "for" then
- local match = search:match("<@!?(%d+)>")
- if match then
- work_on = match
- else
- work_on = discord.getMemberId(search)
- end
- if (not work_on) or not discord.isMember(work_on) then
- print("The given user was not found in the server.")
- return
- end
- local jobs = {}
- for i, v in next, data.jobs do
- if v.boss == work_on and v.available and data.money[v.boss] > 10 and data.money[v.boss] >= v.money_range[2] then
- jobs[#jobs + 1] = {i, v}
- end
- end
- if #jobs == 0 then
- print("<@" .. work_on .. "> is currently not hiring anyone or can't hire anyone.")
- return
- end
- job_title, job = table.unpack(jobs[math.random(#jobs)])
- else
- print("Invalid syntax. Valid ones:")
- print("!work at job name")
- print("!work for Bolo")
- print("!work for Lautenschlager#2555")
- print("!work for <@285878295759814656>")
- print("!work")
- return
- end
- else
- print("Invalid syntax. Valid ones:")
- print("!work at job name")
- print("!work for Bolo")
- print("!work for Lautenschlager#2555")
- print("!work for <@285878295759814656>")
- print("!work")
- return
- end
- end
- if data.money[job.boss] < 10 or data.money[job.boss] < job.money_range[2] then
- print("The job boss can't pay you. Search another job.")
- return
- end
- if not cooldown(1) then return end
- print("Job: `" .. job_title .. "`")
- print("Boss: <@" .. job.boss .. ">")
- print("")
- local state = math.random(3)
- if state == 1 then -- hired
- local earned = math.random(job.money_range[1], job.money_range[2])
- if not data.money[discord.authorId] then
- data.money[discord.authorId] = 500
- end
- data.money[discord.authorId] = data.money[discord.authorId] + 70 * earned / 100
- data.money[job.boss] = data.money[job.boss] + 20 * earned / 100
- data.money["436703225140346881"] = data.money["436703225140346881"] + 5 * earned / 100
- data.money["212634414021214209"] = data.money["212634414021214209"] + 5 * earned / 100
- print("You've been hired!")
- print(job.hired_phrases[math.random(#job.hired_phrases)])
- print("Your wage is $" .. earned)
- print("You've earned $" .. 70 * earned / 100 .. ". (70%)")
- print("Your boss earned $" .. 20 * earned / 100 .. ". (20%)")
- print("You give $" .. 10 * earned / 100 .. " as tax. (10%)")
- elseif state == 2 then -- fired
- print("You've been fired!")
- print(job.fired_phrases[math.random(#job.fired_phrases)])
- print("But see the good point: you stole $10 from your boss!")
- if not data.money[discord.authorId] then
- data.money[discord.authorId] = 500
- end
- data.money[discord.authorId] = data.money[discord.authorId] + 10
- data.money[job.boss] = data.money[job.boss] - 10
- else -- rejected
- print("You've been rejected!")
- print(job.rejected_phrases[math.random(#job.rejected_phrases)])
- end
Add Comment
Please, Sign In to add comment