Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- CONFIG
- states - List of game states.
- name - The name of the state.
- length - How long does this state last? (in seconds)
- boxStart - Start corner of the box for money
- boxEnd - End corner of the box for money
- money - How much money we should give to players in the box
- allowed - Which **JOB NAMES** are allowed to get money from this?
- moneyDelay - How long in seconds we should wait between giving money to players
- moneyDeliverMessage - Message shown to the person when they get money, %s is the money
- distFromCorner - How much distance must there be from the corner of the screen?
- padding - How much space is there inside of the actual box?
- cornerRounding - Round the corners, and by how much (set to 0 for no rounded corners)
- bgCol - Color of the background (r,g,b,a)
- txtCol - Color of the text (r,g,b,a)
- font - Name of the font (in your font viewer)
- fontSize - Size of the font
- alignment - Box position: "top left", "top right", "bottom left", "bottom right"
- timeLeft - Should we show how much time is left before state change?
- */
- local states = {
- {
- name = "Apell",
- length = 60,
- boxStart = Vector(34.311485, -314.349182, 67.269135),
- boxEnd = Vector(-814.582947, 492.064850, 677.402222),
- money = 25
- allowed = {
- ["Insasse"] = true,
- ["El Chapo"] = true
- }
- },
- {
- name = "Frühstück",
- length = 60,
- boxStart = Vector(591.485718, -312.545197, 64.817719),
- boxEnd = Vector(51.453388, 408.247406, 238.359039),
- money = 5
- allowed = {
- ["Insasse"] = true,
- ["El Chapo"] = true
- }
- },
- {
- name = "Freizeit",
- length = 5*60
- allowed = {
- ["Insasse"] = true,
- ["El Chapo"] = true
- }
- },
- {
- name = "Mittagessen",
- length = 60,
- boxStart = Vector(591.485718, -312.545197, 64.817719),
- boxEnd = Vector(51.453388, 408.247406, 238.359039),
- money = 5
- allowed = {
- ["Insasse"] = true,
- ["El Chapo"] = true
- }
- },
- {
- name = "Apell",
- length = 60,
- boxStart = Vector(34.311485, -314.349182, 67.269135),
- boxEnd = Vector(-814.582947, 492.064850, 677.402222),
- money = 25
- allowed = {
- ["Insasse"] = true,
- ["El Chapo"] = true
- }
- },
- {
- name = "Sport",
- length = 60,
- boxStart = Vector(-3067.285645, 1464.248535, 52.639744),
- boxEnd = Vector(-486.948975, 2608.701660, 320.717529),
- money = 5
- allowed = {
- ["Insasse"] = true,
- ["El Chapo"] = true
- }
- },
- {
- name = "Duschzeit",
- length = 60,
- boxStart = Vector(993.137329, 1008.306519, 56.342701),
- boxEnd = Vector(2253.369141, 116.556160, 263.199951),
- money = 5
- allowed = {
- ["Insasse"] = true,
- ["El Chapo"] = true
- }
- },
- {
- name = "Freizeit",
- length = 5*60
- allowed = {
- ["Insasse"] = true,
- ["El Chapo"] = true
- }
- },
- {
- name = "Abendessen",
- length = 60,
- boxStart = Vector(591.485718, -312.545197, 64.817719),
- boxEnd = Vector(51.453388, 408.247406, 238.359039),
- money = 5
- allowed = {
- ["Insasse"] = true,
- ["El Chapo"] = true
- }
- },
- {
- name = "Freizeit",
- length = 2*60
- allowed = {
- ["Insasse"] = true,
- ["El Chapo"] = true
- }
- },
- {
- name = "Nachtruhe",
- length = 30,
- boxStart = Vector(-1764.056641, 916.408691, 54.972107),
- boxEnd = Vector(-831.744080, 1188.248901, 296.873383),
- money = 160
- allowed = {
- ["Insasse"] = true,
- ["El Chapo"] = true
- }
- }
- }
- local moneyDelay = 5
- local moneyDeliverMessage = "Du hast %s erhalten, da du Anwesend bist."
- local distFromCorner = 4
- local padding = 4
- local cornerRounding = 0
- local bgCol = Color(0, 0, 0, 200)
- local txtCol = Color(255, 255, 255, 255)
- local font = "Open Sans"
- local fontSize = 6
- local timeLeft = true
- local alignment = "top right"
- /*
- CONFIG END
- */
- if(SERVER) then
- local state = 1
- local function incrementState()
- state = (states[state + 1] && state || 0) + 1
- SetGlobalString("GameState", states[state].name)
- hook.Run("GameStateChange", state, states[state])
- end
- SetGlobalInt("NextStateChange", CurTime() + states[state].length)
- hook.Add("Think", "ProcessGameState", function()
- if(CurTime() > GetGlobalInt("NextStateChange")) then
- incrementState()
- SetGlobalInt("NextStateChange", CurTime() + states[state].length)
- else return end
- end)
- timer.Create("GameStateMoney", moneyDelay, 0, function()
- local st = states[state]
- if(!st.boxStart || !st.boxEnd || !st.money) then return end
- local entities = ents.FindInBox(st.boxStart, st.boxEnd)
- for _, ent in pairs(entities) do
- if(!IsValid(ent) || !ent:IsPlayer()) then continue end
- if(st.allowed && !st.allowed[team.GetName(ent:Team())]) then continue end
- ent:addMoney(st.money)
- DarkRP.notify(ent, NOTIFY_GENERIC, 3, string.format(moneyDeliverMessage, DarkRP.formatMoney(st.money)))
- end
- end)
- else
- surface.CreateFont("GameState", {font = font, size = ScreenScale(fontSize)})
- local alignments = {
- ["top left"] = {
- x = 0,
- y = 0,
- },
- ["top right"] = {
- x = ScrW(),
- y = 0,
- right = true
- },
- ["bottom left"] = {
- x = 0,
- y = ScrH(),
- bottom = true
- },
- ["bottom right"] = {
- x = ScrW(),
- y = ScrH(),
- right = true,
- bottom = true
- }
- }
- local rnd = cornerRounding * 2
- local align = alignments[alignment]
- local cd = ScreenScale(distFromCorner)
- local pad = ScreenScale(padding)
- hook.Add("HUDPaint", "DrawGameState", function()
- local time = GetGlobalInt("NextStateChange") - CurTime()
- time = math.Round(time)
- time = math.Clamp(time, 0, math.huge)
- time = timeLeft && " - "..time.."s" || ""
- local state = GetGlobalString("GameState")..time
- surface.SetFont("GameState")
- local w, h = surface.GetTextSize(state)
- w, h = w + pad, h + pad
- x, y = align.x-(align.right && w || 0)-(align.right && cd || -cd), align.y-(align.bottom && h || 0)-(align.bottom && cd || -cd)
- if(rnd < 0) then
- draw.RoundedBox(rnd, x, y, w, h, bgCol)
- else
- surface.SetDrawColor(bgCol)
- surface.DrawRect(x, y, w, h)
- end
- draw.SimpleText(state, "GameState", x+w/2, y+h/2, txtCol, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement