This commit is contained in:
lifestorm
2024-08-04 23:54:45 +03:00
parent 8064ba84d8
commit 6a58f406b1
7522 changed files with 4011896 additions and 15 deletions

View File

@@ -0,0 +1,101 @@
--[[
| 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
PLUGIN.waypoints = {}
function PLUGIN:HUDPaint()
if (!hook.Run("CanPlayerSeeWaypoints", LocalPlayer())) then
return
end
local height = draw.GetFontHeight("BudgetLabel")
local clientPos = LocalPlayer():EyePos()
for index, waypoint in pairs(self.waypoints) do
if (waypoint.time < CurTime()) then
self.waypoints[index] = nil
continue
end
local screenPos = waypoint.pos:ToScreen()
local color = waypoint.color
local text = waypoint.text
local x, y = screenPos.x, screenPos.y
surface.SetDrawColor(color)
surface.SetMaterial(ix.util.GetMaterial("willardnetworks/waypoint1.png"))
surface.DrawTexturedRectRotated(x, y, 50, 50, CurTime() * -150)
surface.SetMaterial(ix.util.GetMaterial("willardnetworks/waypoint2.png"))
surface.DrawTexturedRectRotated(x, y, 50, 50, CurTime() * 150)
surface.SetMaterial(ix.util.GetMaterial("willardnetworks/waypoint3.png"))
surface.DrawTexturedRectRotated(x, y, 50, 50, CurTime() * -150)
surface.SetMaterial(ix.util.GetMaterial("willardnetworks/waypoint4.png"))
surface.DrawTexturedRectRotated(x, y, 50, 50, CurTime() * 150)
surface.SetFont("BudgetLabel")
surface.SetTextColor(color)
local width = surface.GetTextSize(text)
surface.SetTextPos(x - width / 2, y - 30 - height)
surface.DrawText(text)
if (!waypoint.noDistance) then
local distanceText = tostring(math.Round(clientPos:Distance(waypoint.pos) * 0.01905, 2)) .. "m"
width = surface.GetTextSize(distanceText)
surface.SetTextPos(x - width / 2, y + 30)
surface.DrawText(distanceText)
end
end
end
net.Receive("SetupWaypoints", function()
local bWaypoints = net.ReadBool()
if (!bWaypoints) then
PLUGIN.waypoints = {}
return
end
local data = net.ReadTable()
for index, waypoint in pairs(data) do
local text = waypoint.text
-- check for any phrases and replace the text
if (text:sub(1, 1) == "@") then
waypoint.text = ":: " .. L(text:sub(2), waypoint.arguments and unpack(waypoint.arguments) or nil) .. " ::"
else
waypoint.text = ":: " .. text .. " ::"
end
data[index] = waypoint
end
PLUGIN.waypoints = data
end)
net.Receive("UpdateWaypoint", function()
local data = net.ReadTable()
if (data[2] != nil) then
local text = data[2].text
-- check for any phrases and replace the text
if (text:sub(1, 1) == "@") then
data[2].text = ":: " .. L(text:sub(2), data[2].arguments and unpack(data[2].arguments) or nil) .. " ::"
else
data[2].text = ":: " .. text .. " ::"
end
end
PLUGIN.waypoints[data[1]] = data[2]
end)

View File

@@ -0,0 +1,36 @@
--[[
| 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/
--]]
LANGUAGE = {
cmdWaypointAdd = "Add a waypoint where you are looking.",
cmdWaypointAddND = "Add a waypoint with no distance marking where you are looking.",
cmdWaypointUpdate = "Update an existing waypoint closest to where you are looking.",
cmdWaypointRemove = "Remove an existing waypoint closest to where you are looking.",
cmdWaypointRemoveAll = "Remove all current waypoints.",
addedWaypoint = "You have added a waypoint.",
updatedWaypoint = "You have updated a waypoint.",
removedWaypoint = "You have removed a waypoint.",
removedAllWaypoints = "You have removed all waypoints.",
cannotAddWaypoints = "You cannot add waypoints.",
cannotRemoveWaypoints = "You cannot remove waypoints.",
invalidWaypointColor = "'%s' is not a valid color! Use one of these instead:\n%s",
noWaypointsToRemove = "There are no waypoints that you can remove.",
noWaypointsNearToRemove = "There are no waypoints that you can remove near where you are looking.",
noWaypointsToUpdate = "There are no waypoints you can update.",
noWaypointsNearToUpdate = "There are no waypoints you can update near where you are looking.",
noWaypointsSet = "There are no waypoints set."
}

View File

@@ -0,0 +1,29 @@
--[[
| 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/
--]]
LANGUAGE = {
cmdWaypointAddND = "Añade un marcador sin distancia marcada donde estás mirando.",
cmdWaypointUpdate = "Actualiza el marcador más cercano a donde estás mirando.",
cmdWaypointAdd = "Añade un marcador donde estás mirando.",
removedWaypoint = "Has eliminado un marcador.",
updatedWaypoint = "Has actualizado un marcador.",
addedWaypoint = "Has añadido un marcador.",
cmdWaypointRemove = "Elimina el marcador existente más cercano a donde estás mirando.",
invalidWaypointColor = "¡'%s' no es un color válido! Usa uno de estos en su lugar:\n%s",
noWaypointsToUpdate = "No hay marcadores que actualizar.",
noWaypointsToRemove = "No hay marcadores que puedas eliminar.",
noWaypointsSet = "No hay marcadores colocados.",
noWaypointsNearToUpdate = "No hay marcadores que actualizar cerca de donde estás mirando.",
noWaypointsNearToRemove = "No hay marcadores que puedas eliminar cerca de donde estás mirando.",
cmdWaypointRemoveAll = "Elimina todos los marcadores existentes.",
removedAllWaypoints = "Has eliminado todos los marcadores.",
cannotAddWaypoints = "No puedes añadir marcadores.",
cannotRemoveWaypoints = "No puedes eliminar marcadores."
}

View File

@@ -0,0 +1,35 @@
--[[
| 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/
--]]
ix.waypoint = ix.waypoint or {}
ix.waypoint.types = ix.waypoint.types or {}
local PLUGIN = PLUGIN
function ix.waypoint.AddWaypoint(position, text, color, time, addedBy, ...)
if (!position or !isvector(position) or !position.Add) then
ErrorNoHalt("[WAYPOINTS] Invalid position given "..(position or nil))
return
end
position:Add(Vector(0, 0, 30))
color = color or color_white
time = time or 8
local waypoint = {
pos = position,
text = text,
color = color,
addedBy = addedBy,
arguments = {...},
time = CurTime() + time
}
PLUGIN:AddWaypoint(waypoint)
end

View File

@@ -0,0 +1,241 @@
--[[
| 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
PLUGIN.name = "Waypoints"
PLUGIN.author = "Gr4ss"
PLUGIN.description = "Gives the ability to allow some factions to see/add/remove/update waypoints."
PLUGIN.license = [[
(c) 2016 by Gr4Ss (greengr4ss@gmail.com)
This plugin is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/
]]
PLUGIN.readme = [[
A small plugin that allow some factions to use waypoints. To just list the features:
- Players can still remove/update their own waypoints without their faction having Remove/Update permissions.
- Makes it easy to add waypoints script-wise with a global library function (in case you for example want to create a waypoint where a player died).
- Waypoints can have some text.
- Waypoints can have different colors and can be made to last for a certain amount of time.
- Waypoint markers draw through walls and include a distance to them in meters. It is also possible to add waypoints without a distance marker.
- Waypoints will visually change a bit when a player can see the actual location.
- Players joining will see waypoints created before they joined if they should see them. Everything updates quite nicely.
- No texture download needed, waypoint is just drawn with lines and rectangles.
]]
ix.util.Include("cl_hooks.lua")
ix.util.Include("sv_hooks.lua")
ix.util.Include("sv_plugin.lua")
CAMI.RegisterPrivilege({
Name = "Helix - Waypoints",
MinAccess = "user"
})
ix.command.Add("WaypointAdd", {
description = "@cmdWaypointAdd",
privilege = "Waypoints",
arguments = {ix.type.string, ix.type.number, bit.bor(ix.type.string, ix.type.optional)},
OnRun = function(self, client, text, time, color)
if (!hook.Run("CanPlayerAddWaypoint", client)) then
return "@cannotAddWaypoints"
end
if (color) then
local colorName = string.lower(color)
color = PLUGIN:GetWaypointColor(colorName)
if (!color) then
return "@invalidWaypointColor", colorName
end
else
local faction = ix.faction.Get(client:Team())
color = faction.color or color_white
end
local position = client:GetEyeTraceNoCursor().HitPos
position:Add(Vector(0, 0, 30))
local waypoint = {
pos = position,
text = text,
color = color,
addedBy = client,
time = CurTime() + time
}
PLUGIN:AddWaypoint(waypoint)
return "@addedWaypoint"
end
})
ix.command.Add("WaypointAddND", {
description = "@cmdWaypointAddND",
privilege = "Waypoints",
arguments = {ix.type.string, ix.type.number, bit.bor(ix.type.string, ix.type.optional)},
OnRun = function(self, client, text, time, color)
if (!hook.Run("CanPlayerAddWaypoint", client)) then
return "@cannotAddWaypoints"
end
if (color) then
local colorName = string.lower(color)
color = PLUGIN:GetWaypointColor(colorName)
if (!color) then
return "@invalidWaypointColor", colorName
end
else
local faction = ix.faction.Get(client:Team())
color = faction.color or color_white
end
local position = client:GetEyeTraceNoCursor().HitPos
position:Add(Vector(0, 0, 30))
local waypoint = {
pos = position,
noDistance = true,
text = text,
color = color,
addedBy = client,
time = CurTime() + time
}
PLUGIN:AddWaypoint(waypoint)
return "@addedWaypoint"
end
})
ix.command.Add("WaypointUpdate", {
description = "@cmdWaypointUpdate",
privilege = "Waypoints",
arguments = {ix.type.string, bit.bor(ix.type.number, ix.type.optional), bit.bor(ix.type.string, ix.type.optional)},
OnRun = function(self, client, text, time, color)
local pos = client:GetEyeTraceNoCursor().HitPos
pos:Add(Vector(0, 0, 30))
local index = nil
local minDistanceSqr = nil
local onlyOwnWaypoints = hook.Run("CanPlayerUpdateWaypoints", client) != true
for k, point in pairs(PLUGIN.waypoints) do
if (onlyOwnWaypoints and point.addedBy != client) then
continue
end
if (!index) then
index = k
minDistanceSqr = point.pos:DistToSqr(pos)
else
local dist = point.pos:DistToSqr(pos)
if (dist < minDistanceSqr) then
index = k
minDistanceSqr = dist
end
end
end
if (!index) then
return "@noWaypointsToUpdate"
elseif (index and minDistanceSqr > 40000) then
return "@noWaypointsNearToUpdate"
end
if (color) then
local colorName = string.lower(color)
color = PLUGIN:GetWaypointColor(colorName)
if (!color) then
return "@invalidWaypointColor", colorName
end
else
local faction = ix.faction.Get(client:Team())
color = PLUGIN.waypoints[index].color or faction.color or color_white
end
if (time) then
time = CurTime() + time
else
time = PLUGIN.waypoints[index].time
end
local waypoint = {
pos = PLUGIN.waypoints[index].pos,
noDistance = PLUGIN.waypoints[index].noDistance,
text = text,
color = color,
addedBy = PLUGIN.waypoints[index].addedBy,
time = time
}
PLUGIN:UpdateWaypoint(index, waypoint)
return "@updatedWaypoint"
end
})
ix.command.Add("WaypointRemove", {
description = "@cmdWaypointRemove",
privilege = "Waypoints",
OnRun = function(self, client)
local trace = client:GetEyeTraceNoCursor()
local pos = trace.HitPos
pos:Add(Vector(0, 0, 30))
local index = nil
local minDistanceSqr = nil
local onlyOwnWaypoints = hook.Run("CanPlayerRemoveWaypoints", client) != true
for k, point in pairs(PLUGIN.waypoints) do
if (onlyOwnWaypoints and point.addedBy != client) then
continue
end
if (!index) then
index = k
minDistanceSqr = point.pos:DistToSqr(pos)
else
local dist = point.pos:DistToSqr(pos)
if (dist < minDistanceSqr) then
index = k
minDistanceSqr = dist
end
end
end
if (!index) then
return "@noWaypointsToRemove"
elseif (index and minDistanceSqr > 40000) then
return "@noWaypointsNearToRemove"
end
PLUGIN:UpdateWaypoint(index, nil)
return "@removedWaypoint"
end
})
ix.command.Add("WaypointRemoveAll", {
description = "@cmdWaypointRemoveAll",
privilege = "Waypoints",
OnRun = function(self, client)
if (!hook.Run("CanPlayerRemoveWaypoints", client)) then
return "@cannotRemoveWaypoints"
end
if (table.Count(PLUGIN.waypoints) > 0) then
PLUGIN:RemoveWaypoints()
return "@removedAllWaypoints"
else
return "@noWaypointsSet"
end
end
})

View File

@@ -0,0 +1,45 @@
--[[
| 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
function PLUGIN:PlayerLoadedCharacter(client, character, currentChar)
net.Start("SetupWaypoints")
net.WriteBool(true)
net.WriteTable(self.waypoints)
net.Send(client)
end
timer.Create("ixWaypointUpdate", 60, 0, function()
local curTime = CurTime()
local toRemove = {}
for k, waypoint in pairs(PLUGIN.waypoints) do
if (waypoint.time < curTime) then
table.insert(toRemove, k)
end
end
if (#toRemove > 0) then
table.sort(toRemove)
for i = #toRemove, 1, -1 do
table.remove(PLUGIN.waypoints, toRemove[i])
end
ix.combineNotify:AddNotification("NTC:// Updating Visual Uplink index", Color(0, 200, 150, 255))
net.Start("SetupWaypoints")
net.WriteBool(true)
net.WriteTable(PLUGIN.waypoints)
net.Broadcast()
end
end)

View File

@@ -0,0 +1,60 @@
--[[
| 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
PLUGIN.waypoints = {}
util.AddNetworkString("SetupWaypoints")
util.AddNetworkString("UpdateWaypoint")
function PLUGIN:RemoveWaypoints()
self.waypoints = {}
ix.combineNotify:AddNotification("NTC:// Updating Visual Uplink index", Color(0, 200, 150, 255))
net.Start("SetupWaypoints")
net.WriteBool(false)
net.Broadcast()
end
function PLUGIN:UpdateWaypoint(index, newValue)
if (newValue == nil) then
table.remove(self.waypoints, index)
net.Start("SetupWaypoints")
net.WriteBool(true)
net.WriteTable(self.waypoints)
net.Broadcast()
else
self.waypoints[index] = newValue
net.Start("UpdateWaypoint")
net.WriteTable({index, newValue})
net.Broadcast()
end
ix.combineNotify:AddNotification("NTC:// Updating Visual Uplink index", Color(0, 200, 150, 255))
end
function PLUGIN:AddWaypoint(waypoint)
local index = table.insert(self.waypoints, waypoint)
ix.combineNotify:AddNotification("NTC:// Updating Visual Uplink index", Color(0, 200, 150, 255))
net.Start("UpdateWaypoint")
net.WriteTable({index, waypoint})
net.Broadcast()
end
function PLUGIN:GetWaypointColor(colorName)
return Schema.colors[colorName]
end