ajout de commentaire sur le code

This commit is contained in:
2026-06-27 08:18:07 +02:00
parent 875954ac63
commit 75428ef21d
5 changed files with 48 additions and 88 deletions
-1
View File
@@ -6,7 +6,6 @@ if SERVER then
AddCSLuaFile("bladw_hud/client/cl_hud.lua")
AddCSLuaFile("bladw_cMenu/client/cl_cMenu.lua")
AddCSLuaFile("bladw_deathscreen/client/cl_interface_ds.lua")
AddCSLuaFile("lib/rndx.lua")
include("bladw_deathscreen/server/sv_hooks.lua")
+44 -76
View File
@@ -54,6 +54,30 @@ local function HoveredButton2(button, label, font)
end
end
local function CreateMenuButton(parent, y, label, command)
local btn = vgui.Create("DButton", parent)
btn:SetSize(RX(400), RY(122))
btn:SetPos(RX(0), RY(y))
btn:SetText("")
HoveredButton2(btn, label, "bladw_text")
btn.DoClick = function()
ply:ConCommand(command)
end
return btn
end
local function CreateLinkButton(parent, x, y, icon, label, url)
local btn = vgui.Create("DButton", parent)
btn:SetSize(RX(150), RY(51))
btn:SetPos(RX(x), RY(y))
btn:SetText("")
HoveredButton(btn, icon, label, "bladw_text_Medium")
btn.DoClick = function()
gui.OpenURL(url)
end
return btn
end
local function CloseCMenu()
if IsValid(CMenu) then
CMenu:Remove()
@@ -62,6 +86,20 @@ local function CloseCMenu()
end
end
local cMenuButtons = {
{ y = 250, label = "3ème personne", command = "bladw_3pers" },
{ y = 325, label = "Stopsound", command = "bladw_sound" },
{ y = 400, label = "Appelez un staff", command = "bladw_staff" },
{ y = 475, label = "Jeter de l'argent",command = "bladw_money" },
{ y = 550, label = "Jeter une arme", command = "bladw_weapon" },
}
local linkButtons = {
{ x = 50, y = 942, icon = bladw_materials.discord, label = "Discord", url = "https://discord.gg/KsE4Xef6vg" },
{ x = 207, y = 942, icon = bladw_materials.steam, label = "Steam", url = "" },
{ x = 125, y = 1005, icon = bladw_materials.website, label = "Website", url = "" },
}
local function GetStats()
local nbplayer = player.GetCount()
local nbpolice = team.NumPlayers(TEAM_POLICE)
@@ -70,10 +108,9 @@ local function GetStats()
return nbplayer, nbpolice, nbpompiers
end
local nbplayer, nbpolice, nbpompiers = GetStats()
function OpenCMenu()
if IsValid(CMenu) then return end
local nbplayer, nbpolice, nbpompiers = GetStats()
local ply = LocalPlayer()
@@ -93,7 +130,7 @@ function OpenCMenu()
surface.SetFont("bladw_text")
local before = "Il y a "
local count = tostring(nbplayer)
local count = nbplayer
local after = " joueurs sur le serveur"
local beforeW, _ = surface.GetTextSize(before)
@@ -106,49 +143,8 @@ function OpenCMenu()
draw.SimpleText(after, "bladw_text", startX + beforeW + countW, RY(900), Color(255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
end
button3pers = vgui.Create("DButton", CMenu)
button3pers:SetSize(RX(400), RY(122))
button3pers:SetPos(RX(0), RY(250))
button3pers:SetText("")
HoveredButton2(button3pers, "3ème personne", "bladw_text")
button3pers.DoClick = function()
ply:ConCommand("bladw_3pers")
end
SoundButton = vgui.Create("DButton", CMenu)
SoundButton:SetSize(RX(400), RY(122))
SoundButton:SetPos(RX(0), RY(325))
SoundButton:SetText("")
HoveredButton2(SoundButton, "Stopsound", "bladw_text")
SoundButton.DoClick = function()
ply:ConCommand("bladw_sound")
end
staffbutton = vgui.Create("DButton", CMenu)
staffbutton:SetSize(RX(400), RY(122))
staffbutton:SetPos(RX(0), RY(400))
staffbutton:SetText("")
HoveredButton2(staffbutton, "Appelez un staff", "bladw_text")
staffbutton.DoClick = function()
ply:ConCommand("bladw_staff")
end
moneybutton = vgui.Create("DButton", CMenu)
moneybutton:SetSize(RX(400), RY(122))
moneybutton:SetPos(RX(0), RY(475))
moneybutton:SetText("")
HoveredButton2(moneybutton, "Jeter de l'argent", "bladw_text")
moneybutton.DoClick = function()
ply:ConCommand("bladw_money")
end
weaponbutton = vgui.Create("DButton", CMenu)
weaponbutton:SetSize(RX(400), RY(122))
weaponbutton:SetPos(RX(0), RY(550))
weaponbutton:SetText("")
HoveredButton2(weaponbutton, "Jeter une arme", "bladw_text")
weaponbutton.DoClick = function()
ply:ConCommand("bladw_weapon")
for _, btnData in ipairs(cMenuButtons) do
CreateMenuButton(CMenu, btnData.y, btnData.label, btnData.command)
end
PoliceButton = vgui.Create("DPanel", CMenu)
@@ -191,32 +187,8 @@ function OpenCMenu()
draw.SimpleText(after, "bladw_text_Medium", startX + countW, h / 2, Color(255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
end
DiscordButton = vgui.Create("DButton", CMenu)
DiscordButton:SetSize(RX(150), RY(51))
DiscordButton:SetPos(RX(50), RY(942))
DiscordButton:SetText("")
HoveredButton(DiscordButton, bladw_materials.discord, "Discord", "bladw_text_Medium")
DiscordButton.DoClick = function()
gui.OpenURL("https://discord.gg/KsE4Xef6vg")
end
SteamButton = vgui.Create("DButton", CMenu)
SteamButton:SetSize(RX(150), RY(51))
SteamButton:SetPos(RX(207), RY(942))
SteamButton:SetText("")
HoveredButton(SteamButton, bladw_materials.steam, "Steam", "bladw_text_Medium")
SteamButton.DoClick = function()
gui.OpenURL("")
end
WebButton = vgui.Create("DButton", CMenu)
WebButton:SetSize(RX(150), RY(51))
WebButton:SetPos(RX(125), RY(1005))
WebButton:SetText("")
HoveredButton(WebButton, bladw_materials.website, "Website", "bladw_text_Medium")
WebButton.DoClick = function()
gui.OpenURL("")
for _, btnData in ipairs(linkButtons) do
CreateLinkButton(CMenu, btnData.x, btnData.y, btnData.icon, btnData.label, btnData.url)
end
end
@@ -232,8 +204,4 @@ hook.Add("PlayerButtonUp", "bladw_CMenu_close", function(ply, key)
if key == KEY_C then
CloseCMenu()
end
end)
hook.Add("OnContextMenuOpen", "bladw_blockC", function()
return true
end)
@@ -1,3 +1,5 @@
local RNDX = include("lib/rndx.lua")
local function RX(x) return x * (ScrW() / 1920) end
local function RY(y) return y * (ScrH() / 1080) end
+2 -1
View File
@@ -29,10 +29,11 @@ hook.Add("PlayerDeath", "bladw_ds_open", function(victim, inflictor, attacker)
killerName = string.upper(attacker:Nick())
end
-- Adjusts respawn delay based on players in a specified team.
local hasResponder = false
for _, p in ipairs(player.GetAll()) do
local job = p:getDarkRPVar("job")
if job == "Citizen" or job == "Citizen" then
if job == "Citizen" or job == "Citizen" then
hasResponder = true
break
end
-10
View File
@@ -1,13 +1,3 @@
--[[
Copyright (c) 2025 Srlion (https://github.com/Srlion)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]]
if SERVER then
AddCSLuaFile()
return