Advertisement
shadowndacorner

player.lua

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