ajout de commentaire sur le code
This commit is contained in:
@@ -6,7 +6,6 @@ if SERVER then
|
|||||||
AddCSLuaFile("bladw_hud/client/cl_hud.lua")
|
AddCSLuaFile("bladw_hud/client/cl_hud.lua")
|
||||||
AddCSLuaFile("bladw_cMenu/client/cl_cMenu.lua")
|
AddCSLuaFile("bladw_cMenu/client/cl_cMenu.lua")
|
||||||
AddCSLuaFile("bladw_deathscreen/client/cl_interface_ds.lua")
|
AddCSLuaFile("bladw_deathscreen/client/cl_interface_ds.lua")
|
||||||
AddCSLuaFile("lib/rndx.lua")
|
|
||||||
|
|
||||||
include("bladw_deathscreen/server/sv_hooks.lua")
|
include("bladw_deathscreen/server/sv_hooks.lua")
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,30 @@ local function HoveredButton2(button, label, font)
|
|||||||
end
|
end
|
||||||
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()
|
local function CloseCMenu()
|
||||||
if IsValid(CMenu) then
|
if IsValid(CMenu) then
|
||||||
CMenu:Remove()
|
CMenu:Remove()
|
||||||
@@ -62,6 +86,20 @@ local function CloseCMenu()
|
|||||||
end
|
end
|
||||||
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 function GetStats()
|
||||||
local nbplayer = player.GetCount()
|
local nbplayer = player.GetCount()
|
||||||
local nbpolice = team.NumPlayers(TEAM_POLICE)
|
local nbpolice = team.NumPlayers(TEAM_POLICE)
|
||||||
@@ -70,10 +108,9 @@ local function GetStats()
|
|||||||
return nbplayer, nbpolice, nbpompiers
|
return nbplayer, nbpolice, nbpompiers
|
||||||
end
|
end
|
||||||
|
|
||||||
local nbplayer, nbpolice, nbpompiers = GetStats()
|
|
||||||
|
|
||||||
function OpenCMenu()
|
function OpenCMenu()
|
||||||
if IsValid(CMenu) then return end
|
if IsValid(CMenu) then return end
|
||||||
|
local nbplayer, nbpolice, nbpompiers = GetStats()
|
||||||
|
|
||||||
local ply = LocalPlayer()
|
local ply = LocalPlayer()
|
||||||
|
|
||||||
@@ -93,7 +130,7 @@ function OpenCMenu()
|
|||||||
|
|
||||||
surface.SetFont("bladw_text")
|
surface.SetFont("bladw_text")
|
||||||
local before = "Il y a "
|
local before = "Il y a "
|
||||||
local count = tostring(nbplayer)
|
local count = nbplayer
|
||||||
local after = " joueurs sur le serveur"
|
local after = " joueurs sur le serveur"
|
||||||
|
|
||||||
local beforeW, _ = surface.GetTextSize(before)
|
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)
|
draw.SimpleText(after, "bladw_text", startX + beforeW + countW, RY(900), Color(255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
|
||||||
end
|
end
|
||||||
|
|
||||||
button3pers = vgui.Create("DButton", CMenu)
|
for _, btnData in ipairs(cMenuButtons) do
|
||||||
button3pers:SetSize(RX(400), RY(122))
|
CreateMenuButton(CMenu, btnData.y, btnData.label, btnData.command)
|
||||||
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")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
PoliceButton = vgui.Create("DPanel", CMenu)
|
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)
|
draw.SimpleText(after, "bladw_text_Medium", startX + countW, h / 2, Color(255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
|
||||||
end
|
end
|
||||||
|
|
||||||
DiscordButton = vgui.Create("DButton", CMenu)
|
for _, btnData in ipairs(linkButtons) do
|
||||||
DiscordButton:SetSize(RX(150), RY(51))
|
CreateLinkButton(CMenu, btnData.x, btnData.y, btnData.icon, btnData.label, btnData.url)
|
||||||
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("")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -232,8 +204,4 @@ hook.Add("PlayerButtonUp", "bladw_CMenu_close", function(ply, key)
|
|||||||
if key == KEY_C then
|
if key == KEY_C then
|
||||||
CloseCMenu()
|
CloseCMenu()
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
|
|
||||||
hook.Add("OnContextMenuOpen", "bladw_blockC", function()
|
|
||||||
return true
|
|
||||||
end)
|
end)
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
local RNDX = include("lib/rndx.lua")
|
||||||
|
|
||||||
local function RX(x) return x * (ScrW() / 1920) end
|
local function RX(x) return x * (ScrW() / 1920) end
|
||||||
local function RY(y) return y * (ScrH() / 1080) end
|
local function RY(y) return y * (ScrH() / 1080) end
|
||||||
|
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ hook.Add("PlayerDeath", "bladw_ds_open", function(victim, inflictor, attacker)
|
|||||||
killerName = string.upper(attacker:Nick())
|
killerName = string.upper(attacker:Nick())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Adjusts respawn delay based on players in a specified team.
|
||||||
local hasResponder = false
|
local hasResponder = false
|
||||||
for _, p in ipairs(player.GetAll()) do
|
for _, p in ipairs(player.GetAll()) do
|
||||||
local job = p:getDarkRPVar("job")
|
local job = p:getDarkRPVar("job")
|
||||||
if job == "Citizen" or job == "Citizen" then
|
if job == "Citizen" or job == "Citizen" then
|
||||||
hasResponder = true
|
hasResponder = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
if SERVER then
|
||||||
AddCSLuaFile()
|
AddCSLuaFile()
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user