Files
wnsrc/gamemodes/terrortown/entities/entities/ttt_credit_adjust.lua
lifestorm 9c918c46e5 Upload
2024-08-04 23:12:27 +03:00

47 lines
1.0 KiB
Lua

--[[
| 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/
--]]
ENT.Type = "point"
ENT.Base = "base_point"
ENT.Credits = 0
function ENT:KeyValue(key, value)
if key == "OnSuccess" or key == "OnFail" then
self:StoreOutput(key, value)
elseif key == "credits" then
self.Credits = tonumber(value) or 0
if not tonumber(value) then
ErrorNoHalt(tostring(self) .. " has bad 'credits' setting.\n")
end
end
end
function ENT:AcceptInput(name, activator)
if name == "TakeCredits" then
if IsValid(activator) and activator:IsPlayer() then
if activator:GetCredits() >= self.Credits then
activator:SubtractCredits(self.Credits)
self:TriggerOutput("OnSuccess", activator)
else
self:TriggerOutput("OnFail", activator)
end
end
return true
end
end