Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playerblips: Improved debug messages #482

Merged
merged 12 commits into from
May 23, 2024
Merged
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: 1 addition & 1 deletion [gameplay]/playerblips/meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/>
<setting
name="*blip_color"
value="[[0, 255, 0]]"
value="[[255, 255, 255]]"
friendlyname="Default blip color"
group="Color settings"
accept=""
Expand Down
36 changes: 31 additions & 5 deletions [gameplay]/playerblips/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,57 @@ local color = get("*blip_color")
local blipRange = get("*blip_range")
local colors = {}
local blips = {}
local playerHasDefaultNametagColor
local outputDebugStringTypePlayerColors = "playerColors"
local outputDebugStringTypeUseTeamsAndNametagIsFalse = "useTeamsAndNametagsIsFalse"

local function resourceStart()
for i, player in ipairs(Element.getAllByType("player")) do
createPlayerBlip(player)
end

local playercolorsResource = getResourceFromName("playercolors")
if playercolorsResource and getResourceState(playercolorsResource) ~= "running" and not useTeams then
outputDebugString("playerblips: playercolors resource not running; using blip_color. Restart this resource after starting playercolors.", 4, 255, 125, 0)
useNametags = false
if playerHasDefaultNametagColor and not useTeams then
local playercolorsResource = getResourceFromName("playercolors")
if not playercolorsResource then
giveOutputDebugStringOut("Install", outputDebugStringTypePlayerColors)
elseif playercolorsResource and getResourceState(playercolorsResource) ~= "running" then
giveOutputDebugStringOut("Start", outputDebugStringTypePlayerColors)
end
end

if not useTeams and not useNametags then
giveOutputDebugStringOut(_, outputDebugStringTypeUseTeamsAndNametagIsFalse)
end

if not (useTeams or useNametags) then
addCommandHandler("setblipcolor", setBlipColor)
end
end
addEventHandler("onResourceStart", resourceRoot, resourceStart)

function giveOutputDebugStringOut(instruction, outputDebugStringType)
if outputDebugStringType then
local outputDebugStringText
if instruction and outputDebugStringType == outputDebugStringTypePlayerColors then
outputDebugStringText = instruction .. " the playercolors resource if you want random nametag and blip colors."
elseif outputDebugStringType == outputDebugStringTypeUseTeamsAndNametagIsFalse then
outputDebugStringText = "use_team_colors and use_nametag_colors is false therefore the default blip_color is used. You can change it manually in the admin panel playerblips settings or in the meta.xml file."
end
outputDebugString("playerblips: " .. outputDebugStringText, 4, 255, 125, 0)
end
end

function createPlayerBlip(player)
if (not player or not isElement(player) or player.type ~= "player") then return false end
local r, g, b
if (useTeams and player.team) then
r, g, b = player.team:getColor()
elseif useNametags then
r, g, b = getPlayerNametagColor(player)
if not playerHasDefaultNametagColor then
if r == 255 and g == 255 and b == 255 then
playerHasDefaultNametagColor = true
end
end
elseif (colors[player]) then
r, g, b = colors[player][1], colors[player][2], colors[player][3]
else
Expand Down