shadowndacorner

cl_init.lua

Sep 23rd, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.50 KB | None | 0 0
  1. GM.Version = "2.4.3"
  2. GM.Name = "DarkRP "..GM.Version
  3. GM.Author = "By Rickster, Updated: Pcwizdan, Sibre, philxyz, [GNC] Matt, Chrome Bolt, FPtje Falco, Eusion, Drakehawke"
  4.  
  5. DeriveGamemode("sandbox")
  6. util.PrecacheSound("earthquake.mp3")
  7. CUR = "$"
  8.  
  9. /*---------------------------------------------------------------------------
  10. Fonts
  11. ---------------------------------------------------------------------------*/
  12. surface.CreateFont ("DarkRPHUD1", {
  13. size = 16,
  14. weight = 600,
  15. antialias = true,
  16. shadow = true,
  17. font = "DejaVu Sans"})
  18. surface.CreateFont ("ScoreboardText", {
  19. size = 16,
  20. weight = 600,
  21. antialias = true,
  22. shadow = true,
  23. font = "DejaVu Sans"})
  24. surface.CreateFont ("DarkRPHUD2", {
  25. size = 23,
  26. weight = 400,
  27. antialias = true,
  28. shadow = false,
  29. font = "coolvetica"})
  30.  
  31. /*---------------------------------------------------------------------------
  32. Names
  33. ---------------------------------------------------------------------------*/
  34. -- Make sure the client sees the RP name where they expect to see the name
  35. local pmeta = FindMetaTable("Player")
  36.  
  37. pmeta.SteamName = pmeta.Name
  38. function pmeta:Name()
  39. if not self or not self.IsValid or not IsValid(self) then return "" end
  40.  
  41. self.DarkRPVars = self.DarkRPVars or {}
  42. if GetConVarNumber("allowrpnames") == 0 then
  43. return self:SteamName()
  44. end
  45. return self.DarkRPVars.rpname and tostring(self.DarkRPVars.rpname) or self:SteamName()
  46. end
  47.  
  48. pmeta.GetName = pmeta.Name
  49. pmeta.Nick = pmeta.Name
  50. -- End
  51.  
  52. local ENT = FindMetaTable("Entity")
  53. ENT.OldIsVehicle = ENT.IsVehicle
  54.  
  55. function ENT:IsVehicle()
  56. if type(self) ~= "Entity" then return false end
  57. local class = string.lower(self:GetClass())
  58. return ENT:OldIsVehicle() or string.find(class, "vehicle")
  59. -- Ent:IsVehicle() doesn't work correctly clientside:
  60. /*
  61. ] lua_run_cl print(LocalPlayer():GetEyeTrace().Entity)
  62. > Entity [128][prop_vehicle_jeep_old]
  63. ] lua_run_cl print(LocalPlayer():GetEyeTrace().Entity:IsVehicle())
  64. > false
  65. */
  66. end
  67.  
  68. function GM:DrawDeathNotice(x, y)
  69. if GetConVarNumber("deathnotice") ~= 1 then return end
  70. self.BaseClass:DrawDeathNotice(x, y)
  71. end
  72.  
  73. local function DisplayNotify(msg)
  74. local txt = msg:ReadString()
  75. GAMEMODE:AddNotify(txt, msg:ReadShort(), msg:ReadLong())
  76. surface.PlaySound("buttons/lightswitch2.wav")
  77.  
  78. -- Log to client console
  79. print(txt)
  80. end
  81. usermessage.Hook("_Notify", DisplayNotify)
  82.  
  83. local function LoadModules()
  84. local root = GAMEMODE.FolderName.."/gamemode/modules/"
  85.  
  86. local _, folders = file.Find(root.."*", LUA_PATH)
  87.  
  88. for _, folder in SortedPairs(folders, true) do
  89. for _, File in SortedPairs(file.Find(root .. folder .."/cl_*.lua", LUA_PATH), true) do
  90. include(root.. folder .. "/" ..File)
  91. end
  92. for _, File in SortedPairs(file.Find(root .. folder .."/sh_*.lua", LUA_PATH), true) do
  93. include(root.. folder .. "/" ..File)
  94. end
  95. end
  96. end
  97.  
  98. LocalPlayer().DarkRPVars = LocalPlayer().DarkRPVars or {}
  99. for k,v in pairs(player.GetAll()) do
  100. v.DarkRPVars = v.DarkRPVars or {}
  101. end
  102.  
  103. include("client/help.lua")
  104.  
  105. include("client/DRPDermaSkin.lua")
  106. include("client/helpvgui.lua")
  107. include("client/hud.lua")
  108. include("client/showteamtabs.lua")
  109. include("client/vgui.lua")
  110.  
  111. include("shared/animations.lua")
  112. include("shared/commands.lua")
  113. include("shared/entity.lua")
  114. include("shared/language.lua")
  115. include("shared/MakeThings.lua")
  116. include("shared/Workarounds.lua")
  117.  
  118. include("shared.lua")
  119. include("addentities.lua")
  120. include("ammotypes.lua")
  121.  
  122. include("FPP/sh_settings.lua")
  123. include("FPP/client/FPP_Menu.lua")
  124. include("FPP/client/FPP_HUD.lua")
  125. include("FPP/client/FPP_Buddies.lua")
  126. include("FPP/sh_CPPI.lua")
  127.  
  128. surface.CreateFont("AckBarWriting", {
  129. size = 20,
  130. weight = 500,
  131. antialias = true,
  132. shadow = false,
  133. font = "akbar"})
  134.  
  135. -- Copy from FESP(made by FPtje Falco)
  136. -- This is no stealing since I made FESP myself.
  137. local vector = FindMetaTable("Vector")
  138. function vector:RPIsInSight(v, ply)
  139. ply = ply or LocalPlayer()
  140. local trace = {}
  141. trace.start = ply:EyePos()
  142. trace.endpos = self
  143. trace.filter = v
  144. trace.mask = -1
  145. local TheTrace = util.TraceLine(trace)
  146. if TheTrace.Hit then
  147. return false, TheTrace.HitPos
  148. else
  149. return true, TheTrace.HitPos
  150. end
  151. end
  152.  
  153. function GM:HUDShouldDraw(name)
  154. if name == "CHudHealth" or
  155. name == "CHudBattery" or
  156. name == "CHudSuitPower" or
  157. (HelpToggled and name == "CHudChat") then
  158. return false
  159. else
  160. return true
  161. end
  162. end
  163.  
  164. function GM:HUDDrawTargetID()
  165. return false
  166. end
  167.  
  168. function GM:FindPlayer(info)
  169. if not info or info == "" then return nil end
  170. local pls = player.GetAll()
  171.  
  172. for k = 1, #pls do -- Proven to be faster than pairs loop.
  173. local v = pls[k]
  174. if tonumber(info) == v:UserID() then
  175. return v
  176. end
  177.  
  178. if info == v:SteamID() then
  179. return v
  180. end
  181.  
  182. if string.find(string.lower(v:SteamName()), string.lower(tostring(info)), 1, true) ~= nil then
  183. return v
  184. end
  185.  
  186. if string.find(string.lower(v:Name()), string.lower(tostring(info)), 1, true) ~= nil then
  187. return v
  188. end
  189. end
  190. return nil
  191. end
  192.  
  193. local GUIToggled = false
  194. local HelpToggled = false
  195.  
  196. local HelpVGUI
  197. local function ToggleHelp()
  198. if not HelpVGUI then
  199. HelpVGUI = vgui.Create("HelpVGUI")
  200. end
  201.  
  202. HelpToggled = not HelpToggled
  203.  
  204. HelpVGUI.HelpX = HelpVGUI.StartHelpX
  205. HelpVGUI:SetVisible(HelpToggled)
  206. gui.EnableScreenClicker(HelpToggled)
  207. end
  208. usermessage.Hook("ToggleHelp", ToggleHelp)
  209.  
  210. local function ToggleClicker()
  211. GUIToggled = not GUIToggled
  212. gui.EnableScreenClicker(GUIToggled)
  213. end
  214. usermessage.Hook("ToggleClicker", ToggleClicker)
  215.  
  216. local function DoSpecialEffects(Type)
  217. local thetype = string.lower(Type:ReadString())
  218. local toggle = tobool(Type:ReadString())
  219. if toggle then
  220. if thetype == "motionblur" then
  221. hook.Add("RenderScreenspaceEffects", thetype, function()
  222. DrawMotionBlur(0.05, 1.00, 0.035)
  223. end)
  224. elseif thetype == "dof" then
  225. DOF_SPACING = 8
  226. DOF_OFFSET = 9
  227. DOF_Start()
  228. elseif thetype == "colormod" then
  229. hook.Add("RenderScreenspaceEffects", thetype, function()
  230. local settings = {}
  231. settings[ "$pp_colour_addr" ] = 0
  232. settings[ "$pp_colour_addg" ] = 0
  233. settings[ "$pp_colour_addb" ] = 0
  234. settings[ "$pp_colour_brightness" ] = -1
  235. settings[ "$pp_colour_contrast" ] = 0
  236. settings[ "$pp_colour_colour" ] =0
  237. settings[ "$pp_colour_mulr" ] = 0
  238. settings[ "$pp_colour_mulg" ] = 0
  239. settings[ "$pp_colour_mulb" ] = 0
  240. DrawColorModify(settings)
  241. end)
  242. elseif thetype == "drugged" then
  243. hook.Add("RenderScreenspaceEffects", thetype, function()
  244. DrawSharpen(-1, 2)
  245. DrawMaterialOverlay("models/props_lab/Tank_Glass001", 0)
  246. DrawMotionBlur(0.13, 1, 0.00)
  247. end)
  248. elseif thetype == "deathpov" then
  249. hook.Add("CalcView", "rp_deathPOV", function(ply, origin, angles, fov)
  250. local Ragdoll = ply:GetRagdollEntity()
  251. if not IsValid(Ragdoll) then return end
  252.  
  253. local head = Ragdoll:LookupAttachment("eyes")
  254. head = Ragdoll:GetAttachment(head)
  255. if not head or not head.Pos then return end
  256.  
  257. local view = {}
  258. view.origin = head.Pos
  259. view.angles = head.Ang
  260. view.fov = fov
  261. return view
  262. end)
  263. end
  264. elseif toggle == false then
  265. if thetype == "dof" then
  266. DOF_Kill()
  267. return
  268. elseif thetype == "deathpov" then
  269. if hook.GetTable().CalcView and hook.GetTable().CalcView.rp_deathPOV then
  270. hook.Remove("CalcView", "rp_deathPOV")
  271. end
  272. return
  273. end
  274. hook.Remove("RenderScreenspaceEffects", thetype)
  275. end
  276. end
  277. usermessage.Hook("DarkRPEffects", DoSpecialEffects)
  278.  
  279. local Messagemode = false
  280. local playercolors = {}
  281. local HearMode = "talk"
  282. local isSpeaking = false
  283. local GroupChat = false
  284.  
  285. local function RPStopMessageMode()
  286. Messagemode = false
  287. hook.Remove("Think", "RPGetRecipients")
  288. hook.Remove("HUDPaint", "RPinstructionsOnSayColors")
  289. playercolors = {}
  290. end
  291.  
  292. local function CL_IsInRoom(listener) -- IsInRoom function to see if the player is in the same room.
  293. local tracedata = {}
  294. tracedata.start = LocalPlayer():GetShootPos()
  295. tracedata.endpos = listener:GetShootPos()
  296. local trace = util.TraceLine( tracedata )
  297.  
  298. return not trace.HitWorld
  299. end
  300.  
  301. local PlayerColorsOn = CreateClientConVar("rp_showchatcolors", 1, true, false)
  302. local function RPSelectwhohearit(group)
  303. if PlayerColorsOn:GetInt() == 0 then return end
  304. Messagemode = true
  305. GroupChat = group
  306. hook.Add("HUDPaint", "RPinstructionsOnSayColors", function()
  307. local w, l = ScrW()/80, ScrH() /1.75
  308. local h = l - (#playercolors * 20) - 20
  309. local AllTalk = GetConVarNumber("alltalk") == 1
  310. if #playercolors <= 0 and ((HearMode ~= "talk through OOC" and HearMode ~= "advert" and not AllTalk) or (AllTalk and HearMode ~= "talk" and HearMode ~= "me") or HearMode == "speak" ) then
  311. draw.WordBox(2, w, h, string.format(LANGUAGE.hear_noone, HearMode), "DarkRPHUD1", Color(0,0,0,160), Color(255,0,0,255))
  312. elseif HearMode == "talk through OOC" or HearMode == "advert" then
  313. draw.WordBox(2, w, h, LANGUAGE.hear_everyone, "DarkRPHUD1", Color(0,0,0,160), Color(0,255,0,255))
  314. elseif not AllTalk or (AllTalk and HearMode ~= "talk" and HearMode ~= "me") then
  315. draw.WordBox(2, w, h, string.format(LANGUAGE.hear_certain_persons, HearMode), "DarkRPHUD1", Color(0,0,0,160), Color(0,255,0,255))
  316. end
  317.  
  318. for k,v in pairs(playercolors) do
  319. if v.Nick then
  320. draw.WordBox(2, w, h + k*20, v:Nick(), "DarkRPHUD1", Color(0,0,0,160), Color(255,255,255,255))
  321. end
  322. end
  323. end)
  324.  
  325. hook.Add("Think", "RPGetRecipients", function()
  326. if not Messagemode then RPStopMessageMode() hook.Remove("Think", "RPGetRecipients") return end
  327. if HearMode ~= "whisper" and HearMode ~= "yell" and HearMode ~= "talk" and HearMode ~= "speak" and HearMode ~= "me" then return end
  328. playercolors = {}
  329. for k,v in pairs(player.GetAll()) do
  330. if v ~= LocalPlayer() then
  331. local distance = LocalPlayer():GetPos():Distance(v:GetPos())
  332. if HearMode == "whisper" and distance < 90 and not table.HasValue(playercolors, v) then
  333. table.insert(playercolors, v)
  334. elseif HearMode == "yell" and distance < 550 and not table.HasValue(playercolors, v) then
  335. table.insert(playercolors, v)
  336. elseif HearMode == "speak" and distance < 550 and not table.HasValue(playercolors, v) then
  337. if GetConVarNumber("dynamicvoice") == 1 then
  338. if CL_IsInRoom( v ) then
  339. table.insert(playercolors, v)
  340. end
  341. else
  342. table.insert(playercolors, v)
  343. end
  344. elseif HearMode == "talk" and GetConVarNumber("alltalk") ~= 1 and distance < 250 and not table.HasValue(playercolors, v) then
  345. table.insert(playercolors, v)
  346. elseif HearMode == "me" and GetConVarNumber("alltalk") ~= 1 and distance < 250 and not table.HasValue(playercolors, v) then
  347. table.insert(playercolors, v)
  348. end
  349. end
  350. end
  351. end)
  352. end
  353. hook.Add("StartChat", "RPDoSomethingWithChat", RPSelectwhohearit)
  354. hook.Add("FinishChat", "RPCloseRadiusDetection", function()
  355. if not isSpeaking then
  356. Messagemode = false
  357. RPStopMessageMode()
  358. else
  359. HearMode = "speak"
  360. end
  361. end)
  362.  
  363. function GM:ChatTextChanged(text)
  364. if PlayerColorsOn:GetInt() == 0 then return end
  365. if not Messagemode or HearMode == "speak" then return end
  366. local old = HearMode
  367. HearMode = "talk"
  368. if GetConVarNumber("alltalk") == 0 then
  369. if string.sub(text, 1, 2) == "//" or string.sub(string.lower(text), 1, 4) == "/ooc" or string.sub(string.lower(text), 1, 4) == "/a" then
  370. HearMode = "talk through OOC"
  371. elseif string.sub(string.lower(text), 1, 7) == "/advert" then
  372. HearMode = "advert"
  373. end
  374. end
  375.  
  376. if string.sub(string.lower(text), 1, 3) == "/pm" then
  377. local plyname = string.sub(text, 5)
  378. if string.find(plyname, " ") then
  379. plyname = string.sub(plyname, 1, string.find(plyname, " ") - 1)
  380. end
  381. HearMode = "pm"
  382. playercolors = {}
  383. if plyname ~= "" and self:FindPlayer(plyname) then
  384. playercolors = {self:FindPlayer(plyname)}
  385. end
  386. elseif string.sub(string.lower(text), 1, 5) == "/call" then
  387. local plyname = string.sub(text, 7)
  388. if string.find(plyname, " ") then
  389. plyname = string.sub(plyname, 1, string.find(plyname, " ") - 1)
  390. end
  391. HearMode = "call"
  392. playercolors = {}
  393. if plyname ~= "" and self:FindPlayer(plyname) then
  394. playercolors = {self:FindPlayer(plyname)}
  395. end
  396. elseif string.sub(string.lower(text), 1, 3) == "/g " or GroupChat then
  397. HearMode = "group chat"
  398. local t = LocalPlayer():Team()
  399. playercolors = {}
  400. if t == TEAM_POLICE or t == TEAM_CHIEF or t == TEAM_MAYOR then
  401. for k, v in pairs(player.GetAll()) do
  402. if v ~= LocalPlayer() then
  403. local vt = v:Team()
  404. if vt == TEAM_POLICE or vt == TEAM_CHIEF or vt == TEAM_MAYOR then table.insert(playercolors, v) end
  405. end
  406. end
  407. elseif t == TEAM_MOB or t == TEAM_GANG then
  408. for k, v in pairs(player.GetAll()) do
  409. if v ~= LocalPlayer() then
  410. local vt = v:Team()
  411. if vt == TEAM_MOB or vt == TEAM_GANG then table.insert(playercolors, v) end
  412. end
  413. end
  414. end
  415. elseif string.sub(string.lower(text), 1, 3) == "/w " then
  416. HearMode = "whisper"
  417. elseif string.sub(string.lower(text), 1, 2) == "/y" then
  418. HearMode = "yell"
  419. elseif string.sub(string.lower(text), 1, 3) == "/me" then
  420. HearMode = "me"
  421. end
  422. if old ~= HearMode then
  423. playercolors = {}
  424. end
  425. end
  426.  
  427. function GM:PlayerStartVoice(ply)
  428. isSpeaking = true
  429. LocalPlayer().DarkRPVars = LocalPlayer().DarkRPVars or {}
  430. if ply == LocalPlayer() and GetConVarNumber("sv_alltalk") == 0 and GetConVarNumber("voiceradius") == 1 then
  431. HearMode = "speak"
  432. RPSelectwhohearit()
  433. end
  434.  
  435. if ply == LocalPlayer() then
  436. ply.DRPIsTalking = true
  437. return -- Not the original rectangle for yourself! ugh!
  438. end
  439. self.BaseClass:PlayerStartVoice(ply)
  440. end
  441.  
  442. function GM:PlayerEndVoice(ply) //voice/icntlk_pl.vtf
  443. isSpeaking = false
  444.  
  445. if ply == LocalPlayer() and GetConVarNumber("sv_alltalk") == 0 and GetConVarNumber("voiceradius") == 1 then
  446. HearMode = "talk"
  447. hook.Remove("Think", "RPGetRecipients")
  448. hook.Remove("HUDPaint", "RPinstructionsOnSayColors")
  449. Messagemode = false
  450. playercolors = {}
  451. end
  452.  
  453. if ply == LocalPlayer() then
  454. ply.DRPIsTalking = false
  455. return
  456. end
  457. self.BaseClass:PlayerEndVoice(ply)
  458. end
  459.  
  460. function GM:PlayerBindPress(ply,bind,pressed)
  461. self.BaseClass:PlayerBindPress(ply, bind, pressed)
  462. if ply == LocalPlayer() and IsValid(ply:GetActiveWeapon()) and string.find(string.lower(bind), "attack2") and ply:GetActiveWeapon():GetClass() == "weapon_bugbait" then
  463. LocalPlayer():ConCommand("_hobo_emitsound")
  464. end
  465. return
  466. end
  467.  
  468. local function AddToChat(msg)
  469. local col1 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort())
  470.  
  471. local name = msg:ReadString()
  472. local ply = msg:ReadEntity() or LocalPlayer()
  473.  
  474. if name == "" or not name then
  475. name = ply:Nick()
  476. name = name ~= "" and name or ply:SteamName()
  477. end
  478.  
  479. local col2 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort())
  480.  
  481. local text = msg:ReadString()
  482. if text and text ~= "" then
  483. chat.AddText(col1, name, col2, ": "..text)
  484. if IsValid(ply) then
  485. hook.Call("OnPlayerChat", nil, ply, text, false, ply:Alive())
  486. end
  487. else
  488. chat.AddText(col1, name)
  489. hook.Call("ChatText", nil, "0", name, name, "none")
  490. end
  491. chat.PlaySound()
  492. end
  493. usermessage.Hook("DarkRP_Chat", AddToChat)
  494.  
  495. local function GetAvailableVehicles()
  496. print("Available vehicles for custom vehicles:")
  497. for k,v in pairs(list.Get("Vehicles")) do
  498. print("\""..k.."\"")
  499. end
  500. end
  501. concommand.Add("rp_getvehicles", GetAvailableVehicles)
  502.  
  503. local function AdminLog(um)
  504. local colour = Color(um:ReadShort(), um:ReadShort(), um:ReadShort())
  505. local text = um:ReadString() .. "\n"
  506. MsgC(Color(255,0,0), "[DarkRP] ")
  507. MsgC(colour, text)
  508. end
  509. usermessage.Hook("DRPLogMsg", AdminLog)
  510.  
  511. local function RetrieveDoorData(len)
  512. local door = net.ReadEntity()
  513. local doorData = net.ReadTable()
  514. if not door or not door.IsValid or not IsValid(door) then return end
  515.  
  516. if doorData.TeamOwn then
  517. local tdata = {}
  518. for k, v in pairs(string.Explode("\n", doorData.TeamOwn or "")) do
  519. if v and v != "" then
  520. tdata[tonumber(v)] = true
  521. end
  522. end
  523. doorData.TeamOwn = tdata
  524. else
  525. doorData.TeamOwn = nil
  526. end
  527.  
  528. door.DoorData = doorData
  529.  
  530. local DoorString = "Data:\n"
  531. for k,v in pairs(doorData) do
  532. DoorString = DoorString .. k.."\t\t".. tostring(v) .. "\n"
  533. end
  534. end
  535. net.Receive("DarkRP_DoorData", RetrieveDoorData)
  536.  
  537. local function UpdateDoorData(um)
  538. local door = um:ReadEntity()
  539. if not IsValid(door) then return end
  540.  
  541. local var, value = um:ReadString(), um:ReadString()
  542. value = tonumber(value) or value
  543.  
  544. if string.match(tostring(value), "Entity .([0-9]*)") then
  545. value = Entity(string.match(value, "Entity .([0-9]*)"))
  546. end
  547.  
  548. if string.match(tostring(value), "Player .([0-9]*)") then
  549. value = Entity(string.match(value, "Player .([0-9]*)"))
  550. end
  551.  
  552. if value == "true" or value == "false" then value = tobool(value) end
  553.  
  554. if value == "nil" then value = nil end
  555.  
  556. if var == "TeamOwn" then
  557. local decoded = {}
  558. for k, v in pairs(string.Explode("\n", value or "")) do
  559. if v and v != "" then
  560. decoded[tonumber(v)] = true
  561. end
  562. end
  563. if table.Count( decoded ) == 0 then
  564. value = nil
  565. else
  566. value = decoded
  567. end
  568. end
  569.  
  570. door.DoorData[var] = value
  571. end
  572. usermessage.Hook("DRP_UpdateDoorData", UpdateDoorData)
  573.  
  574. local function RetrievePlayerVar(um)
  575. local ply = um:ReadEntity()
  576. if not IsValid(ply) then return end
  577.  
  578. ply.DarkRPVars = ply.DarkRPVars or {}
  579.  
  580. local var, value = um:ReadString(), um:ReadString()
  581. local stringvalue = value
  582. value = tonumber(value) or value
  583.  
  584. if string.match(stringvalue, "Entity .([0-9]*)") then
  585. value = Entity(string.match(stringvalue, "Entity .([0-9]*)"))
  586. end
  587.  
  588. if string.match(stringvalue, "(-?[0-9]+\.[0-9]+) (-?[0-9]+\.[0-9]+) (-?[0-9]+\.[0-9]+)") then
  589. local x,y,z = string.match(value, "(-?[0-9]+\.[0-9]+) (-?[0-9]+\.[0-9]+) (-?[0-9]+\.[0-9]+)")
  590. value = Vector(x,y,z)
  591. end
  592.  
  593. if stringvalue == "true" or stringvalue == "false" then value = tobool(value) end
  594.  
  595. if stringvalue == "nil" then value = nil end
  596.  
  597. hook.Call("DarkRPVarChanged", nil, ply, var, ply.DarkRPVars[var], value)
  598. ply.DarkRPVars[var] = value
  599. end
  600. usermessage.Hook("DarkRP_PlayerVar", RetrievePlayerVar)
  601.  
  602. local function InitializeDarkRPVars(len)
  603. local ply = net.ReadEntity()
  604. local vars = net.ReadTable()
  605. if not vars then return end
  606. ply.DarkRPVars = vars
  607. end
  608. net.Receive("DarkRP_InitializeVars", InitializeDarkRPVars)
  609.  
  610. function GM:InitPostEntity()
  611. LoadModules()
  612. function VoiceNotify:Init()
  613. self.LabelName = vgui.Create( "DLabel", self )
  614. self.Avatar = vgui.Create( "SpawnIcon", self )
  615. end
  616.  
  617. function VoiceNotify:Setup(ply)
  618. self.LabelName:SetText( ply:Nick() )
  619. self.Avatar:SetModel( ply:GetModel() )
  620. self.Avatar:SetSize(32)
  621.  
  622. self.Color = team.GetColor( ply:Team() )
  623.  
  624. self:InvalidateLayout()
  625. end
  626.  
  627. RunConsoleCommand("_sendDarkRPvars")
  628. timer.Create("DarkRPCheckifitcamethrough", 30, 0, function()
  629. for k,v in pairs(player.GetAll()) do
  630. v.DarkRPVars = v.DarkRPVars or {}
  631. if not v.DarkRPVars.job or not v.DarkRPVars.money or not v.DarkRPVars.rpname then
  632. RunConsoleCommand("_sendDarkRPvars")
  633. return
  634. end
  635. timer.Destroy("DarkRPCheckifitcamethrough")
  636. end
  637. end)
  638. end
  639.  
  640. -- Please only ADD to the credits
  641. -- Removing people from the credits will make at least one person very angry.
  642. local creds =
  643. [[LightRP:
  644. Rick darkalonio
  645.  
  646. DarkRP:
  647. Rickster
  648. Picwizdan
  649. Sibre
  650. PhilXYZ
  651. [GNC] Matt
  652. Chromebolt A.K.A. unib5 (STEAM_0:1:19045957)
  653. Falco A.K.A. FPtje (STEAM_0:0:8944068)
  654. Eusion (STEAM_0:0:20450406)
  655. Drakehawke (STEAM_0:0:22342869)]]
  656.  
  657. local function credits(um)
  658. chat.AddText(Color(255,0,0,255), "CREDITS FOR DARKRP", Color(0,0,255,255), creds)
  659. end
  660. usermessage.Hook("DarkRP_Credits", credits)
  661.  
  662. -- DarkRP plugin for FAdmin. It's this simple to make a plugin. If FAdmin isn't installed, this code won't bother anyone
  663. --include(GM.FolderName.."/gamemode/shared/FAdmin_DarkRP.lua")
  664.  
  665. if not FAdmin or not FAdmin.StartHooks then return end
  666. FAdmin.StartHooks["DarkRP"] = function()
  667. -- DarkRP information:
  668. FAdmin.ScoreBoard.Player:AddInformation("Steam name", function(ply) return ply:SteamName() end, true)
  669. FAdmin.ScoreBoard.Player:AddInformation("Money", function(ply) if LocalPlayer():IsAdmin() and ply.DarkRPVars and ply.DarkRPVars.money then return "$"..ply.DarkRPVars.money end end)
  670. FAdmin.ScoreBoard.Player:AddInformation("Wanted", function(ply) if ply.DarkRPVars and ply.DarkRPVars.wanted then return tostring(ply.DarkRPVars["wantedReason"] or "N/A") end end)
  671. FAdmin.ScoreBoard.Player:AddInformation("Community link", function(ply) return FAdmin.SteamToProfile(ply:SteamID()) end)
  672.  
  673. -- Warrant
  674. FAdmin.ScoreBoard.Player:AddActionButton("Warrant", "FAdmin/icons/Message", Color(0, 0, 200, 255),
  675. function(ply) local t = LocalPlayer():Team() return t == TEAM_POLICE or t == TEAM_MAYOR or t == TEAM_CHIEF end,
  676. function(ply, button)
  677. Derma_StringRequest("Warrant reason", "Enter the reason for the warrant", "", function(Reason)
  678. LocalPlayer():ConCommand("say /warrant ".. ply:UserID().." ".. Reason)
  679. end)
  680. end)
  681.  
  682. --wanted
  683. FAdmin.ScoreBoard.Player:AddActionButton(function(ply)
  684. return ((ply.DarkRPVars.wanted and "Unw") or "W") .. "anted"
  685. end,
  686. function(ply) return "FAdmin/icons/jail", ply.DarkRPVars.wanted and "FAdmin/icons/disable" end,
  687. Color(0, 0, 200, 255),
  688. function(ply) local t = LocalPlayer():Team() return t == TEAM_POLICE or t == TEAM_MAYOR or t == TEAM_CHIEF end,
  689. function(ply, button)
  690. if not ply.DarkRPVars.wanted then
  691. Derma_StringRequest("wanted reason", "Enter the reason to arrest this player", "", function(Reason)
  692. LocalPlayer():ConCommand("say /wanted ".. ply:UserID().." ".. Reason)
  693. end)
  694. else
  695. LocalPlayer():ConCommand("say /unwanted ".. ply:UserID())
  696. end
  697. end)
  698.  
  699. --Teamban
  700. local function teamban(ply, button)
  701.  
  702. local menu = DermaMenu()
  703. local Title = vgui.Create("DLabel")
  704. Title:SetText(" Jobs:\n")
  705. Title:SetFont("UiBold")
  706. Title:SizeToContents()
  707. Title:SetTextColor(color_black)
  708. local command = (button.TextLabel:GetText() == "Unban from job") and "rp_teamunban" or "rp_teamban"
  709.  
  710. menu:AddPanel(Title)
  711. for k,v in SortedPairsByMemberValue(RPExtraTeams, "name") do
  712. menu:AddOption(v.name, function() RunConsoleCommand(command, ply:UserID(), k) end)
  713. end
  714. menu:Open()
  715. end
  716. FAdmin.ScoreBoard.Player:AddActionButton("Ban from job", "FAdmin/icons/changeteam", Color(200, 0, 0, 255),
  717. function(ply) return FAdmin.Access.PlayerHasPrivilege(LocalPlayer(), "rp_commands", ply) end, teamban)
  718.  
  719. FAdmin.ScoreBoard.Player:AddActionButton("Unban from job", function() return "FAdmin/icons/changeteam", "FAdmin/icons/disable" end, Color(200, 0, 0, 255),
  720. function(ply) return FAdmin.Access.PlayerHasPrivilege(LocalPlayer(), "rp_commands", ply) end, teamban)
  721. end
Advertisement
Add Comment
Please, Sign In to add comment