From 25d963bfaf1f1651530252e04ea1d4c17979432a Mon Sep 17 00:00:00 2001 From: T-MaxWiese-T <65263210+T-MaxWiese-T@users.noreply.github.com> Date: Tue, 30 Apr 2024 03:40:19 +0200 Subject: [PATCH 01/10] playerblips: Fixed that the resource "playercolors" should be activated for teams The reason for this pull request is because the resource did not work the way I wanted it to. Only after I had a closer look at the code I realized that you can configure the resource in the meta.xml. Because I wanted the playerblips resource to take over the team colors that I have in my code, but that didn't happen. And since the server log said to activate the playercolors resource, I did it, but it didn't help. Only after I deactivated the playercolors resource and set "use_team_colors" to "true" did it work as expected. Anyway, the playercolors resource only makes sense if you want to have random player nametag colors, which makes no sense for a team, since a team can only have one color. --- [gameplay]/playerblips/server/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[gameplay]/playerblips/server/main.lua b/[gameplay]/playerblips/server/main.lua index a4020d312..416ab62dd 100644 --- a/[gameplay]/playerblips/server/main.lua +++ b/[gameplay]/playerblips/server/main.lua @@ -13,7 +13,7 @@ local function resourceStart() end local playercolorsResource = getResourceFromName("playercolors") - if playercolorsResource and getResourceState(playercolorsResource) ~= "running" then + 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 end From fe7bbd2c65d2d05e1a722fa78d612272474a2069 Mon Sep 17 00:00:00 2001 From: T-MaxWiese-T <65263210+T-MaxWiese-T@users.noreply.github.com> Date: Fri, 10 May 2024 08:53:49 +0200 Subject: [PATCH 02/10] Playercolors should only be recommended if a player uses a default nametag color --- [gameplay]/playerblips/server/main.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/[gameplay]/playerblips/server/main.lua b/[gameplay]/playerblips/server/main.lua index 416ab62dd..b1367e0c4 100644 --- a/[gameplay]/playerblips/server/main.lua +++ b/[gameplay]/playerblips/server/main.lua @@ -6,6 +6,7 @@ local color = get("*blip_color") local blipRange = get("*blip_range") local colors = {} local blips = {} +local playerHasDefaultNametagColor local function resourceStart() for i, player in ipairs(Element.getAllByType("player")) do @@ -13,9 +14,12 @@ local function resourceStart() 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 + if not playercolorsResource then + givePlayerColorsOutputDebugStringOut("Install") + elseif playercolorsResource and getResourceState(playercolorsResource) ~= "running" then + givePlayerColorsOutputDebugStringOut("Start") + end end if not (useTeams or useNametags) then @@ -24,6 +28,11 @@ local function resourceStart() end addEventHandler("onResourceStart", resourceRoot, resourceStart) +function givePlayerColorsOutputDebugStringOut(instruction) + outputDebugString("playerblips: " .. instruction .. " the playercolors resource if you want random nametag colors, otherwise the default blip color is used, which you can change manually in the playerblips settings or meta.xml.", 4, 255, 125, 0) + useNametags = false +end + function createPlayerBlip(player) if (not player or not isElement(player) or player.type ~= "player") then return false end local r, g, b @@ -31,6 +40,11 @@ function createPlayerBlip(player) 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 From 84c408edb54a4bbbfb761451ff103071e5d350e8 Mon Sep 17 00:00:00 2001 From: T-MaxWiese-T <65263210+T-MaxWiese-T@users.noreply.github.com> Date: Fri, 10 May 2024 08:55:12 +0200 Subject: [PATCH 03/10] Default playerblip color should be the default nametag color --- [gameplay]/playerblips/meta.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[gameplay]/playerblips/meta.xml b/[gameplay]/playerblips/meta.xml index 8bcc5c690..86555142d 100644 --- a/[gameplay]/playerblips/meta.xml +++ b/[gameplay]/playerblips/meta.xml @@ -21,7 +21,7 @@ /> Date: Fri, 10 May 2024 09:36:38 +0200 Subject: [PATCH 04/10] Removed unnecessary text --- [gameplay]/playerblips/server/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[gameplay]/playerblips/server/main.lua b/[gameplay]/playerblips/server/main.lua index b1367e0c4..895756c7c 100644 --- a/[gameplay]/playerblips/server/main.lua +++ b/[gameplay]/playerblips/server/main.lua @@ -29,7 +29,7 @@ end addEventHandler("onResourceStart", resourceRoot, resourceStart) function givePlayerColorsOutputDebugStringOut(instruction) - outputDebugString("playerblips: " .. instruction .. " the playercolors resource if you want random nametag colors, otherwise the default blip color is used, which you can change manually in the playerblips settings or meta.xml.", 4, 255, 125, 0) + outputDebugString("playerblips: " .. instruction .. " the playercolors resource if you want random nametag colors.", 4, 255, 125, 0) useNametags = false end From 7f81980856bd3c4a0517799a938477d9eec393f8 Mon Sep 17 00:00:00 2001 From: T-MaxWiese-T <65263210+T-MaxWiese-T@users.noreply.github.com> Date: Fri, 10 May 2024 09:45:26 +0200 Subject: [PATCH 05/10] Added debug message if use_team_colors and use_nametag_colors is false --- [gameplay]/playerblips/server/main.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/[gameplay]/playerblips/server/main.lua b/[gameplay]/playerblips/server/main.lua index 895756c7c..8e385f032 100644 --- a/[gameplay]/playerblips/server/main.lua +++ b/[gameplay]/playerblips/server/main.lua @@ -49,6 +49,7 @@ function createPlayerBlip(player) r, g, b = colors[player][1], colors[player][2], colors[player][3] else r, g, b = color[1], color[2], color[3] + outputDebugString("playerblips: use_team_colors and use_nametag_colors is false therefore the default blip_color is used, which you can change manually in the playerblips setting or meta.xml or set one of them to true.", 4, 255, 125, 0) end if isElement(blips[player]) then blips[player]:setColor(r, g, b, blipAlpha) From 8c330ded56166e143cd101f71f0e846f5ec604b9 Mon Sep 17 00:00:00 2001 From: T-MaxWiese-T <65263210+T-MaxWiese-T@users.noreply.github.com> Date: Fri, 10 May 2024 22:39:13 +0200 Subject: [PATCH 06/10] Improved text --- [gameplay]/playerblips/server/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/[gameplay]/playerblips/server/main.lua b/[gameplay]/playerblips/server/main.lua index 8e385f032..a8aa73f42 100644 --- a/[gameplay]/playerblips/server/main.lua +++ b/[gameplay]/playerblips/server/main.lua @@ -29,7 +29,7 @@ end addEventHandler("onResourceStart", resourceRoot, resourceStart) function givePlayerColorsOutputDebugStringOut(instruction) - outputDebugString("playerblips: " .. instruction .. " the playercolors resource if you want random nametag colors.", 4, 255, 125, 0) + outputDebugString("playerblips: " .. instruction .. " the playercolors resource if you want random nametag and blip colors.", 4, 255, 125, 0) useNametags = false end @@ -49,7 +49,7 @@ function createPlayerBlip(player) r, g, b = colors[player][1], colors[player][2], colors[player][3] else r, g, b = color[1], color[2], color[3] - outputDebugString("playerblips: use_team_colors and use_nametag_colors is false therefore the default blip_color is used, which you can change manually in the playerblips setting or meta.xml or set one of them to true.", 4, 255, 125, 0) + outputDebugString("playerblips: 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.", 4, 255, 125, 0) end if isElement(blips[player]) then blips[player]:setColor(r, g, b, blipAlpha) From dedeef6efdd614bb878a39a9af0500887b36477f Mon Sep 17 00:00:00 2001 From: T-MaxWiese-T <65263210+T-MaxWiese-T@users.noreply.github.com> Date: Sat, 11 May 2024 00:05:16 +0200 Subject: [PATCH 07/10] Fixed debug message for when useTeams and useNametags is false was displayed although it was not true and displayed on every player spawn --- [gameplay]/playerblips/server/main.lua | 28 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/[gameplay]/playerblips/server/main.lua b/[gameplay]/playerblips/server/main.lua index a8aa73f42..0a7ae26c3 100644 --- a/[gameplay]/playerblips/server/main.lua +++ b/[gameplay]/playerblips/server/main.lua @@ -7,6 +7,8 @@ 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 @@ -16,21 +18,32 @@ local function resourceStart() local playercolorsResource = getResourceFromName("playercolors") if playerHasDefaultNametagColor and not useTeams then if not playercolorsResource then - givePlayerColorsOutputDebugStringOut("Install") + giveOutputDebugStringOut("Install", outputDebugStringTypePlayerColors) elseif playercolorsResource and getResourceState(playercolorsResource) ~= "running" then - givePlayerColorsOutputDebugStringOut("Start") + giveOutputDebugStringOut("Start", outputDebugStringTypePlayerColors) end end - - if not (useTeams or useNametags) then + + if not useTeams and not useNametags then + giveOutputDebugStringOut("Start", outputDebugStringTypeUseTeamsAndNametagIsFalse) + elseif not (useTeams or useNametags) then addCommandHandler("setblipcolor", setBlipColor) end end addEventHandler("onResourceStart", resourceRoot, resourceStart) -function givePlayerColorsOutputDebugStringOut(instruction) - outputDebugString("playerblips: " .. instruction .. " the playercolors resource if you want random nametag and blip colors.", 4, 255, 125, 0) - useNametags = false +function giveOutputDebugStringOut(instruction, outputDebugStringType) + if instruction and outputDebugStringType then + local localInstruction = instruction + if localInstruction then + if outputDebugStringType == outputDebugStringTypePlayerColors then + localInstruction = localInstruction .. " the playercolors resource if you want random nametag and blip colors." + elseif outputDebugStringType == outputDebugStringTypeUseTeamsAndNametagIsFalse then + localInstruction = "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: " .. localInstruction, 4, 255, 125, 0) + end + end end function createPlayerBlip(player) @@ -49,7 +62,6 @@ function createPlayerBlip(player) r, g, b = colors[player][1], colors[player][2], colors[player][3] else r, g, b = color[1], color[2], color[3] - outputDebugString("playerblips: 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.", 4, 255, 125, 0) end if isElement(blips[player]) then blips[player]:setColor(r, g, b, blipAlpha) From 7d41d5e2e3d7ba732a92fd5320a94e76d62ebc0c Mon Sep 17 00:00:00 2001 From: T-MaxWiese-T <65263210+T-MaxWiese-T@users.noreply.github.com> Date: Sat, 11 May 2024 00:15:37 +0200 Subject: [PATCH 08/10] If query (useTeams or useNametags) logic restored --- [gameplay]/playerblips/server/main.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/[gameplay]/playerblips/server/main.lua b/[gameplay]/playerblips/server/main.lua index 0a7ae26c3..8d9eda3da 100644 --- a/[gameplay]/playerblips/server/main.lua +++ b/[gameplay]/playerblips/server/main.lua @@ -26,7 +26,8 @@ local function resourceStart() if not useTeams and not useNametags then giveOutputDebugStringOut("Start", outputDebugStringTypeUseTeamsAndNametagIsFalse) - elseif not (useTeams or useNametags) then + end + if not (useTeams or useNametags) then addCommandHandler("setblipcolor", setBlipColor) end end From e0655df1012591e7c809df28de627345b2c39fb8 Mon Sep 17 00:00:00 2001 From: T-MaxWiese-T <65263210+T-MaxWiese-T@users.noreply.github.com> Date: Sat, 11 May 2024 01:41:55 +0200 Subject: [PATCH 09/10] If query adjusted if the first parameter is nil. Variable name adjusted and unnecessary assignment removed --- [gameplay]/playerblips/server/main.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/[gameplay]/playerblips/server/main.lua b/[gameplay]/playerblips/server/main.lua index 8d9eda3da..f2a7f15cb 100644 --- a/[gameplay]/playerblips/server/main.lua +++ b/[gameplay]/playerblips/server/main.lua @@ -25,7 +25,7 @@ local function resourceStart() end if not useTeams and not useNametags then - giveOutputDebugStringOut("Start", outputDebugStringTypeUseTeamsAndNametagIsFalse) + giveOutputDebugStringOut(_, outputDebugStringTypeUseTeamsAndNametagIsFalse) end if not (useTeams or useNametags) then addCommandHandler("setblipcolor", setBlipColor) @@ -34,16 +34,14 @@ end addEventHandler("onResourceStart", resourceRoot, resourceStart) function giveOutputDebugStringOut(instruction, outputDebugStringType) - if instruction and outputDebugStringType then - local localInstruction = instruction - if localInstruction then - if outputDebugStringType == outputDebugStringTypePlayerColors then - localInstruction = localInstruction .. " the playercolors resource if you want random nametag and blip colors." - elseif outputDebugStringType == outputDebugStringTypeUseTeamsAndNametagIsFalse then - localInstruction = "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: " .. localInstruction, 4, 255, 125, 0) + 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 From 8708982c604a4643d862225044a82289d98d7a6a Mon Sep 17 00:00:00 2001 From: T-MaxWiese-T <65263210+T-MaxWiese-T@users.noreply.github.com> Date: Wed, 15 May 2024 06:01:36 +0200 Subject: [PATCH 10/10] Resource name should only be queried if it is required --- [gameplay]/playerblips/server/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[gameplay]/playerblips/server/main.lua b/[gameplay]/playerblips/server/main.lua index f2a7f15cb..5849c1c56 100644 --- a/[gameplay]/playerblips/server/main.lua +++ b/[gameplay]/playerblips/server/main.lua @@ -15,8 +15,8 @@ local function resourceStart() createPlayerBlip(player) end - local playercolorsResource = getResourceFromName("playercolors") if playerHasDefaultNametagColor and not useTeams then + local playercolorsResource = getResourceFromName("playercolors") if not playercolorsResource then giveOutputDebugStringOut("Install", outputDebugStringTypePlayerColors) elseif playercolorsResource and getResourceState(playercolorsResource) ~= "running" then