Guest User

Untitled

a guest
Dec 9th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.32 KB | None | 0 0
  1. /*---------------------------------------------------------
  2. Variables
  3. ---------------------------------------------------------*/
  4. local meta = FindMetaTable("Player")
  5.  
  6. /*---------------------------------------------------------
  7. RP names
  8. ---------------------------------------------------------*/
  9. local function RPName(ply, args)
  10. if ply.LastNameChange and ply.LastNameChange > (CurTime() - 5) then
  11. GAMEMODE:Notify( ply, 1, 4, string.format( LANGUAGE.have_to_wait, math.ceil(5 - (CurTime() - ply.LastNameChange)), "/rpname" ))
  12. return ""
  13. end
  14.  
  15. if GetConVarNumber("allowrpnames") ~= 1 then
  16. GAMEMODE:Notify(ply, 1, 6, string.format(LANGUAGE.disabled, "RPname", ""))
  17. return ""
  18. end
  19.  
  20. local len = string.len(args)
  21. local low = string.lower(args)
  22.  
  23. if len > 30 then
  24. GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.unable, "RPname", "<=30"))
  25. return ""
  26. elseif len < 3 then
  27. GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.unable, "RPname", ">2"))
  28. return ""
  29. end
  30.  
  31. local canChangeName = hook.Call("CanChangeRPName", GAMEMODE, ply, low)
  32. if canChangeName == false then
  33. GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.unable, "RPname", ""))
  34. return ""
  35. end
  36.  
  37. local allowed = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
  38. 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
  39. 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l',
  40. 'z', 'x', 'c', 'v', 'b', 'n', 'm', ' ',
  41. '(', ')', '[', ']', '!', '@', '#', '$', '%', '^', '&', '*', '-', '_', '=', '+', '|', '\\'}
  42.  
  43. for k in string.gmatch(args, ".") do
  44. if not table.HasValue(allowed, string.lower(k)) then
  45. GAMEMODE:Notify(ply, 1, 4, string.format(LANGUAGE.unable, "RPname", k))
  46. return ""
  47. end
  48. end
  49. ply:SetRPName(args)
  50. ply.LastNameChange = CurTime()
  51. return ""
  52. end
  53. AddChatCommand("/rpname", RPName)
  54. AddChatCommand("/name", RPName)
  55. AddChatCommand("/nick", RPName)
  56.  
  57. function meta:IsCP()
  58. local Team = self:Team()
  59. return Team == TEAM_POLICE or Team == TEAM_CHIEF or Team == TEAM_MAYOR or Team == TEAM_SWAT or Team == TEAM_SWATLEADER or Team == TEAM_CIVILMEDIC
  60. end
  61.  
  62. function meta:SetRPName(name, firstRun)
  63. -- Make sure nobody on this server already has this RP name
  64. local lowername = string.lower(tostring(name))
  65. DB.RetrieveRPNames(self, name, function(taken)
  66. if string.len(lowername) < 2 and not firstrun then return end
  67. -- If we found that this name exists for another player
  68. if taken then
  69. if firstRun then
  70. -- If we just connected and another player happens to be using our steam name as their RP name
  71. -- Put a 1 after our steam name
  72. DB.StoreRPName(self, name .. " 1")
  73. GAMEMODE:Notify(self, 0, 12, "Someone is already using your Steam name as their RP name so we gave you a '1' after your name.")
  74. else
  75. GAMEMODE:Notify(self, 1, 5, string.format(LANGUAGE.unable, "RPname", "it's been taken"))
  76. return ""
  77. end
  78. else
  79. if not firstRun then -- Don't save the steam name in the database
  80. GAMEMODE:NotifyAll(2, 6, string.format(LANGUAGE.rpname_changed, self:SteamName(), name))
  81. DB.StoreRPName(self, name)
  82. end
  83. end
  84. end)
  85. end
  86.  
  87. function meta:RestorePlayerData()
  88. if not ValidEntity(self) then return end
  89. DB.RetrievePlayerData(self, function(data)
  90. if not ValidEntity(self) then return end
  91.  
  92. local info = data and data[1] or {}
  93. if not info.rpname or info.rpname == "NULL" then info.rpname = string.gsub(self:SteamName(), "\\\"", "\"") end
  94.  
  95. self:SetDarkRPVar("money", info.wallet or GetConVarNumber("startingmoney"))
  96. self:SetDarkRPVar("salary", info.salary or GetConVarNumber("normalsalary"))
  97.  
  98. self:SetDarkRPVar("rpname", info.rpname)
  99. end)
  100. end
  101.  
  102. /*---------------------------------------------------------
  103. Admin/automatic stuff
  104. ---------------------------------------------------------*/
  105. function meta:HasPriv(priv)
  106. return (FAdmin and FAdmin.Access.PlayerHasPrivilege(self, priv)) or self:IsAdmin()
  107. end
  108.  
  109. function meta:ChangeAllowed(t)
  110. if not self.bannedfrom then return true end
  111. if self.bannedfrom[t] == 1 then return false else return true end
  112. end
  113.  
  114. function meta:ResetDMCounter()
  115. if not ValidEntity(self) then return end
  116. self.kills = 0
  117. return true
  118. end
  119.  
  120. function meta:InitiateTax()
  121. local taxtime = GetConVarNumber("wallettaxtime")
  122. timer.Create("rp_tax_"..self:UniqueID(), taxtime ~= 0 and taxtime or 600, 0, function(ply, timerName)
  123. if not ValidEntity(ply) then
  124. timer.Destroy(timerName)
  125. return
  126. end
  127.  
  128. if not tobool(GetConVarNumber("wallettax")) then
  129. return -- Don't remove the hook in case it's turned on afterwards.
  130. end
  131.  
  132. local money = ply.DarkRPVars.money
  133. local mintax = GetConVarNumber("wallettaxmin") / 100
  134. local maxtax = GetConVarNumber("wallettaxmax") / 100 -- convert to decimals for percentage calculations
  135. local startMoney = GetConVarNumber("startingmoney")
  136.  
  137. if money < (startMoney * 2) then
  138. return -- Don't tax players if they have less than twice the starting amount
  139. end
  140.  
  141. -- Variate the taxes between twice the starting money ($1000 by default) and 200 - 2 times the starting money (100.000 by default)
  142. local tax = (money - (startMoney * 2)) / (startMoney * 198)
  143. tax = mathx.Min(maxtax, mintax + (maxtax - mintax) * tax)
  144.  
  145. ply:AddMoney(-tax * money)
  146. GAMEMODE:Notify(ply, 3, 7, "Tax day! "..math.Round(tax * 100, 3) .. "% of your income was taken!")
  147.  
  148. end, self, "rp_tax_"..self:UniqueID())
  149. end
  150.  
  151. function meta:TeamUnBan(Team)
  152. if not ValidEntity(self) then return end
  153. if not self.bannedfrom then self.bannedfrom = {} end
  154. self.bannedfrom[Team] = 0
  155. end
  156.  
  157. function meta:TeamBan(t)
  158. if not self.bannedfrom then self.bannedfrom = {} end
  159. self.bannedfrom[t or self:Team()] = 1
  160. timer.Simple(GetConVarNumber("demotetime"), self.TeamUnBan, self, self:Team())
  161. end
  162.  
  163. function meta:CompleteSentence()
  164. if not ValidEntity(self) then return end
  165.  
  166. for k,v in pairs(GAMEMODE.ToggleCmds) do
  167. local value = GetConVarNumber(v.var)
  168. if value ~= v.default then
  169. RunConsoleCommand(v.var, v.default)
  170. timer.Simple(0, RunConsoleCommand, v.var, value)
  171. end
  172. end
  173.  
  174. for k,v in pairs(GAMEMODE.ValueCmds) do
  175. local value = GetConVarNumber(v.var)
  176. if value ~= v.default then
  177. RunConsoleCommand(v.var, v.default)
  178. timer.Simple(0, RunConsoleCommand, v.var, value)
  179. end
  180. end
  181.  
  182. if ValidEntity(self) and self:isArrested() then
  183. local time = GetConVarNumber("jailtimer")
  184. self:Arrest(time, true)
  185. GAMEMODE:Notify(self, 0, 5, string.format(LANGUAGE.jail_punishment, time))
  186. end
  187. end
  188.  
  189. local CSFiles = {}
  190. function GM:includeCS(dir)
  191. AddCSLuaFile(dir)
  192. table.insert(CSFiles, dir)
  193. end
  194.  
  195. function meta:NewData()
  196. if not ValidEntity(self) then return end
  197. local function ModuleDelay(ply)
  198. umsg.Start("LoadModules", ply)
  199. umsg.Short(#CSFiles)
  200. for n = 1, #CSFiles do
  201. umsg.String(CSFiles[n])
  202. end
  203. umsg.End()
  204. end
  205.  
  206. timer.Simple(.01, ModuleDelay, self)
  207.  
  208. -- Restoring data delayed the player handle will not be valid on the player otherwise
  209. timer.Simple(2, function() self:RestorePlayerData() end)
  210.  
  211. self:InitiateTax()
  212.  
  213. self:UpdateJob(team.GetName(1))
  214.  
  215. self:GetTable().Ownedz = { }
  216. self:GetTable().OwnedNumz = 0
  217.  
  218. self:GetTable().LastLetterMade = CurTime() - 61
  219. self:GetTable().LastVoteCop = CurTime() - 61
  220.  
  221. self:SetTeam(1)
  222.  
  223. -- Whether or not a player is being prevented from joining
  224. -- a specific team for a certain length of time
  225. for i = 1, #RPExtraTeams do
  226. if GetConVarNumber("restrictallteams") == 1 then
  227. self.bannedfrom[i] = 1
  228. else
  229. self.bannedfrom[i] = 0
  230. end
  231. end
  232. end
  233.  
  234. /*---------------------------------------------------------
  235. Teams/jobs
  236. ---------------------------------------------------------*/
  237. function meta:ChangeTeam(t, force)
  238. if self:isArrested() and not force then
  239. if not self:Alive() then
  240. GAMEMODE:Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), ""))
  241. return false
  242. else
  243. GAMEMODE:Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), ""))
  244. return false
  245. end
  246. end
  247.  
  248. self:SetSelfDarkRPVar("helpBoss",false)
  249. self:SetSelfDarkRPVar("helpCop",false)
  250. self:SetSelfDarkRPVar("helpMayor",false)
  251.  
  252. if t ~= TEAM_CITIZEN and not self:ChangeAllowed(t) and not force then
  253. GAMEMODE:Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), "banned/demoted"))
  254. return false
  255. end
  256.  
  257. if self.LastJob and 10 - (CurTime() - self.LastJob) >= 0 and not force then
  258. GAMEMODE:Notify(self, 1, 4, string.format(LANGUAGE.have_to_wait, math.ceil(10 - (CurTime() - self.LastJob)), "/job"))
  259. return false
  260. end
  261.  
  262. if self.IsBeingDemoted then
  263. self:TeamBan()
  264. self.IsBeingDemoted = false
  265. self:ChangeTeam(1, true)
  266. GAMEMODE.vote.DestroyVotesWithEnt(self)
  267. GAMEMODE:Notify(self, 1, 4, "You tried to escape demotion. You failed, and have been demoted.")
  268.  
  269. return false
  270. end
  271.  
  272.  
  273. if self:Team() == t then
  274. GAMEMODE:Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), ""))
  275. return false
  276. end
  277.  
  278. local TEAM = RPExtraTeams[t]
  279. if not TEAM then return end
  280.  
  281. if TEAM.customCheck and not TEAM.customCheck(self) then
  282. GAMEMODE:Notify(self, 1, 4, string.format(LANGUAGE.unable, team.GetName(t), ""))
  283. return false
  284. end
  285.  
  286. if not self.DarkRPVars["Priv"..TEAM.command] and not force then
  287. if type(TEAM.NeedToChangeFrom) == "number" and self:Team() ~= TEAM.NeedToChangeFrom then
  288. GAMEMODE:Notify(self, 1,4, string.format(LANGUAGE.need_to_be_before, team.GetName(TEAM.NeedToChangeFrom), TEAM.name))
  289. return false
  290. elseif type(TEAM.NeedToChangeFrom) == "table" and not table.HasValue(TEAM.NeedToChangeFrom, self:Team()) then
  291. local teamnames = ""
  292. for a,b in pairs(TEAM.NeedToChangeFrom) do teamnames = teamnames.." or "..team.GetName(b) end
  293. GAMEMODE:Notify(self, 1,4, string.format(string.sub(teamnames, 5), team.GetName(TEAM.NeedToChangeFrom), TEAM.name))
  294. return false
  295. end
  296. local max = TEAM.max
  297. if max ~= 0 and ((max % 1 == 0 and team.NumPlayers(t) >= max) or (max % 1 ~= 0 and (team.NumPlayers(t) + 1) / #player.GetAll() > max)) then
  298. GAMEMODE:Notify(self, 1, 4, string.format(LANGUAGE.team_limit_reached, TEAM.name))
  299. return false
  300. end
  301. end
  302.  
  303. if self:Team() == TEAM_MAYOR and tobool(GetConVarNumber("DarkRP_LockDown")) then
  304. GAMEMODE:UnLockdown(self)
  305. end
  306. self:UpdateJob(TEAM.name)
  307. self:SetSelfDarkRPVar("salary", TEAM.salary)
  308. GAMEMODE:NotifyAll(0, 4, string.format(LANGUAGE.job_has_become, self:Nick(), TEAM.name))
  309. if self.DarkRPVars.HasGunlicense then
  310. self:SetDarkRPVar("HasGunlicense", false)
  311. end
  312. if TEAM.Haslicense and GetConVarNumber("license") ~= 0 then
  313. self:SetDarkRPVar("HasGunlicense", true)
  314. end
  315.  
  316. self.LastJob = CurTime()
  317.  
  318. if t == TEAM_POLICE then
  319. self:SetSelfDarkRPVar("helpCop", true)
  320. elseif t == TEAM_MOB then
  321. self:SetSelfDarkRPVar("helpBoss", true)
  322. elseif t == TEAM_MAYOR then
  323. self:SetSelfDarkRPVar("helpMayor", true)
  324. end
  325.  
  326. if tobool(GetConVarNumber("removeclassitems")) then
  327. for k, v in pairs(ents.FindByClass("microwave")) do
  328. if v.SID == self.SID then v:Remove() end
  329. end
  330. for k, v in pairs(ents.FindByClass("gunlab")) do
  331. if v.SID == self.SID then v:Remove() end
  332. end
  333.  
  334. if t ~= TEAM_MOB and t ~= TEAM_GANG then
  335. for k, v in pairs(ents.FindByClass("drug_lab")) do
  336. if v.SID == self.SID then v:Remove() end
  337. end
  338. end
  339.  
  340. for k,v in pairs(ents.FindByClass("spawned_shipment")) do
  341. if v.SID == self.SID then v:Remove() end
  342. end
  343. end
  344.  
  345. if self:Team() == TEAM_MAYOR then
  346. for _, ent in pairs(self.lawboards or {}) do
  347. if ValidEntity(ent) then
  348. ent:Remove()
  349. end
  350. end
  351. end
  352.  
  353. self:SetTeam(t)
  354. DB.Log(self:SteamName().." ("..self:SteamID()..") changed to "..team.GetName(t), nil, Color(100, 0, 255))
  355. if self:InVehicle() then self:ExitVehicle() end
  356. if GetConVarNumber("norespawn") == 1 and self:Alive() then
  357. self:StripWeapons()
  358. local vPoint = self:GetShootPos() + Vector(0,0,50)
  359. local effectdata = EffectData()
  360. effectdata:SetEntity(self)
  361. effectdata:SetStart( vPoint ) -- Not sure if we need a start and origin (endpoint) for this effect, but whatever
  362. effectdata:SetOrigin( vPoint )
  363. effectdata:SetScale(1)
  364. util.Effect("entity_remove", effectdata)
  365. GAMEMODE:PlayerSetModel(self)
  366. GAMEMODE:PlayerLoadout(self)
  367. else
  368. self:KillSilent()
  369. end
  370. return true
  371. end
  372.  
  373. function meta:UpdateJob(job)
  374. self:SetDarkRPVar("job", job)
  375. self:GetTable().Pay = 1
  376. self:GetTable().LastPayDay = CurTime()
  377.  
  378. timer.Create(self:UniqueID() .. "jobtimer", GetConVarNumber("paydelay"), 0, self.PayDay, self)
  379. end
  380.  
  381. /*---------------------------------------------------------
  382. Money
  383. ---------------------------------------------------------*/
  384. function meta:CanAfford(amount)
  385. if not amount then return false end
  386. return math.floor(amount) >= 0 and self.DarkRPVars.money - math.floor(amount) >= 0
  387. end
  388.  
  389. function meta:AddMoney(amount)
  390. if not amount then return false end
  391. hook.Call("PlayerWalletChanged", GAMEMODE, ply, amount)
  392. DB.StoreMoney(self, self.DarkRPVars.money + math.floor(amount))
  393. end
  394.  
  395. function meta:PayDay()
  396. if not ValidEntity(self) or self:GetTable().Pay ~= 1 then return end
  397. if not self:isArrested() then
  398. DB.RetrieveSalary(self, function(amount)
  399. amount = math.floor(amount or GetConVarNumber("normalsalary"))
  400. hook.Call("PlayerGetSalary", GAMEMODE, self, amount)
  401. if amount == 0 or not amount then
  402. GAMEMODE:Notify(self, 4, 4, LANGUAGE.payday_unemployed)
  403. else
  404. self:AddMoney(amount)
  405. GAMEMODE:Notify(self, 4, 4, string.format(LANGUAGE.payday_message, CUR .. amount))
  406. end
  407. end)
  408. else
  409. GAMEMODE:Notify(self, 4, 4, LANGUAGE.payday_missed)
  410. end
  411. end
  412.  
  413. /*---------------------------------------------------------
  414. Jail/arrest
  415. ---------------------------------------------------------*/
  416. local function JailPos(ply)
  417. -- Admin or Chief can set the Jail Position
  418. if (ply:Team() == TEAM_CHIEF and GetConVarNumber("chiefjailpos") == 1) or ply:HasPriv("rp_commands") then
  419. DB.StoreJailPos(ply)
  420. else
  421. local str = "Admin only!"
  422. if GetConVarNumber("chiefjailpos") == 1 then
  423. str = "Chief or " .. str
  424. end
  425.  
  426. GAMEMODE:Notify(ply, 1, 4, str)
  427. end
  428. return ""
  429. end
  430. AddChatCommand("/jailpos", JailPos)
  431.  
  432. local function AddJailPos(ply)
  433. -- Admin or Chief can add Jail Positions
  434. if (ply:Team() == TEAM_CHIEF and GetConVarNumber("chiefjailpos") == 1) or ply:HasPriv("rp_commands") then
  435. DB.StoreJailPos(ply, true)
  436. else
  437. local str = LANGUAGE.admin_only
  438. if GetConVarNumber("chiefjailpos") == 1 then
  439. str = LANGUAGE.chief_or .. str
  440. end
  441.  
  442. GAMEMODE:Notify(ply, 1, 4, str)
  443. end
  444. return ""
  445. end
  446. AddChatCommand("/addjailpos", AddJailPos)
  447.  
  448. local arrestedPlayers = {}
  449. function meta:isArrested()
  450. return arrestedPlayers[self:SteamID()]
  451. end
  452.  
  453. function meta:setArrested(bool)
  454. arrestedPlayers[self:SteamID()] = bool or nil
  455. end
  456.  
  457. function meta:Arrest(time, rejoin)
  458. hook.Call("PlayerArrested", GAMEMODE, self, time)
  459. self:SetDarkRPVar("wanted", false)
  460. self.warranted = false
  461. self:SetSelfDarkRPVar("HasGunlicense", false)
  462. self:SetDarkRPVar("Arrested", true)
  463. GAMEMODE:SetPlayerSpeed(self, GetConVarNumber("aspd"), GetConVarNumber("aspd"))
  464. self:StripWeapons()
  465.  
  466. if tobool(GetConVarNumber("droppocketarrest")) and self.Pocket then
  467. for k, v in pairs(self.Pocket) do
  468. if ValidEntity(v) then
  469. v:SetMoveType(MOVETYPE_VPHYSICS)
  470. v:SetNoDraw(false)
  471. v:SetCollisionGroup(4)
  472. v:SetPos(self:GetPos() + Vector(0,0,10))
  473. local phys = v:GetPhysicsObject()
  474. phys:EnableCollisions(true)
  475. phys:Wake()
  476. end
  477. end
  478. self.Pocket = nil
  479. end
  480.  
  481. -- Always get sent to jail when Arrest() is called, even when already under arrest
  482. if GetConVarNumber("teletojail") == 1 and DB.CountJailPos() and DB.CountJailPos() ~= 0 then
  483. local jailpos = DB.RetrieveJailPos()
  484. if jailpos then
  485. self:SetPos(jailpos)
  486. end
  487. end
  488.  
  489. if not self:isArrested() or rejoin then
  490. self:setArrested(true)
  491. self.LastJailed = CurTime()
  492.  
  493. -- If the player has no remaining jail time,
  494. -- set it back to the max for this new sentence
  495. if not time or time == 0 then
  496. time = (GetConVarNumber("jailtimer") ~= 0 and GetConVarNumber("jailtimer")) or 120
  497. end
  498.  
  499. self:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.youre_arrested, time))
  500. for k, v in pairs(player.GetAll()) do
  501. if v ~= self then
  502. v:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.hes_arrested, self:Name(), time))
  503. end
  504. end
  505.  
  506. timer.Create(self:UniqueID() .. "jailtimer", time, 1, function() if ValidEntity(self) then self:Unarrest() end end)
  507. umsg.Start("GotArrested", self)
  508. umsg.Float(time)
  509. umsg.End()
  510. end
  511. end
  512.  
  513. function meta:Unarrest()
  514. hook.Call("PlayerUnarrested", GAMEMODE, self)
  515.  
  516. self:SetDarkRPVar("Arrested", false)
  517. if not ValidEntity(self) then
  518. return
  519. end
  520.  
  521. if self.Sleeping and GAMEMODE.KnockoutToggle then
  522. GAMEMODE:KnockoutToggle(self, "force")
  523. end
  524.  
  525. if self:isArrested() then
  526. self:setArrested(false)
  527.  
  528. GAMEMODE:SetPlayerSpeed(self, GetConVarNumber("wspd"), GetConVarNumber("rspd"))
  529. GAMEMODE:PlayerLoadout(self)
  530. if GetConVarNumber("telefromjail") == 1 and (not FAdmin or not self:FAdmin_GetGlobal("fadmin_jailed")) then
  531. local _, pos = GAMEMODE:PlayerSelectSpawn(self)
  532. self:SetPos(pos)
  533. elseif FAdmin and self:FAdmin_GetGlobal("fadmin_jailed") then
  534. self:SetPos(self.FAdminJailPos)
  535. end
  536.  
  537. timer.Destroy(self:SteamID() .. "jailtimer")
  538. GAMEMODE:NotifyAll(0, 4, string.format(LANGUAGE.hes_unarrested, self:Name()))
  539. end
  540. end
  541.  
  542. /*---------------------------------------------------------
  543. Items
  544. ---------------------------------------------------------*/
  545. function meta:UnownAll()
  546. for k, v in pairs(ents.GetAll()) do
  547. if v:IsOwnable() and v:OwnedBy(self) == true then
  548. v:Fire("unlock", "", 0.6)
  549. end
  550. end
  551.  
  552. if self:GetTable().Ownedz then
  553. for k, v in pairs(self:GetTable().Ownedz) do
  554. v:UnOwn(self)
  555. self:GetTable().Ownedz[v:EntIndex()] = nil
  556. end
  557. end
  558.  
  559. for k, v in pairs(player.GetAll()) do
  560. if v:GetTable().Ownedz then
  561. for n, m in pairs(v:GetTable().Ownedz) do
  562. if ValidEntity(m) and m:AllowedToOwn(self) then
  563. m:RemoveAllowed(self)
  564. end
  565. end
  566. end
  567. end
  568.  
  569. self:GetTable().OwnedNumz = 0
  570. end
  571.  
  572. function meta:DoPropertyTax()
  573. if GetConVarNumber("propertytax") == 0 then return end
  574. if (self:IsCP()) and GetConVarNumber("cit_propertytax") == 1 then return end
  575.  
  576. local numowned = self.OwnedNumz
  577.  
  578. if numowned <= 0 then return end
  579.  
  580. local price = 10
  581. local tax = price * numowned + math.random(-5, 5)
  582.  
  583. if self:CanAfford(tax) then
  584. if tax ~= 0 then
  585. self:AddMoney(-tax)
  586. GAMEMODE:Notify(self, 0, 5, string.format(LANGUAGE.property_tax, CUR .. tax))
  587. end
  588. else
  589. GAMEMODE:Notify(self, 1, 8, LANGUAGE.property_tax_cant_afford)
  590. self:UnownAll()
  591. end
  592. end
  593.  
  594. function meta:DropDRPWeapon(weapon)
  595. if GetConVarNumber("RestrictDrop") == 1 then
  596. local found = false
  597. for k,v in pairs(CustomShipments) do
  598. if v.entity == weapon:GetClass() then
  599. found = true
  600. break
  601. end
  602. end
  603.  
  604. if not found then return end
  605. end
  606.  
  607. self:DropWeapon(weapon) -- Drop it so the model isn't the viewmodel
  608.  
  609. local ent = ents.Create("spawned_weapon")
  610. local model = (weapon:GetModel() == "models/weapons/v_physcannon.mdl" and "models/weapons/w_physics.mdl") or weapon:GetModel()
  611.  
  612. ent.ShareGravgun = true
  613. ent:SetPos(self:GetShootPos() + self:GetAimVector() * 30)
  614. ent:SetModel(model)
  615. ent:SetSkin(weapon:GetSkin())
  616. ent.weaponclass = weapon:GetClass()
  617. ent.nodupe = true
  618. ent.clip1 = weapon:Clip1()
  619. ent.clip2 = weapon:Clip2()
  620.  
  621. ent.ammo = ammo
  622. self:RemoveAmmo(ammo, ammotype)
  623. ent:Spawn()
  624.  
  625. weapon:Remove()
  626. end
Add Comment
Please, Sign In to add comment