This commit is contained in:
lifestorm
2024-08-04 23:12:27 +03:00
parent 0e770b2b49
commit ba1fc01b16
7084 changed files with 2173495 additions and 14 deletions

View File

@@ -0,0 +1,97 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PLUGIN = PLUGIN
DEFINE_BASECLASS( "base_anim" )
ENT.Base = "base_entity"
ENT.Type = "anim"
ENT.PrintName = "Cigarette"
ENT.Author = "Fruity"
ENT.Information = "A cigarette that smokes."
ENT.Category = "HL2 RP"
ENT.Editable = true
ENT.Spawnable = true
ENT.AdminSpawnable = true
ENT.AdminOnly = true
ENT.smokeDelay = 0
ENT.flexIndexAshes = 1
ENT.addValueAshes = 0.05
ENT.minValueAshes = 0
ENT.maxValueAshes = 0.5
ENT.flexIndexLength = 0
ENT.addValueLength = 0.01
ENT.minValueLength = 0
ENT.maxValueLength = 1
ENT.AutomaticFrameAdvance = true -- Must be set on client
function ENT:SpawnFunction( client, tr, ClassName )
if (!client:Alive()) then return false end
local base = ents.Create( ClassName )
base:SetParent(client)
base:SetOwner(client)
return base
end
function ENT:Initialize()
end
function ENT:ChangeSkinStateTimer()
PLUGIN:ChangeSkinStateTimer(self)
end
function ENT:CreateJetLengthTimer()
PLUGIN:CreateJetLengthTimer(self)
end
-- Cigarette gets smaller over time and ashes effect
function ENT:GetAshesValue()
return PLUGIN:GetAshesValue(self)
end
function ENT:GetLengthValue(currentLength)
return PLUGIN:GetLengthValue(self, currentLength)
end
function ENT:Think()
if (SERVER) then
PLUGIN:CigaretteThink(self)
end
end
function ENT:Draw()
if (!IsValid(self) or !IsValid(self:GetParent())) then return false end
if (self:GetParent():GetMoveType() == 8) then
return false
end
if (LocalPlayer() == self:GetParent() and !ix.option.Get("firstPersonCigarette", true)) then
if ix.config.Get("thirdperson") then
if !ix.option.Get("thirdpersonEnabled", false) then
return false
end
else
return false
end
end
self:DrawModel()
end

View File

@@ -0,0 +1,203 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PLUGIN = PLUGIN
ITEM.name = "Cigarette"
ITEM.description = "Ćmik."
ITEM.model = Model("models/willardnetworks/cigarettes/cigarette.mdl")
ITEM.width = 1
ITEM.height = 1
ITEM.junkCleanTime = 120
if (CLIENT) then
function ITEM:PopulateTooltip(tooltip)
local length = self:GetData("length", 0)
local panel = tooltip:AddRowAfter("name", "remaining tobacco")
panel:SetBackgroundColor(derma.GetColor("Warning", tooltip))
panel:SetText("Pozostały tytoń: "..(math.Round(math.Remap(length, 0, 1, 100, 0), 0)).."%")
panel:SizeToContents()
end
function ITEM:PaintOver(item, w, h)
local length = item:GetData("length", 0)
surface.SetDrawColor(length >= 1 and (Color(255, 110, 110, 100)) or (length < 1 and length != 0 and Color(255, 193, 110, 100)) or (Color(110, 255, 110, 100)))
surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
end
end
function ITEM:GetModelFlexes()
return {[0] = self:GetData("length", 0)}
end
function ITEM:CreateCigarette(client)
if ( SERVER ) then
PLUGIN:CreateCigarette(self, client)
end
end
function ITEM:CheckIfModelAllowed(client)
local faceIndex = client:FindBodygroupByName("face")
if string.find(client:GetModel(), "models/willardnetworks/citizens/") then
local headIndex = client:FindBodygroupByName("head")
if client:GetBodygroup(faceIndex) == 1 or client:GetBodygroup(headIndex) == 4 then
return false
end
end
if string.find(client:GetModel(), "models/thomask_110/") then
if client:GetBodygroup(faceIndex) == 3 or client:GetBodygroup(faceIndex) == 4 then
return false
end
end
if string.find(client:GetModel(), "models/willardnetworks/vortigaunt.mdl") and client:GetBodygroup(faceIndex) == 1 then
return false
end
if string.find(client:GetModel(), "models/wn7new/metropolice/") and client:GetBodygroup(client:FindBodygroupByName("Cp_Head")) > 0 then
return false
end
if string.find(client:GetModel(), "models/wn7new/metropolice_c8/") and client:GetBodygroup(client:FindBodygroupByName("Cp_Head")) > 0 then
return false
end
for _, v in pairs(PLUGIN.allowedModels) do
if string.find(client:GetModel(), v) then return true end
end
return false
end
function ITEM:OnCanRunSmoke()
local client = self.player
local length = self:GetData("length", 0)
if length >= 1 then return false end
if client and !self:CheckIfModelAllowed(client) then return false end
if math.Round(math.Remap(length, 0, 1, 100, 0), 0) == 0 then return false end
if self.entity then return false end
if client and client.cigarette and IsValid(client.cigarette) then return false end
if !self.cigaretteEnt then return true end
return false
end
function ITEM:OnRunSmoke()
local client = self.player
if !client then return false end
if (!client:Alive()) then return false end
self:CreateCigarette(client)
client:NotifyLocalized("Włożyłeś do ust papierosa. Użyj zapalniczki, aby go zapalić.")
end
function ITEM:OnRunStopSmoke(client, value, bRemove)
client = client or self.player
if !client then return false end
if (!client:Alive()) then return false end
if (value and !bRemove) then
self:SetData("length", value)
end
if IsValid(self.cigaretteEnt) and IsEntity(self.cigaretteEnt) then
if !value and !bRemove then
local length = self.cigaretteEnt:GetFlexWeight(self.cigaretteEnt.flexIndexLength)
self:SetData("length", length)
end
self.cigaretteEnt:Remove()
client.cigarette = nil
end
self.cigaretteEnt = nil
client:NotifyLocalized(self:GetData("length") == 1 and "Skończyłeś palić papierosa. Pozostał po nim tylko niedopałek." or "Wyjąłeś papierosa z ust.")
local itemID = self:GetID()
if bRemove then
self:Remove()
end
netstream.Start(client, "CigaretteSetClientEntity", itemID, nil, nil)
end
function ITEM:OnCanRunStopSmoke()
local length = self:GetData("length", 0)
if length >= 1 then return false end
if math.Round(math.Remap(length, 0, 1, 100, 0), 0) == 0 then return false end
if self.cigaretteEnt and IsEntity(self.cigaretteEnt) then return true end
if self.player and !self:CheckIfModelAllowed(self.player) then return false end
return false
end
function ITEM:SmokingFinished(client, value)
self:OnRunStopSmoke(client, value, true)
end
function ITEM:OnTransferred(curInv, inventory)
local client = self.player
if client and client.cigarette and IsEntity(client.cigarette) and client.cigarette.cigaretteItem and client.cigarette.cigaretteItem == self then
self:OnRunStopSmoke()
end
end
ITEM.functions.smoke = {
name = "Umieść w ustach",
tip = "Umieść papierosa w ustach.",
icon = "icon16/brick_add.png",
OnRun = function(item)
item:OnRunSmoke()
return false
end,
OnCanRun = function(item)
if item:OnCanRunSmoke() then return true end
return false
end
}
ITEM.functions.stopsmoke = {
name = "Wyjmij z ust",
tip = "Wyjmij papierosa z ust i zgaś go.",
icon = "icon16/brick_add.png",
OnRun = function(item)
item:OnRunStopSmoke()
return false
end,
OnCanRun = function(item)
if item:OnCanRunStopSmoke() then return true end
return false
end
}
if (CLIENT) then
netstream.Hook("CigaretteSetClientEntity", function(itemID, entIndex, isLit)
if itemID and ix.item.instances[itemID] then
ix.item.instances[itemID].cigaretteEnt = entIndex or nil
end
LocalPlayer().cigarette = entIndex or nil
if !LocalPlayer().cigarette then return end
LocalPlayer().cigarette.isLit = isLit or nil
end)
end

View File

@@ -0,0 +1,61 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.name = "Lighter"
ITEM.base = "base_tools"
ITEM.model = Model("models/willardnetworks/cigarettes/lighter.mdl")
ITEM.width = 1
ITEM.height = 1
ITEM.description = "Podręczne urządzenie przeznaczone do rozpalania płomienia w celu podpalenia przedmiotów."
function ITEM:OnRunLight()
local client = self.player
if !client then return end
if !client:Alive() then return end
if client.cigarette and IsEntity(client.cigarette) and client.cigarette.cigaretteItem and
client.cigarette.cigaretteItem.GetID and ix.item.instances[client.cigarette.cigaretteItem:GetID()] then
client.cigarette.isLit = true
netstream.Start(client, "CigaretteSetClientEntity", client.cigarette.cigaretteItem:GetID(), client.cigarette, true)
end
client:NotifyLocalized("Zacząłeś palić papierosa.")
client:EmitSound(self.useSound)
self:DamageDurability(1)
end
function ITEM:OnCanRunLight()
local client = self.player
if !client then return end
if !client:Alive() then return end
if client.cigarette and !client.cigarette.isLit then return true end
return false
end
ITEM.functions.light = {
name = "Zapal papierosa",
tip = "Zapal papierosa",
icon = "icon16/brick_add.png",
OnRun = function(item)
item:OnRunLight()
return false
end,
OnCanRun = function(item)
if item:OnCanRunLight() then return true end
return false
end
}

View File

@@ -0,0 +1,13 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.name = "Papieros"
ITEM.description = "Podobno palenie jest niezdrowe, ale czy w tych czasach jest to ważne?"

View File

@@ -0,0 +1,21 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.name = "Cygaretki Goodfella"
ITEM.model = Model("models/willardnetworks/cigarettes/cigarette_pack_goodfella.mdl")
ITEM.description = "Paczka cygaretek wysokiej jakości, w której mieści się ich 8 sztuk."
ITEM.allowNesting = true
ITEM.restriction = {"cigarette"}
ITEM.noEquip = true
function ITEM:OnBagInitialized(inventory)
inventory:Add("cigarette", 8)
end

View File

@@ -0,0 +1,33 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.name = "Paczka papierosów"
ITEM.model = Model("models/willardnetworks/cigarettes/cigarette_pack_1.mdl")
ITEM.description = "Paczka papierosów, w której mieści się 8 papierosów."
ITEM.allowNesting = true
ITEM.restriction = {"cigarette", "lighter"}
ITEM.noEquip = true
function ITEM:GetName()
return self:GetData("relabeled", false) and "Paczka papierosów ze zmienioną etykietą" or "Paczka papiersów - Edycja Benefaktor"
end
function ITEM:GetDescription()
return self:GetData("relabeled", false) and "Paczka papierosów ze zmienioną etykietą, w której mieści się 8 papierosów." or "Paczka papierosów wydana przez Kombinat, w której mieści się 8 papierosów."
end
function ITEM:GetModel()
return self:GetData("relabeled", false) and "models/willardnetworks/cigarettes/cigarette_pack_1.mdl" or "models/willardnetworks/cigarettes/cigarette_pack.mdl"
end
function ITEM:OnBagInitialized(inventory)
inventory:Add("cigarette", 8)
end

View File

@@ -0,0 +1,28 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.name = "Plastikowa zapalniczka"
ITEM.model = Model("models/willardnetworks/cigarettes/lighter.mdl")
ITEM.description = "Tania plastikowa zapalniczka, przydatna do zapalania papierosów."
ITEM.useSound = "willardnetworks/cigarettes/normal.wav"
ITEM.category = "Tools"
ITEM.maxDurability = 8
ITEM.holdData = {
vectorOffset = {
right = 0,
up = 0,
forward = 0
},
angleOffset = {
right = 0,
up = 0,
forward = 0
},
}

View File

@@ -0,0 +1,34 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.name = "Zapalniczka Zippo"
ITEM.model = Model("models/willardnetworks/cigarettes/zippo.mdl")
ITEM.description = "Zapalniczka Zippo to klasyczny model zapalniczki na benzynę, przydatna do zapalania papierosów."
ITEM.useSound = "willardnetworks/cigarettes/zippo.wav"
ITEM.maxDurability = 24
ITEM.width = 1
ITEM.height = 1
ITEM.iconCam = {
pos = Vector(-509.64, -427.61, 310.24),
ang = Angle(24.98, 400.03, 0),
fov = 0.29
}
ITEM.holdData = {
vectorOffset = {
right = 0,
up = 0,
forward = 0
},
angleOffset = {
right = 0,
up = 0,
forward = 0
},
}

View File

@@ -0,0 +1,49 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local ix = ix
local PLUGIN = PLUGIN
PLUGIN.name = "Cigarettes"
PLUGIN.author = "Fruity"
PLUGIN.description = "Adds non PAC3 cigarettes."
ix.util.Include("sv_plugin.lua")
PLUGIN.allowedModels = {
[1] = "models/willardnetworks/citizens/",
[2] = "models/willardnetworks/vortigaunt.mdl",
[3] = "models/wn7new/metropolice/",
[4] = "models/wn7new/metropolice_c8/",
[5] = "models/thomask_110/"
}
if (CLIENT) then
ix.option.Add("firstPersonCigarette", ix.type.bool, true, {
category = "Cigarettes"
})
end
ix.lang.AddTable("english", {
optFirstPersonCigarette = "Pokaż papierosa w pierwszej osobie",
optdFirstPersonCigarette = "Przełącza, czy papieros ma być wyświetlany w pierwszej osobie, czy nie."
})
ix.lang.AddTable("spanish", {
optFirstPersonCigarette = "Mostrar el Cigarro en Primera Persona",
optdFirstPersonCigarette = "Alterna si quieres que el cigarro se muestre en primera persona o no."
})
ix.lang.AddTable("polish", {
optFirstPersonCigarette = "Pokaż papierosa w pierwszej osobie",
optdFirstPersonCigarette = "Przełącza, czy papieros ma być wyświetlany w pierwszej osobie, czy nie."
})

View File

@@ -0,0 +1,246 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local ents = ents
local tonumber = tonumber
local netstream = netstream
local timer = timer
local IsValid = IsValid
local IsEntity = IsEntity
local string = string
local tostring = tostring
local math = math
local Vector = Vector
local CurTime = CurTime
local PLUGIN = PLUGIN
function PLUGIN:CreateCigarette(item, client)
local entity = ents.Create("ix_cigarette")
entity:SetOwner(client)
entity:SetParent(client)
entity:Fire("SetParentAttachment", "cigarette", 0.01)
entity:SetModel( "models/willardnetworks/cigarettes/cigarette.mdl" )
entity:SetModelScale(0.7)
entity:CreateJetLengthTimer()
entity:ChangeSkinStateTimer()
entity:Spawn()
local length = item:GetData("length", 0)
entity:SetFlexWeight(entity.flexIndexLength, tonumber(length))
client.cigarette = entity
item.cigaretteEnt = entity
entity.cigaretteItem = item
netstream.Start(client, "CigaretteSetClientEntity", item:GetID(), entity, false)
end
function PLUGIN:CreateCigaretteSmoke(entity)
entity.smoke = ents.Create( "env_smokestack" )
entity.smoke:SetParent(entity:GetParent())
entity.smoke:Fire("SetParentAttachment", "cigarette_glow", 0.01)
entity.smoke:SetKeyValue("InitialState", "1")
entity.smoke:SetKeyValue("WindAngle", "90 0 0")
entity.smoke:SetKeyValue("WindSpeed", "0.6")
entity.smoke:SetKeyValue("rendercolor", "162 162 162")
entity.smoke:SetKeyValue("renderamt", "6") -- alpha
entity.smoke:SetKeyValue("SmokeMaterial", "particle/smokesprites_0001.vmt")
entity.smoke:SetKeyValue("BaseSpread", "0.2")
entity.smoke:SetKeyValue("SpreadSpeed", "0.4")
entity.smoke:SetKeyValue("Speed", "1.4")
entity.smoke:SetKeyValue("StartSize", "0.3")
entity.smoke:SetKeyValue("EndSize", "1.5")
entity.smoke:SetKeyValue("roll", "32")
entity.smoke:SetKeyValue("Rate", "24")
entity.smoke:SetKeyValue("twist", "32")
entity:DeleteOnRemove(entity.smoke)
entity.smoke:Spawn()
entity.smoke:Activate()
timer.Simple(0.25, function()
if !IsValid(entity) then return end
if !IsEntity(entity) then return end
if entity.cigaretteItem and entity.cigaretteItem.GetID and ix.item.instances[entity.cigaretteItem:GetID()] then
local lastSmokePos = tonumber(string.Right(tostring(math.Round(entity:GetFlexWeight(entity.flexIndexLength), 2)), 2))
if entity.cigaretteItem:GetData("length", 0) > 0 then
self:ChangeSmokePos(entity, entity:GetParent(), lastSmokePos)
end
end
end)
end
function PLUGIN:ChangeSkinStateTimer(entity)
if timer.Exists("ChangeSkinStateCigarette_"..entity:EntIndex()) then timer.Remove("ChangeSkinStateCigarette_"..entity:EntIndex()) end
timer.Create("ChangeSkinStateCigarette_"..entity:EntIndex(), math.random(3, 7), 0, function()
if !IsValid(entity) then timer.Remove("ChangeSkinStateCigarette_"..entity:EntIndex()) return end
local parent = entity:GetParent()
if !IsValid(parent) then timer.Remove("ChangeSkinStateCigarette_"..entity:EntIndex()) return end
if parent.Alive and !parent:Alive() then timer.Remove("ChangeSkinStateCigarette_"..entity:EntIndex()) return end
if !entity.state then entity.state = 1 end
if (entity.state or 0) != 2 then
timer.Adjust("ChangeSkinStateCigarette_"..entity:EntIndex(), 2, 0, nil)
else
timer.Adjust("ChangeSkinStateCigarette_"..entity:EntIndex(), math.random(3, 7), 0, nil)
end
entity.state = ((entity.state or 0) > 1 and 1 or 2)
entity:SetSkin(entity.state)
if entity.cigaretteItem and entity.cigaretteItem.GetID and ix.item.instances[entity.cigaretteItem:GetID()] then
local length = entity:GetFlexWeight(entity.flexIndexLength)
entity.cigaretteItem:SetData("length", length)
end
end)
end
function PLUGIN:CreateJetLengthTimer(entity)
if timer.Exists("ChangeJetLengthCigarette_"..entity:EntIndex()) then timer.Remove("ChangeJetLengthCigarette_"..entity:EntIndex()) end
timer.Create("ChangeJetLengthCigarette_"..entity:EntIndex(), 0.2, 0, function()
if !IsValid(entity) then timer.Remove("ChangeJetLengthCigarette_"..entity:EntIndex()) return end
local parent = entity:GetParent()
if !IsValid(parent) then timer.Remove("ChangeJetLengthCigarette_"..entity:EntIndex()) return end
if parent.Alive and !parent:Alive() then timer.Remove("ChangeJetLengthCigarette_"..entity:EntIndex()) return end
if IsValid(entity.smoke) and parent:GetMoveType() == 8 then entity.smoke:Remove() return end
if IsValid(entity) and (!IsValid(entity.smoke) or (IsValid(entity.smoke) and !entity.smoke:GetInternalVariable("JetLength"))) then
if parent.cigarette and parent.cigarette.isLit then self:CreateCigaretteSmoke(entity) return end
end
if IsValid(entity.smoke) then
if parent:GetVelocity():Length2D() > parent:GetWalkSpeed() then
if math.Round(tonumber(entity.smoke:GetInternalVariable("JetLength")), 1) != 0.2 then entity.smoke:SetKeyValue("JetLength", "0.2") end
else
if tonumber(entity.smoke:GetInternalVariable("JetLength")) != 10 then entity.smoke:SetKeyValue("JetLength", "10") end
end
end
if entity.cigaretteItem and entity.cigaretteItem.GetID and ix.item.instances[entity.cigaretteItem:GetID()] then
if !parent then return end
if !entity.cigaretteItem:CheckIfModelAllowed(parent) then entity.cigaretteItem:OnRunStopSmoke(parent) end
end
end)
end
function PLUGIN:ChangeSmokePos(entity, parent, fixedPos)
if (IsValid(entity) and IsEntity(entity) and entity) then
if (entity.smoke and IsEntity(entity.smoke) and parent and IsValid(parent)) then
if parent:GetMoveType() != 8 then
if fixedPos then
fixedPos = (fixedPos * 0.001) * 10
entity.smoke:SetPos(entity.smoke:GetPos() + Vector(-fixedPos * parent:GetForward(), 0, 0))
return
end
entity.smoke:SetPos(entity.smoke:GetPos() + Vector(-0.001 * parent:GetForward(), 0, 0))
end
end
end
end
function PLUGIN:CigaretteThink(entity)
local currentWeightLength = entity:GetFlexWeight( entity.flexIndexLength )
local parent = entity:GetParent()
if !parent.cigarette then return end
if !parent.cigarette.isLit then return end
if currentWeightLength >= entity.maxValueLength then
if (SERVER) then
if IsValid(entity) and IsEntity(entity) then
if entity.cigaretteItem and entity.cigaretteItem.SmokingFinished then
entity.cigaretteItem:SmokingFinished(entity:GetParent(), 1)
end
end
end
return
end
if CurTime() < entity.smokeDelay then return end
if parent and parent:GetMoveType() == 8 then return end
if parent and !parent:Alive() or !parent then
if (SERVER) then
if IsValid(entity) and IsEntity(entity) then
entity:Remove()
end
end
return
end
self:ChangeSmokePos(entity, parent)
-- Length
entity:SetFlexWeight( entity.flexIndexLength, entity:GetLengthValue(currentWeightLength) )
-- Ashes
entity:SetFlexWeight( entity.flexIndexAshes, entity:GetAshesValue() )
entity.smokeDelay = CurTime() + 3
entity:NextThink( CurTime() ) -- Set the next think to run as soon as possible, i.e. the next frame.
return true -- Apply NextThink call
end
-- Cigarette gets smaller over time and ashes effect
function PLUGIN:GetAshesValue(entity)
local currentWeightAshes = entity:GetFlexWeight( entity.flexIndexAshes )
if currentWeightAshes < 0.5 or currentWeightAshes < 0.1 then
return math.Clamp( currentWeightAshes + entity.addValueAshes, entity.minValueAshes, entity.maxValueAshes)
else
return 0.1
end
end
function PLUGIN:GetLengthValue(entity, currentLength)
return math.Clamp( currentLength + entity.addValueLength, entity.minValueLength, entity.maxValueLength )
end
function PLUGIN:PlayerDisconnected(client)
if (client.cigarette) then
local cigaretteItem = client.cigarette.cigaretteItem
if cigaretteItem then
cigaretteItem:OnRunStopSmoke()
end
end
end
function PLUGIN:CanPlayerUseCharacter(client, character)
if (client.cigarette and IsValid(client.cigarette)) then
return false, "You currently have a cigarette in your mouth, you cannot switch characters whilst having so!"
end
end
function PLUGIN:PlayerDeath(client)
if (client.cigarette) then
local cigaretteItem = client.cigarette.cigaretteItem
if (cigaretteItem) then
cigaretteItem:OnRunStopSmoke()
if (cigaretteItem.cigaretteEnt) then cigaretteItem.cigaretteEnt:Remove() end
if (client.cigarette) then client.cigarette = nil end
end
end
end