Skip to content
This repository was archived by the owner on Oct 8, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

idée.txt
7 changes: 0 additions & 7 deletions lua/autorun/vikrlaundry_autorun.lua

This file was deleted.

19 changes: 16 additions & 3 deletions lua/autorun/vikrlaundry_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,26 @@ LaundryConfig.DirtyCartMaxCloth = 20
LaundryConfig.MoneyPerCloth = 10

-- <clothes> = How many clean clothes are in the cart (default: "<clothes> clean clothes")
LaundryConfig.PhraseCleanClothes = "<clothes> clean clothes"
LaundryConfig.PhraseCleanClothes = "%d clean clothes"
-- Example : If there is 6 clean clothes, "Clean clothes : <clothes>" will show "Clean clothes : 6"

-- <clothes> = How many dirty clothes are in the cart (default: "<clothes> dirty clothes")
LaundryConfig.PhraseDirtyClothes = "<clothes> dirty clothes"
LaundryConfig.PhraseDirtyClothes = "%d dirty clothes"
-- Example : If there is 9 dirty clothes, "Clean clothes : <clothes>" will show "Dirty clothes : 9"

-- <money> = Money received, <clothes> = clothes washed (default: "You received <money> for washing <clothes> clothes")
LaundryConfig.PhraseNotifyText = "You received <money> for washing <clothes> clothes"
LaundryConfig.PhraseNotifyText = "You received %s for washing %d clothes"
-- Example : "You got <money> for <clothes> clothes" will show "You got 60$ for 6 clothes"

LaundryConfig.PhraseCantInteract = "You cannot interact with this"

-- true = Blacklist teams, false = Whitelist teams (default: true)
LaundryConfig.BlackOrWhiteList = true
-- Example : If the value is true, all teams in the configuration below will be blacklisted of the addon

-- Name of white/blacklisted teams
LaundryConfig.Teams = {
["Guard"] = true,
["Chief Guard"] = true,
["Director"] = true
}
18 changes: 10 additions & 8 deletions lua/entities/clean_laundry_cart/cl_init.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
include("shared.lua")

local colWhite = Color(255, 255, 255)
local superAngle = Angle(0, 0, 90)

function ENT:Draw()
self:DrawModel()
self:DrawModel()

local pos = self:LocalToWorld(self:OBBCenter())
local ang = self:GetAngles()
if self:GetPos():DistToSqr(LocalPlayer():GetPos()) > 500 ^ 2 then return end

local phrase = string.gsub(LaundryConfig.PhraseCleanClothes, "<clothes>", self:GetClothesNumber())
local ang = self:GetAngles()

cam.Start3D2D(pos + (ang:Up() * 5) + (ang:Right() * 21), ang + Angle(0,0,90), 0.25)
draw.SimpleText(tostring(phrase), "DermaLarge", 0, 0, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
cam.End3D2D()
end
cam.Start3D2D(self:LocalToWorld(self:OBBCenter()) + (ang:Up() * 5) + (ang:Right() * 21), ang + superAngle, 0.25)
draw.SimpleText(string.format(LaundryConfig.PhraseCleanClothes, self:GetClothesNumber()), "DermaLarge", 0, 0, colWhite, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
cam.End3D2D()
end
65 changes: 22 additions & 43 deletions lua/entities/clean_laundry_cart/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@ AddCSLuaFile("shared.lua")

include("shared.lua")

function ENT:SpawnFunction(ply, tr, cn)
local ang = ply:GetAngles()
local ent = ents.Create(cn)
ent:SetPos(tr.HitPos + tr.HitNormal + Vector(0,0,60))
ent:SetAngles(Angle(0, ang.y, 0) - Angle(0, 90, 0))
ent:Spawn()

return ent
end

function ENT:Initialize()
self:SetModel("models/props_wasteland/laundry_cart001.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
Expand All @@ -21,57 +11,46 @@ function ENT:Initialize()

self:SetUseType(SIMPLE_USE)

local phys = self:GetPhysicsObject()
local phys = self:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end

function ENT:Use(act, cal)
if not self.ClothTable then return end
if not (#self.ClothTable > 0) then return end
if not cal:IsValid() then return end
local numCloth = #self.ClothTable

cal:addMoney(#self.ClothTable * LaundryConfig.MoneyPerCloth)
if not self.ClothTable or numCloth < 1 then return end

local phrase = string.gsub(LaundryConfig.PhraseNotifyText, "<clothes>", tostring(#self.ClothTable))
phrase = string.gsub(phrase, "<money>", tostring(#self.ClothTable * LaundryConfig.MoneyPerCloth) .. GAMEMODE.Config.currency)
if (LaundryConfig.BlackOrWhiteList and LaundryConfig.Teams[team.GetName(cal:Team())]) or (not LaundryConfig.BlackOrWhiteList and not LaundryConfig.Teams[team.GetName(cal:Team())]) then
DarkRP.notify(cal, 1, 5, LaundryConfig.PhraseCantInteract)
return
end

DarkRP.notify(cal, 0, 7, phrase)
local reward = numCloth * LaundryConfig.MoneyPerCloth

cal:addMoney(reward)

DarkRP.notify(cal, 0, 7, string.format(LaundryConfig.PhraseNotifyText, DarkRP.formatMoney(reward), numCloth))

for _, ent in pairs(self.ClothTable) do
for index, ent in pairs(self.ClothTable) do
self.ClothTable[index] = nil
ent:Remove()
end
end

function ENT:Think()
local pos = self:LocalToWorld(self:OBBCenter())
local ang = self:GetAngles()
local entnum = 0
self.ClothTable = { }
self.ClothTable = {}
local x, y = self:GetModelBounds()

for _, ent in pairs(ents.FindInSphere(pos + (ang:Forward() * 20), 20)) do
if ent:GetClass() == "cloth" and not table.HasValue(self.ClothTable, ent) then
if ent:GetClean() then
table.insert(self.ClothTable, ent)
end
for _, ent in pairs(ents.FindInBox(self:LocalToWorld(x + Vector(10, 0, 10)), self:LocalToWorld(y - Vector(10, 0, 0)))) do
if ent:GetClass() == "cloth" and ent:GetClean() and not table.HasValue(self.ClothTable, ent) then
table.insert(self.ClothTable, ent)
end
end

for _, ent in pairs(ents.FindInSphere(pos - (ang:Forward() * 20), 20)) do
if ent:GetClass() == "cloth" then
if ent:GetClean() and not table.HasValue(self.ClothTable, ent) then
table.insert(self.ClothTable, ent)
end
end
end

for _, ent in pairs(self.ClothTable) do
entnum = entnum + 1
end
self:SetClothesNumber(#self.ClothTable)

self:SetClothesNumber(entnum)

self:NextThink(CurTime() + 0.1)
self:NextThink(CurTime() + 1)
return true
end
end
4 changes: 2 additions & 2 deletions lua/entities/clean_laundry_cart/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ ENT.Spawnable = true
ENT.AdminSpawnable = false

function ENT:SetupDataTables()
self:NetworkVar("Float", 0, "ClothesNumber")
end
self:NetworkVar("Int", 0, "ClothesNumber")
end
4 changes: 2 additions & 2 deletions lua/entities/cloth/cl_init.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include("shared.lua")

function ENT:Draw()
self:DrawModel()
end
self:DrawModel()
end
26 changes: 7 additions & 19 deletions lua/entities/cloth/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,20 @@ include("shared.lua")
function ENT:SpawnFunction(ply, tr, cn)
local ent = ents.Create(cn)
ent:SetPos(tr.HitPos + tr.HitNormal)
if math.random(1, 4) == 4 then
ent:SetClothType(2)
else
ent:SetClothType(1)
end
ent:SetClothType(math.random(1, 4) == 4 and 2 or 1)
ent:SetClean(false)
ent:Spawn()

return ent
end

local colOrange = Color(255,125,0)
local colBlue = Color(0,50,255)

function ENT:Initialize()
self:SetModel("models/props_junk/garbage_newspaper001a.mdl")

if not self:GetClean() then
self:SetMaterial("models/props_pipes/GutterMetal01a")
else
self:SetMaterial("models/debug/debugwhite")
end

if self:GetClothType() == 1 then
self:SetColor(Color(255,125,0))
elseif self:GetClothType() == 2 then
self:SetColor(Color(0,50,255))
end

self:SetMaterial(self:GetClean() and "models/debug/debugwhite" or "models/props_pipes/GutterMetal01a")
self:SetColor(self:GetClothType() == 1 and colOrange or colBlue)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
Expand All @@ -40,4 +28,4 @@ function ENT:Initialize()
if (phys:IsValid()) then
phys:Wake()
end
end
end
4 changes: 2 additions & 2 deletions lua/entities/cloth/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ENT.AdminSpawnable = false

function ENT:SetupDataTables()
self:NetworkVar("Bool", 0, "Clean")
self:NetworkVar("Float", 1, "ClothType") -- 1 = prisonnier, 2 = garde
self:NetworkVar("Int", 1, "ClothType") -- 1 = prisonnier, 2 = garde

if SERVER then
self:NetworkVarNotify("Clean", self.OnClothChangeState)
end
end
end
18 changes: 10 additions & 8 deletions lua/entities/dirty_laundry_cart/cl_init.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
include("shared.lua")

local colWhite = Color(255, 255, 255)
local superAngle = Angle(0, 0, 90)

function ENT:Draw()
self:DrawModel()
self:DrawModel()

local pos = self:LocalToWorld(self:OBBCenter())
local ang = self:GetAngles()
if self:GetPos():DistToSqr(LocalPlayer():GetPos()) > 500 ^ 2 then return end

local phrase = string.gsub(LaundryConfig.PhraseDirtyClothes, "<clothes>", self:GetClothesNumber())
local ang = self:GetAngles()

cam.Start3D2D(pos + (ang:Up() * 5) + (ang:Right() * 25), ang + Angle(0, 0, 90), 0.25)
draw.SimpleText(tostring(phrase), "DermaLarge", 0, 0, Color(255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
cam.End3D2D()
end
cam.Start3D2D(self:LocalToWorld(self:OBBCenter()) + (ang:Up() * 5) + (ang:Right() * 25), ang + superAngle, 0.25)
draw.SimpleText(string.format(LaundryConfig.PhraseDirtyClothes, self:GetClothesNumber()), "DermaLarge", 0, 0, colWhite, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
cam.End3D2D()
end
28 changes: 7 additions & 21 deletions lua/entities/dirty_laundry_cart/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@ AddCSLuaFile("shared.lua")

include("shared.lua")

function ENT:SpawnFunction(ply, tr, cn)
local ang = ply:GetAngles()
local ent = ents.Create(cn)
ent:SetPos(tr.HitPos + tr.HitNormal + Vector(0,0,40))
ent:SetAngles(Angle(0, ang.y, 0) - Angle(0, 90, 0))
ent:Spawn()

return ent
end

function ENT:Initialize()
self:SetModel("models/props_wasteland/laundry_basket001.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
Expand All @@ -33,6 +23,11 @@ function ENT:Initialize()
end

function ENT:Use(act, cal)
if (LaundryConfig.BlackOrWhiteList and LaundryConfig.Teams[team.GetName(cal:Team())]) or (not LaundryConfig.BlackOrWhiteList and not LaundryConfig.Teams[team.GetName(cal:Team())]) then
DarkRP.notify(cal, 1, 5, LaundryConfig.PhraseCantInteract)
return
end

if self:GetClothesNumber() <= 0 then return end

local pos = self:LocalToWorld(self:OBBCenter())
Expand All @@ -42,24 +37,15 @@ function ENT:Use(act, cal)
if not cloth:IsValid() then return end
cloth:SetPos(pos + (ang:Up() * 30))
cloth:SetAngles(self:GetAngles())
if math.random(1, 4) == 4 then
cloth:SetClothType(2)
else
cloth:SetClothType(1)
end
cloth:SetClothType(math.random(1, 4) == 4 and 2 or 1)
cloth:SetClean(false)
cloth:Spawn()

self:SetClothesNumber(self:GetClothesNumber() - 1)
end

function ENT:Think()
self:NextThink(CurTime())
return true
end

function ENT:OnRemove()
if timer.Exists("AddClothTimer"..self:EntIndex()) then
timer.Remove("AddClothTimer"..self:EntIndex())
end
end
end
4 changes: 2 additions & 2 deletions lua/entities/dirty_laundry_cart/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ ENT.Spawnable = true
ENT.AdminSpawnable = false

function ENT:SetupDataTables()
self:NetworkVar("Float", 0, "ClothesNumber")
end
self:NetworkVar("Int", 0, "ClothesNumber")
end
42 changes: 16 additions & 26 deletions lua/entities/washing_machine/cl_init.lua
Original file line number Diff line number Diff line change
@@ -1,32 +1,22 @@
include("shared.lua")
include("autorun/vikrlaundry_config.lua")

function ENT:Draw()
self:DrawModel()

local pos = self:LocalToWorld(self:OBBCenter())
local ang = self:GetAngles()
ang:RotateAroundAxis(ang:Up(), 90)
ang:RotateAroundAxis(ang:Forward(), 90)
local color = Color(255, 0, 0)
local x, y, w, h = 0, 0, 30, 30
local colBlack = Color(10, 10, 10, 100)
local colRed = Color(255, 0, 0)
local colGreen = Color(0, 255, 0)

if self:GetWashing() then
color = Color(0, 255, 0)
end
local x, y, w, h = 0, 0, 30, 30

cam.Start3D2D(pos + (ang:Up() * 20.75) + (ang:Forward() * 27.5) + (ang:Right() * 12.5), ang, 0.2)
draw.RoundedBox(0, x - w / 2, y - h / 2, w + 2, h + 2, Color(10, 10, 10, 100))
draw.RoundedBox(0, x - w / 2 + 1, y - h / 2 + 1, w, h, color)
cam.End3D2D()
end

function ENT:Think()
if not self.ClothModel then return end
function ENT:Draw()
self:DrawModel()

self.ClothModel:SetPos(self:LocalToWorld(self:OBBCenter()))
if self:GetPos():DistToSqr(LocalPlayer():GetPos()) > 500 ^ 2 then return end

if not self:GetWashing() then
self.ClothModel:Remove()
end
end
local ang = self:GetAngles()
ang:RotateAroundAxis(ang:Up(), 90)
ang:RotateAroundAxis(ang:Forward(), 90)

cam.Start3D2D(self:LocalToWorld(self:OBBCenter()) + (ang:Up() * 20.75) + (ang:Forward() * 27.5) + (ang:Right() * 12.5), ang, 0.2)
draw.RoundedBox(0, x - w / 2, y - h / 2, w + 2, h + 2, colBlack)
draw.RoundedBox(0, x - w / 2 + 1, y - h / 2 + 1, w, h, self:GetWashing() and colGreen or colRed)
cam.End3D2D()
end
Loading