shadowndacorner

Code for ya

Jul 5th, 2011
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.72 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.     local IsHourJob=false
  316.     // SHORTCUT LOLZ
  317.     for f, v in pairs(donatorjobs) do
  318.         if t==v then
  319.             IsDonatorJob=true
  320.         end
  321.     end
  322.    
  323.     for f, v in pairs(hourjobs) do
  324.         if t==v then
  325.             IsHourJob=true
  326.         end
  327.     end
  328.    
  329.     if IsDonatorJob==true then
  330.         if ( isDonator or self:IsAdmin() or self:IsSuperAdmin() ) then
  331.             self:SetTeam( t )
  332.             self:UpdateJob(TEAM.name)
  333.             DB.StoreSalary(self, TEAM.salary)
  334.             NotifyAll(0, 4, string.format(LANGUAGE.job_has_become, self:Nick(), TEAM.name))
  335.             DB.Log(self:SteamName().." ("..self:SteamID()..") changed to "..team.GetName(t))
  336.                 if self:InVehicle() then self:ExitVehicle() end
  337.                 if GetConVarNumber("norespawn") == 1 and self:Alive() then
  338.                 self:StripWeapons()
  339.                     local vPoint = self:GetShootPos() + Vector(0,0,50)
  340.                     local effectdata = EffectData()
  341.                     effectdata:SetEntity(self)
  342.                     effectdata:SetStart( vPoint ) -- Not sure if we need a start and origin (endpoint) for this effect, but whatever
  343.                     effectdata:SetOrigin( vPoint )
  344.                     effectdata:SetScale(1)
  345.                     util.Effect("entity_remove", effectdata)
  346.                     GAMEMODE:PlayerSetModel(self)
  347.                     GAMEMODE:PlayerLoadout(self)
  348.                 else
  349.                     self:KillSilent()
  350.                 end
  351.         else
  352.             Notify(self, 1, 4, "You must be a donator to use that job!")
  353.         end
  354.     else
  355.         self:SetTeam( t )
  356.         self:UpdateJob(TEAM.name)
  357.         DB.StoreSalary(self, TEAM.salary)
  358.         if silent==true then
  359.         else
  360.             NotifyAll(0, 4, string.format(LANGUAGE.job_has_become, self:Nick(), TEAM.name))
  361.         end
  362.         DB.Log(self:SteamName().." ("..self:SteamID()..") changed to "..team.GetName(t))
  363.         if self:InVehicle() then self:ExitVehicle() end
  364.         if GetConVarNumber("norespawn") == 1 and self:Alive() then
  365.             self:StripWeapons()
  366.             local vPoint = self:GetShootPos() + Vector(0,0,50)
  367.             local effectdata = EffectData()
  368.             effectdata:SetEntity(self)
  369.             effectdata:SetStart( vPoint ) -- Not sure if we need a start and origin (endpoint) for this effect, but whatever
  370.             effectdata:SetOrigin( vPoint )
  371.             effectdata:SetScale(1)
  372.             util.Effect("entity_remove", effectdata)
  373.             GAMEMODE:PlayerSetModel(self)
  374.             GAMEMODE:PlayerLoadout(self)
  375.         else
  376.             self:KillSilent()
  377.         end
  378.     end
  379. end
  380.  
  381. function meta:UpdateJob(job)
  382.     self:SetDarkRPVar("job", job)
  383.     self:GetTable().Pay = 1
  384.     self:GetTable().LastPayDay = CurTime()
  385.  
  386.     timer.Create(self:SteamID() .. "jobtimer", GetConVarNumber("paydelay"), 0, self.PayDay, self)
  387. end
  388.  
  389. /*---------------------------------------------------------
  390.  Money
  391.  ---------------------------------------------------------*/
  392. function meta:CanAfford(amount)
  393.     if not amount then return false end
  394.     return math.floor(amount) >= 0 and self.DarkRPVars.money - math.floor(amount) >= 0
  395. end
  396.  
  397. function meta:GetMoney()
  398.     return self.DarkRPVars.money
  399. end
  400.  
  401. function meta:AddMoney(amount)
  402.     if not amount then return false end
  403.     DB.StoreMoney(self, self.DarkRPVars.money + math.floor(amount))
  404. end
  405.  
  406. function meta:AddPoints(amount)
  407.     if not amount then return false end
  408.     DB.StorePoints(self, self.DarkRPVars.money + math.floor(amount))
  409. end
  410.  
  411. function meta:PayDay()
  412.     if ValidEntity(self) and self:GetTable().Pay == 1 then
  413.         if not RPArrestedPlayers[self:SteamID()] then
  414.             DB.RetrieveSalary(self, function(amount)
  415.                 amount = math.floor(amount or GetConVarNumber("normalsalary"))
  416.                 if amount == 0 or not amount then
  417.                     Notify(self, 4, 4, LANGUAGE.payday_unemployed)
  418.                 else
  419.                     if ( isDonator=self:IsUserGroup("VIP") or self:IsAdmin() or self:IsSuperAdmin() ) then
  420.                         self:AddMoney(amount*2)
  421.                         Notify(self, 4, 4, string.format(LANGUAGE.payday_message, "You have earned 2x "..amount.." because you are a donator!"))
  422.                     else
  423.                         self:AddMoney(amount)
  424.                         Notify(self, 4, 4, string.format(LANGUAGE.payday_message, CUR .. amount))
  425.                     end
  426.                 end
  427.             end)
  428.         else
  429.             Notify(self, 4, 4, LANGUAGE.payday_missed)
  430.         end
  431.     end
  432. end
  433.  
  434. /*---------------------------------------------------------
  435.  Jail/arrest
  436.  ---------------------------------------------------------*/
  437. local function JailPos(ply)
  438.     -- Admin or Chief can set the Jail Position
  439.     if (ply:Team() == TEAM_CHIEF and GetConVarNumber("chiefjailpos") == 1) or ply:HasPriv("rp_commands") then
  440.         DB.StoreJailPos(ply)
  441.     else
  442.         local str = "Admin only!"
  443.         if GetConVarNumber("chiefjailpos") == 1 then
  444.             str = "Chief or " .. str
  445.         end
  446.  
  447.         Notify(ply, 1, 4, str)
  448.     end
  449.     return ""
  450. end
  451. AddChatCommand("/jailpos", JailPos)
  452.  
  453. local function AddJailPos(ply)
  454.     -- Admin or Chief can add Jail Positions
  455.     if (ply:Team() == TEAM_CHIEF and GetConVarNumber("chiefjailpos") == 1) or ply:HasPriv("rp_commands") then
  456.         DB.StoreJailPos(ply, true)
  457.     else
  458.         local str = LANGUAGE.admin_only
  459.         if GetConVarNumber("chiefjailpos") == 1 then
  460.             str = LANGUAGE.chief_or .. str
  461.         end
  462.  
  463.         Notify(ply, 1, 4, str)
  464.     end
  465.     return ""
  466. end
  467. AddChatCommand("/addjailpos", AddJailPos)
  468.  
  469. function meta:Arrest(time, rejoin)
  470.     self:SetDarkRPVar("wanted", false)
  471.     self.warranted = false
  472.     self:SetDarkRPVar("HasGunlicense", false)
  473.     self:SetDarkRPVar("Arrested", true)
  474.     GAMEMODE:SetPlayerSpeed(self, GetConVarNumber("aspd"), GetConVarNumber("aspd"))
  475.     self:StripWeapons()
  476.    
  477.     if tobool(GetConVarNumber("droppocketarrest")) and self.Pocket then
  478.         for k, v in pairs(self.Pocket) do
  479.             if ValidEntity(v) then
  480.                 v:SetMoveType(MOVETYPE_VPHYSICS)
  481.                 v:SetNoDraw(false)
  482.                 v:SetCollisionGroup(4)
  483.                 v:SetPos(self:GetPos() + Vector(0,0,10))
  484.                 local phys = v:GetPhysicsObject()
  485.                 if phys:IsValid() then
  486.                     phys:EnableCollisions(true)
  487.                     phys:Wake()
  488.                 end
  489.             end
  490.         end
  491.         self.Pocket = nil
  492.     end
  493.    
  494.     -- Always get sent to jail when Arrest() is called, even when already under arrest
  495.     if GetConVarNumber("teletojail") == 1 and DB.CountJailPos() and DB.CountJailPos() ~= 0 then
  496.         local jailpos = DB.RetrieveJailPos()
  497.         if jailpos then
  498.             self:SetPos(jailpos)
  499.         end
  500.     end
  501.    
  502.     if not RPArrestedPlayers[self:SteamID()] or rejoin then
  503.         local ID = self:SteamID()
  504.         RPArrestedPlayers[ID] = true
  505.         self.LastJailed = CurTime()
  506.        
  507.         -- If the player has no remaining jail time,
  508.         -- set it back to the max for this new sentence
  509.         if not time or time == 0 then
  510.             time = (GetConVarNumber("jailtimer") ~= 0 and GetConVarNumber("jailtimer")) or 120
  511.         end
  512.  
  513.         self:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.youre_arrested, time))
  514.         for k, v in pairs(player.GetAll()) do
  515.             if v ~= self then
  516.                 v:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.hes_arrested, self:Name(), time))
  517.             end
  518.         end
  519.        
  520.         timer.Create(ID .. "jailtimer", time, 1, function() if ValidEntity(self) then self:Unarrest(ID) end end)
  521.         umsg.Start("GotArrested", self)
  522.             umsg.Float(time)
  523.         umsg.End()
  524.     end
  525. end
  526.  
  527. function meta:Unarrest(ID)
  528.     self:SetDarkRPVar("Arrested", false)
  529.     if not ValidEntity(self) then
  530.         RPArrestedPlayers[ID] = nil
  531.         return
  532.     end
  533.    
  534.     if self.Sleeping then
  535.         KnockoutToggle(self, "force")
  536.     end
  537.  
  538.     if RPArrestedPlayers[self:SteamID()] ~= nil then
  539.         RPArrestedPlayers[self:SteamID()] = nil
  540.        
  541.         GAMEMODE:SetPlayerSpeed(self, GetConVarNumber("wspd"), GetConVarNumber("rspd"))
  542.         GAMEMODE:PlayerLoadout(self)
  543.         if GetConVarNumber("telefromjail") == 1 and (not FAdmin or not self:FAdmin_GetGlobal("fadmin_jailed")) then
  544.             local _, pos = GAMEMODE:PlayerSelectSpawn(self)
  545.             self:SetPos(pos)
  546.         elseif FAdmin and self:FAdmin_GetGlobal("fadmin_jailed") then
  547.             self:SetPos(self.FAdminJailPos)
  548.         end
  549.        
  550.         timer.Destroy(self:SteamID() .. "jailtimer")
  551.         NotifyAll(0, 4, string.format(LANGUAGE.hes_unarrested, self:Name()))
  552.     end
  553. end
  554.  
  555. /*---------------------------------------------------------
  556.  Items
  557.  ---------------------------------------------------------*/
  558. function meta:UnownAll()
  559.     for k, v in pairs(ents.GetAll()) do
  560.         if v:IsOwnable() and v:OwnedBy(self) == true then
  561.             v:Fire("unlock", "", 0.6)
  562.         end
  563.     end
  564.  
  565.     if self:GetTable().Ownedz then
  566.         for k, v in pairs(self:GetTable().Ownedz) do
  567.             v:UnOwn(self)
  568.             self:GetTable().Ownedz[v:EntIndex()] = nil
  569.         end
  570.     end
  571.  
  572.     for k, v in pairs(player.GetAll()) do
  573.         if v:GetTable().Ownedz then
  574.             for n, m in pairs(v:GetTable().Ownedz) do
  575.                 if ValidEntity(m) and m:AllowedToOwn(self) then
  576.                     m:RemoveAllowed(self)
  577.                 end
  578.             end
  579.         end
  580.     end
  581.  
  582.     self:GetTable().OwnedNumz = 0
  583. end
  584.  
  585. function meta:DoPropertyTax()
  586.     if GetConVarNumber("propertytax") == 0 then return end
  587.     if (self:IsCP()) and GetConVarNumber("cit_propertytax") == 1 then return end
  588.  
  589.     local numowned = self:GetTable().OwnedNumz
  590.  
  591.     if numowned <= 0 then return end
  592.  
  593.     local price = 10
  594.     local tax = price * numowned + math.random(-5, 5)
  595.  
  596.     if self:CanAfford(tax) then
  597.         if tax ~= 0 then
  598.             self:AddMoney(-tax)
  599.             Notify(self, 0, 5, string.format(LANGUAGE.property_tax, CUR .. tax))
  600.         end
  601.     else
  602.         Notify(self, 1, 8, LANGUAGE.property_tax_cant_afford)
  603.         self:UnownAll()
  604.     end
  605. end
  606. ---------------------------------------------------------------------------------------
  607. // Hobos part
  608. // Make argument 1 be amount of money
  609. function DonateToHobos(ply, cmd, args)
  610.     local hoboCount=table.Count(team.GetPlayers(TEAM_HOBO))+table.Count(team.GetPlayers(TEAM_HOBOLEAD))
  611.     local evenNum==math.floor(args[1]/hoboCount)
  612.     for f, v in pairs(player.GetAll()) do
  613.         if ( v:Team()==TEAM_HOBO ) or v:Team()==TEAM_HOBOLEAD then
  614.             v:AddMoney(evenNum)
  615.         end
  616.     end
  617. end
  618. concommand.Add("_donateToHobos", DonateToHobos)
Advertisement
Add Comment
Please, Sign In to add comment