Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.02 KB | None | 0 0
  1. /*
  2. CONFIG
  3.  
  4. states - List of game states.
  5. name - The name of the state.
  6. length - How long does this state last? (in seconds)
  7. boxStart - Start corner of the box for money
  8. boxEnd - End corner of the box for money
  9. money - How much money we should give to players in the box
  10. allowed - Which **JOB NAMES** are allowed to get money from this?
  11.  
  12. moneyDelay - How long in seconds we should wait between giving money to players
  13. moneyDeliverMessage - Message shown to the person when they get money, %s is the money
  14.  
  15. distFromCorner - How much distance must there be from the corner of the screen?
  16. padding - How much space is there inside of the actual box?
  17. cornerRounding - Round the corners, and by how much (set to 0 for no rounded corners)
  18. bgCol - Color of the background (r,g,b,a)
  19. txtCol - Color of the text (r,g,b,a)
  20. font - Name of the font (in your font viewer)
  21. fontSize - Size of the font
  22. alignment - Box position: "top left", "top right", "bottom left", "bottom right"
  23. timeLeft - Should we show how much time is left before state change?
  24. */
  25. local states = {
  26. {
  27. name = "Apell",
  28. length = 60,
  29. boxStart = Vector(34.311485, -314.349182, 67.269135),
  30. boxEnd = Vector(-814.582947, 492.064850, 677.402222),
  31. money = 25
  32. allowed = {
  33. ["Insasse"] = true,
  34. ["El Chapo"] = true
  35. }
  36. },
  37. {
  38. name = "Frühstück",
  39. length = 60,
  40. boxStart = Vector(591.485718, -312.545197, 64.817719),
  41. boxEnd = Vector(51.453388, 408.247406, 238.359039),
  42. money = 5
  43. allowed = {
  44. ["Insasse"] = true,
  45. ["El Chapo"] = true
  46. }
  47. },
  48. {
  49. name = "Freizeit",
  50. length = 5*60
  51. allowed = {
  52. ["Insasse"] = true,
  53. ["El Chapo"] = true
  54. }
  55. },
  56. {
  57. name = "Mittagessen",
  58. length = 60,
  59. boxStart = Vector(591.485718, -312.545197, 64.817719),
  60. boxEnd = Vector(51.453388, 408.247406, 238.359039),
  61. money = 5
  62. allowed = {
  63. ["Insasse"] = true,
  64. ["El Chapo"] = true
  65. }
  66. },
  67. {
  68. name = "Apell",
  69. length = 60,
  70. boxStart = Vector(34.311485, -314.349182, 67.269135),
  71. boxEnd = Vector(-814.582947, 492.064850, 677.402222),
  72. money = 25
  73. allowed = {
  74. ["Insasse"] = true,
  75. ["El Chapo"] = true
  76. }
  77. },
  78. {
  79. name = "Sport",
  80. length = 60,
  81. boxStart = Vector(-3067.285645, 1464.248535, 52.639744),
  82. boxEnd = Vector(-486.948975, 2608.701660, 320.717529),
  83. money = 5
  84. allowed = {
  85. ["Insasse"] = true,
  86. ["El Chapo"] = true
  87. }
  88. },
  89. {
  90. name = "Duschzeit",
  91. length = 60,
  92. boxStart = Vector(993.137329, 1008.306519, 56.342701),
  93. boxEnd = Vector(2253.369141, 116.556160, 263.199951),
  94. money = 5
  95. allowed = {
  96. ["Insasse"] = true,
  97. ["El Chapo"] = true
  98. }
  99. },
  100. {
  101. name = "Freizeit",
  102. length = 5*60
  103. allowed = {
  104. ["Insasse"] = true,
  105. ["El Chapo"] = true
  106. }
  107. },
  108. {
  109. name = "Abendessen",
  110. length = 60,
  111. boxStart = Vector(591.485718, -312.545197, 64.817719),
  112. boxEnd = Vector(51.453388, 408.247406, 238.359039),
  113. money = 5
  114. allowed = {
  115. ["Insasse"] = true,
  116. ["El Chapo"] = true
  117. }
  118. },
  119. {
  120. name = "Freizeit",
  121. length = 2*60
  122. allowed = {
  123. ["Insasse"] = true,
  124. ["El Chapo"] = true
  125. }
  126. },
  127. {
  128. name = "Nachtruhe",
  129. length = 30,
  130. boxStart = Vector(-1764.056641, 916.408691, 54.972107),
  131. boxEnd = Vector(-831.744080, 1188.248901, 296.873383),
  132. money = 160
  133. allowed = {
  134. ["Insasse"] = true,
  135. ["El Chapo"] = true
  136. }
  137. }
  138. }
  139.  
  140. local moneyDelay = 5
  141. local moneyDeliverMessage = "Du hast %s erhalten, da du Anwesend bist."
  142.  
  143. local distFromCorner = 4
  144. local padding = 4
  145. local cornerRounding = 0
  146. local bgCol = Color(0, 0, 0, 200)
  147. local txtCol = Color(255, 255, 255, 255)
  148. local font = "Open Sans"
  149. local fontSize = 6
  150.  
  151. local timeLeft = true
  152.  
  153. local alignment = "top right"
  154. /*
  155. CONFIG END
  156. */
  157.  
  158. if(SERVER) then
  159. local state = 1
  160. local function incrementState()
  161. state = (states[state + 1] && state || 0) + 1
  162. SetGlobalString("GameState", states[state].name)
  163. hook.Run("GameStateChange", state, states[state])
  164. end
  165.  
  166. SetGlobalInt("NextStateChange", CurTime() + states[state].length)
  167. hook.Add("Think", "ProcessGameState", function()
  168. if(CurTime() > GetGlobalInt("NextStateChange")) then
  169. incrementState()
  170. SetGlobalInt("NextStateChange", CurTime() + states[state].length)
  171. else return end
  172. end)
  173.  
  174. timer.Create("GameStateMoney", moneyDelay, 0, function()
  175. local st = states[state]
  176. if(!st.boxStart || !st.boxEnd || !st.money) then return end
  177. local entities = ents.FindInBox(st.boxStart, st.boxEnd)
  178.  
  179. for _, ent in pairs(entities) do
  180. if(!IsValid(ent) || !ent:IsPlayer()) then continue end
  181. if(st.allowed && !st.allowed[team.GetName(ent:Team())]) then continue end
  182. ent:addMoney(st.money)
  183. DarkRP.notify(ent, NOTIFY_GENERIC, 3, string.format(moneyDeliverMessage, DarkRP.formatMoney(st.money)))
  184. end
  185. end)
  186. else
  187. surface.CreateFont("GameState", {font = font, size = ScreenScale(fontSize)})
  188.  
  189. local alignments = {
  190. ["top left"] = {
  191. x = 0,
  192. y = 0,
  193. },
  194. ["top right"] = {
  195. x = ScrW(),
  196. y = 0,
  197. right = true
  198. },
  199. ["bottom left"] = {
  200. x = 0,
  201. y = ScrH(),
  202. bottom = true
  203. },
  204. ["bottom right"] = {
  205. x = ScrW(),
  206. y = ScrH(),
  207. right = true,
  208. bottom = true
  209. }
  210. }
  211.  
  212. local rnd = cornerRounding * 2
  213.  
  214. local align = alignments[alignment]
  215.  
  216. local cd = ScreenScale(distFromCorner)
  217. local pad = ScreenScale(padding)
  218.  
  219. hook.Add("HUDPaint", "DrawGameState", function()
  220. local time = GetGlobalInt("NextStateChange") - CurTime()
  221. time = math.Round(time)
  222. time = math.Clamp(time, 0, math.huge)
  223. time = timeLeft && " - "..time.."s" || ""
  224.  
  225. local state = GetGlobalString("GameState")..time
  226. surface.SetFont("GameState")
  227. local w, h = surface.GetTextSize(state)
  228.  
  229. w, h = w + pad, h + pad
  230.  
  231. x, y = align.x-(align.right && w || 0)-(align.right && cd || -cd), align.y-(align.bottom && h || 0)-(align.bottom && cd || -cd)
  232.  
  233. if(rnd < 0) then
  234. draw.RoundedBox(rnd, x, y, w, h, bgCol)
  235. else
  236. surface.SetDrawColor(bgCol)
  237. surface.DrawRect(x, y, w, h)
  238. end
  239.  
  240. draw.SimpleText(state, "GameState", x+w/2, y+h/2, txtCol, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  241. end)
  242. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement