- Joined
- Mar 16, 2017
- Messages
- 1,435
- Solutions
- 158
- Reaction score
- 2,016
- Location
- London
- GitHub
- MillhioreBT
- Twitch
- millhiorebt
This system is similar to the [TFS 1.5] Simple Aura System I published some time ago, but this time it's purely cosmetic. Essentially, by equipping certain pre-defined items in the configuration, you will automatically gain a colored square that appears at configurable intervals.
Fully optimized by not using
You are free to add any benefit or edit it to your liking, use your imagination
I first saw this system on a server called marlborowar.
Fully optimized by not using
GlobalEvent
or addEvent
, neither of which was necessary for this case.data/scripts/square_colour.lua
Lua:
--[[
Square Colour System
By: 𝓜𝓲𝓵𝓵𝓱𝓲𝓸𝓻𝓮 𝓑𝓣
Version: 1.0
TFS 1.5
]]--
local squareInterval = 5 -- seconds
local squareColour = TEXTCOLOR_SKYBLUE
local equipaments = {
[CONST_SLOT_HEAD] = 2493,
[CONST_SLOT_ARMOR] = 2494,
[CONST_SLOT_LEGS] = 2495,
[CONST_SLOT_FEET] = 2195
}
local ec = EventCallback
function ec.onInventoryUpdate(player, item, slot, equip)
local equipamentId = equipaments[slot]
if not equipamentId then
return
end
if not equip then
if item:getId() == equipamentId then
player:unregisterEvent("SquareColour")
end
return
end
for s, id in pairs(equipaments) do
if s ~= slot then
local sItem = player:getSlotItem(s)
if not sItem or sItem:getId() ~= id then
player:unregisterEvent("SquareColour")
return
end
end
end
player:registerEvent("SquareColour")
end
ec:register()
local intervals = {}
local squareEvent = CreatureEvent("SquareColour")
function squareEvent.onThink(player)
local playerId = player:getId()
local timeNow = os.time()
if not intervals[playerId] then
intervals[playerId] = timeNow
end
if timeNow - intervals[playerId] >= squareInterval then
intervals[playerId] = timeNow + squareInterval
for _, p in pairs(Game.getSpectators(player:getPosition(), false, true)) do
p:sendCreatureSquare(player, squareColour)
end
end
return true
end
squareEvent:register()
You are free to add any benefit or edit it to your liking, use your imagination
I first saw this system on a server called marlborowar.