Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local PLUGIN = {}
- PLUGIN.Title = "Count Stuff"
- PLUGIN.Description = "Counts stuff on map."
- PLUGIN.Author = "Frankess"
- PLUGIN.ChatCommand = "count"
- PLUGIN.Usage = '<player> / nothing to show your props'
- PLUGIN.Privileges = { "Count" }
- if SERVER then
- util.AddNetworkString( "EV_countstream" )
- end
- local function GetClass(str)
- if str == "prop_physics" then return "prop" end
- if str == "prop_vehicle_prisoner_pod" or str == "prop_vehicle_jeep" or str == "prop_vehicle_jeep_old" or str == "prop_vehicle_airboat" then return "vehicle" end
- if str == "acf_gun" then return "_acf_gun" end
- if str == "acf_ammo" then return "_acf_ammo" end
- if str == "acf_gearbox" then return "_acf_Gearbox" end
- if str == "acf_engine" then return "_acf_engine" end
- return str
- end
- function PLUGIN:BuildTable()
- local Table = {}
- for _,v in pairs (ents.GetAll()) do
- if v.Owner and IsValid(v.Owner)then
- local ply = v.Owner
- local SteamID = ply:UserID()
- if not Table[SteamID] then Table[SteamID] = {} end
- if not Table[SteamID][v:GetClass()] then
- Table[SteamID][v:GetClass()] = 1
- else
- Table[SteamID][v:GetClass()] = Table[SteamID][v:GetClass()] + 1
- end
- end
- end
- return Table
- end
- function PLUGIN:BuildDupeTable( Tbl )
- local Table = {}
- for _,v in pairs ( Tbl ) do
- if not Table[v.Class] then
- Table[v.Class] = 1
- else
- Table[v.Class] = Table[v.Class] + 1
- end
- end
- return Table
- end
- function PLUGIN:BuildString(ply, Table )
- local str = "#############################\n"..ply:Nick()..":\n#class: count / limit (-1 or 0 = unlimited) \n#"
- for name,count in pairs(Table) do
- if EV_AP_LIMITS[ply:EV_GetRank()] then
- local Class = GetClass(name)
- if EV_AP_LIMITS[ply:EV_GetRank()][Class] then
- str = str..name..": "..tostring(count).." / "..EV_AP_LIMITS[ply:EV_GetRank()][Class].."\n#"
- else
- local Limit = GetConVarNumber("sbox_max"..Class.."s")
- if string.Left(Class,9)=="gmod_wire" then Limit = GetConVarNumber("sbox_maxwire"..string.sub(Class,10,9999999).."s") end
- str = str..name..": "..tostring(count).." / "..Limit.."\n#"
- end
- else
- str = str..name..": "..tostring(count).."\n#"
- end
- end
- str = str.."############################\n"
- return str
- end
- function PLUGIN:Call( ply, args )
- if #args>0 then
- local target = evolve:FindPlayer( args[1], nil, false, false )[1]
- if not target then
- evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayersnoimmunity )
- return
- end
- local Table = self:BuildTable()
- local Str = self:BuildString(target, Table[target:UserID()] )
- if IsValid(ply) then
- net.Start ("EV_countstream")
- net.WriteString(Str)
- net.Send( ply )
- evolve:Notify( ply, evolve.colors.white, "list was send to your console")
- else
- Msg(Str)
- end
- else
- if ply and IsValid(ply) and ply:GetActiveWeapon().Mode and ply:GetActiveWeapon():GetMode() == "advdupe2" and ply.AdvDupe2.Entities then
- local Table = self:BuildDupeTable( ply.AdvDupe2.Entities )
- local Str = self:BuildString(ply, Table )
- net.Start ("EV_countstream")
- net.WriteString(Str)
- net.Send( ply )
- evolve:Notify( ply, evolve.colors.white, "list was send to your console")
- return
- end
- if ( ply:EV_HasPrivilege( "Count" ) ) then
- Table = self:BuildTable()
- local Str = ""
- for _,v in pairs (player.GetAll()) do
- local Str = self:BuildString(v, Table[v:UserID()] )
- if IsValid(ply) then
- net.Start ("EV_countstream")
- net.WriteString(Str)
- net.Send( ply )
- else
- Msg(Str)
- end
- end
- evolve:Notify( ply, evolve.colors.white, "list was send to your console")
- else
- local Table = self:BuildTable()
- local Str = self:BuildString(ply, Table[ply:UserID()] )
- net.Start ("EV_countstream")
- net.WriteString(Str)
- net.Send( ply )
- evolve:Notify( ply, evolve.colors.white, "list was send to your console")
- end
- end
- end
- if CLIENT then
- net.Receive( "EV_countstream", function()
- print(net:ReadString())
- end)
- end
- evolve:RegisterPlugin( PLUGIN )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement