mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
Upload
This commit is contained in:
137
gamemodes/helix/plugins/radio/items/base/sh_radio.lua
Normal file
137
gamemodes/helix/plugins/radio/items/base/sh_radio.lua
Normal file
@@ -0,0 +1,137 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Radio Base"
|
||||
ITEM.category = "Radio"
|
||||
ITEM.model = Model("models/deadbodies/dead_male_civilian_radio.mdl")
|
||||
ITEM.description = "A shiny handheld radio with a frequency tuner."
|
||||
|
||||
ITEM.isRadio = true
|
||||
|
||||
-- Inventory drawing
|
||||
if (CLIENT) then
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
if (item:GetData("enabled")) then
|
||||
surface.SetDrawColor(110, 255, 110, 100)
|
||||
surface.DrawRect(w - 14, h - 14, 8, 8)
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:PopulateTooltip(tooltip)
|
||||
if (self:GetData("enabled")) then
|
||||
local name = tooltip:GetRow("name")
|
||||
name:SetBackgroundColor(derma.GetColor("Success", tooltip))
|
||||
end
|
||||
|
||||
local channel = ix.radio:FindByID(self:GetChannel())
|
||||
if (channel) then
|
||||
local chTip = tooltip:AddRowAfter("name", "channel")
|
||||
chTip:SetText("Channel: "..channel.name)
|
||||
chTip:SizeToContents()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:GetChannel(bForce)
|
||||
if (bForce or self:GetData("enabled")) then
|
||||
return self.channel
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnRemoved()
|
||||
self:SetData("enabled", false)
|
||||
local owner = self:GetOwner()
|
||||
if (owner) then
|
||||
ix.radio:RemoveListenerFromChannel(owner, self:GetChannel(true))
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnDestroyed(entity)
|
||||
self:SetData("enabled", false)
|
||||
if (IsValid(entity)) then
|
||||
ix.radio:RemoveStationaryFromChannel(self:GetChannel(true), entity)
|
||||
end
|
||||
end
|
||||
|
||||
ITEM.functions.ToggleOn = {
|
||||
name = "Allumer",
|
||||
OnRun = function(item)
|
||||
item:SetData("enabled", true)
|
||||
item.player:EmitSound("buttons/lever7.wav", 50, math.random(170, 180), 0.25)
|
||||
|
||||
item:SetData("volume", 0, nil, false)
|
||||
|
||||
if (!IsValid(item.entity)) then
|
||||
local owner = item:GetOwner()
|
||||
if (owner) then
|
||||
ix.radio:AddListenerToChannel(owner, item:GetChannel())
|
||||
end
|
||||
else
|
||||
ix.radio:AddStationaryToChannel(item:GetChannel(), item.entity)
|
||||
end
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return item:GetData("enabled", false) == false
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.ToggleOff = {
|
||||
name = "Éteindre",
|
||||
OnRun = function(item)
|
||||
item:SetData("enabled", false)
|
||||
item.player:EmitSound("buttons/lever7.wav", 50, math.random(170, 180), 0.25)
|
||||
|
||||
|
||||
if (!IsValid(item.entity)) then
|
||||
local owner = item:GetOwner()
|
||||
if (owner) then
|
||||
ix.radio:RemoveListenerFromChannel(owner, item:GetChannel(true))
|
||||
end
|
||||
else
|
||||
ix.radio:RemoveStationaryFromChannel(item:GetChannel(true), item.entity)
|
||||
end
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return item:GetData("enabled", false) == true
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.VolumeDown = {
|
||||
name = "Baisser volume",
|
||||
OnRun = function(item)
|
||||
item:SetData("volume", 0, nil, false)
|
||||
ix.radio:RemoveStationaryFromChannel(item:GetChannel(), item.entity)
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return IsValid(item.entity) and item:GetData("volume", 0) == 1 and item:GetData("enabled")
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.VolumeUp = {
|
||||
name = "Augmenter volume",
|
||||
OnRun = function(item)
|
||||
item:SetData("volume", 1, nil, false)
|
||||
ix.radio:AddStationaryToChannel(item:GetChannel(), item.entity)
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return IsValid(item.entity) and item:GetData("volume", 0) == 0 and item:GetData("enabled")
|
||||
end
|
||||
}
|
||||
106
gamemodes/helix/plugins/radio/items/base/sh_radio_m.lua
Normal file
106
gamemodes/helix/plugins/radio/items/base/sh_radio_m.lua
Normal file
@@ -0,0 +1,106 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Radio (M) Base"
|
||||
ITEM.category = "Radio"
|
||||
ITEM.model = Model("models/deadbodies/dead_male_civilian_radio.mdl")
|
||||
ITEM.description = "A shiny handheld radio with a frequency tuner."
|
||||
|
||||
ITEM.isRadio = true
|
||||
|
||||
-- Inventory drawing
|
||||
if (CLIENT) then
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
if (item:GetData("enabled")) then
|
||||
surface.SetDrawColor(110, 255, 110, 100)
|
||||
surface.DrawRect(w - 14, h - 14, 8, 8)
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:PopulateTooltip(tooltip)
|
||||
if (self:GetData("enabled")) then
|
||||
local name = tooltip:GetRow("name")
|
||||
name:SetBackgroundColor(derma.GetColor("Success", tooltip))
|
||||
end
|
||||
|
||||
local channels = self:GetChannels()
|
||||
if (channels) then
|
||||
local channelNames = {}
|
||||
for k, v in ipairs(channels) do
|
||||
if (ix.radio:FindByID(v)) then
|
||||
channelNames[#channelNames + 1] = ix.radio:FindByID(v).name
|
||||
end
|
||||
end
|
||||
|
||||
local chTip = tooltip:AddRowAfter("name", "channel")
|
||||
chTip:SetText("Channels: "..table.concat(channelNames, ", "))
|
||||
chTip:SizeToContents()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:GetChannels(bForce)
|
||||
return {}
|
||||
end
|
||||
|
||||
function ITEM:OnRemoved()
|
||||
self:SetData("enabled", false)
|
||||
local owner = self:GetOwner()
|
||||
if (owner) then
|
||||
for _, v in ipairs(self:GetChannels(true)) do
|
||||
ix.radio:RemoveListenerFromChannel(owner, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnDestroyed(entity)
|
||||
self:SetData("enabled", false)
|
||||
end
|
||||
|
||||
ITEM.functions.ToggleOn = {
|
||||
name = "Toggle Radio On",
|
||||
OnRun = function(item)
|
||||
item:SetData("enabled", true)
|
||||
item.player:EmitSound("buttons/lever7.wav", 50, math.random(170, 180), 0.25)
|
||||
|
||||
local owner = item:GetOwner()
|
||||
if (owner) then
|
||||
for _, v in ipairs(item:GetChannels()) do
|
||||
ix.radio:AddListenerToChannel(owner, v)
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return item:GetData("enabled", false) == false
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.ToggleOff = {
|
||||
name = "Toggle Radio Off",
|
||||
OnRun = function(item)
|
||||
item:SetData("enabled", false)
|
||||
item.player:EmitSound("buttons/lever7.wav", 50, math.random(170, 180), 0.25)
|
||||
|
||||
local owner = item:GetOwner()
|
||||
if (owner) then
|
||||
for _, v in ipairs(item:GetChannels(true)) do
|
||||
ix.radio:RemoveListenerFromChannel(owner, v)
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return item:GetData("enabled", false) == true
|
||||
end
|
||||
}
|
||||
179
gamemodes/helix/plugins/radio/items/base/sh_radio_m2.lua
Normal file
179
gamemodes/helix/plugins/radio/items/base/sh_radio_m2.lua
Normal file
@@ -0,0 +1,179 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
ITEM.name = "Radio (M2) Base"
|
||||
ITEM.model = Model("models/props_lab/citizenradio.mdl")
|
||||
ITEM.description = "A big powerful long-range radio allowing for communication across large distances - or through thick obstructions."
|
||||
|
||||
ITEM.isRadio = true
|
||||
|
||||
ITEM.category = "Radio"
|
||||
ITEM.height = 4
|
||||
ITEM.width = 4
|
||||
|
||||
ITEM.maxFrequencies = 3
|
||||
|
||||
if (CLIENT) then
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
if (item:GetData("enabled")) then
|
||||
surface.SetDrawColor(110, 255, 110, 100)
|
||||
surface.DrawRect(w - 14, h - 14, 8, 8)
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:PopulateTooltip(tooltip)
|
||||
if (self:GetData("enabled")) then
|
||||
local name = tooltip:GetRow("name")
|
||||
name:SetBackgroundColor(derma.GetColor("Success", tooltip))
|
||||
end
|
||||
|
||||
local channels = self:GetChannels()
|
||||
if (channels) then
|
||||
local channelNames = {}
|
||||
for k, v in ipairs(channels) do
|
||||
if (ix.radio:FindByID(v)) then
|
||||
channelNames[#channelNames + 1] = ix.radio:FindByID(v).name
|
||||
end
|
||||
end
|
||||
|
||||
local chTip = tooltip:AddRowAfter("name", "channel")
|
||||
chTip:SetText("Channels: "..table.concat(channelNames, ", "))
|
||||
chTip:SizeToContents()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:GetChannels(bForce)
|
||||
if (bForce or self:GetData("enabled")) then
|
||||
return self:GetData("channels", {})
|
||||
else
|
||||
return {}
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnRemoved()
|
||||
self:SetData("enabled", false)
|
||||
local owner = self:GetOwner()
|
||||
if (owner) then
|
||||
for _, v in ipairs(self:GetChannels(true)) do
|
||||
ix.radio:RemoveListenerFromChannel(owner, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnDestroyed(entity)
|
||||
self:SetData("enabled", false)
|
||||
end
|
||||
|
||||
ITEM.functions.setRadioFrequency = {
|
||||
name = "Set Frequency",
|
||||
icon = "icon16/transmit.png",
|
||||
isMulti = true,
|
||||
multiOptions = function(item, player)
|
||||
local options = {}
|
||||
for i = 1, item.maxFrequencies do
|
||||
options[i] = {name = "Freq "..i, OnClick = function(itemTbl)
|
||||
local freq = itemTbl:GetData("channels", {})[i]
|
||||
local freqText = freq and string.match(freq, "^freq_(%d%d%d)$") or ""
|
||||
Derma_StringRequest("Select Frequency", "Please enter the frequency you wish to switch to:", freqText, function(text)
|
||||
local newFreq = tonumber(text)
|
||||
if (string.len(text) == 2 and newFreq and newFreq >= 10) then
|
||||
net.Start("ixInventoryAction")
|
||||
net.WriteString("setRadioFrequency")
|
||||
net.WriteUInt(itemTbl.id, 32)
|
||||
net.WriteUInt(itemTbl.invID, 32)
|
||||
net.WriteTable({i, text})
|
||||
net.SendToServer()
|
||||
else
|
||||
player:Notify("Please enter a frequency between 100 and 999")
|
||||
end
|
||||
end, nil, "Set", "Cancel")
|
||||
return false
|
||||
end}
|
||||
end
|
||||
|
||||
return options
|
||||
end,
|
||||
OnRun = function(item, data)
|
||||
if (!data or !data[1]) then return false end
|
||||
if (data[1] < 1 or data[1] > item.maxFrequencies) then return false end
|
||||
local newFreq = tonumber(data[2])
|
||||
if (string.len(data[2]) != 2 or !newFreq or newFreq < 10) then return false end
|
||||
|
||||
local channels = item:GetData("channels", {})
|
||||
local oldFreq = channels[data[1]]
|
||||
channels[data[1]] = "freq_"..data[2]
|
||||
item:SetData("channels", channels)
|
||||
|
||||
if (oldFreq) then
|
||||
ix.radio:RemoveListenerFromChannel(item:GetOwner(), oldFreq)
|
||||
end
|
||||
ix.radio:AddListenerToChannel(item:GetOwner(), channels[data[1]])
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
if (IsValid(item.entity)) then return false end
|
||||
|
||||
return true
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.setRadioOn = {
|
||||
name = "Toggle Radio On",
|
||||
icon = "icon16/connect.png",
|
||||
OnRun = function(item)
|
||||
item:SetData("enabled", true)
|
||||
item.player:EmitSound("buttons/lever7.wav", 50, math.random(170, 180), 0.25)
|
||||
|
||||
local owner = item:GetOwner()
|
||||
if (owner) then
|
||||
for _, v in ipairs(item:GetChannels()) do
|
||||
ix.radio:AddListenerToChannel(owner, v)
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return item:GetData("enabled", false) == false
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.setRadioOff = {
|
||||
name = "Toggle Radio Off",
|
||||
icon = "icon16/disconnect.png",
|
||||
OnRun = function(item)
|
||||
item:SetData("enabled", false)
|
||||
item.player:EmitSound("buttons/lever7.wav", 50, math.random(170, 180), 0.25)
|
||||
|
||||
local owner = item:GetOwner()
|
||||
if (owner) then
|
||||
for _, v in ipairs(item:GetChannels(true)) do
|
||||
ix.radio:RemoveListenerFromChannel(owner, v)
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return item:GetData("enabled", false) == true
|
||||
end
|
||||
}
|
||||
|
||||
function ITEM:OnInstanced()
|
||||
local tbl = {"freq_10"}
|
||||
if (self.maxFrequencies > 1) then
|
||||
for i = 1, self.maxFrequencies - 1 do
|
||||
tbl[#tbl + 1] = "freq_1"..i
|
||||
end
|
||||
end
|
||||
self:SetData("channels", tbl)
|
||||
end
|
||||
120
gamemodes/helix/plugins/radio/items/radio/sh_handheld_radio.lua
Normal file
120
gamemodes/helix/plugins/radio/items/radio/sh_handheld_radio.lua
Normal file
@@ -0,0 +1,120 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Radio portable"
|
||||
ITEM.model = Model("models/willardnetworks/skills/handheld_radio.mdl")
|
||||
ITEM.description = "Une radio portable correctement conçue prenant en charge les fréquences analogiques et numériques."
|
||||
ITEM.category = "Radios"
|
||||
|
||||
function ITEM:OnInstanced()
|
||||
self:SetData("qt", {{}, {}, {}})
|
||||
self:UpdateChannel()
|
||||
end
|
||||
|
||||
function ITEM:UpdateChannel()
|
||||
local client = self:GetOwner()
|
||||
local oldChannel = client and self:GetChannel()
|
||||
|
||||
local zone, channel = self:GetData("zone", 1), self:GetData("ch", 1)
|
||||
local qt = self:GetData("qt")
|
||||
self:SetData("channel", "freq_"..zone.."_"..channel.."_"..(qt[zone][channel] or channel))
|
||||
|
||||
if (client and self:GetChannel() != oldChannel) then
|
||||
ix.radio:RemoveListenerFromChannel(client, oldChannel)
|
||||
ix.radio:AddListenerToChannel(client, self:GetChannel())
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:GetChannel(bForce)
|
||||
if (bForce or self:GetData("enabled")) then
|
||||
return self:GetData("channel")
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
ITEM.functions.zone = {
|
||||
name = "Définir fréquence",
|
||||
isMulti = true,
|
||||
multiOptions = function(item, player)
|
||||
local zones = {}
|
||||
for i = 1, 3 do
|
||||
zones[i] = {name = i, data = {i}}
|
||||
end
|
||||
|
||||
return zones
|
||||
end,
|
||||
OnRun = function(item, data)
|
||||
item:SetData("zone", data[1])
|
||||
item:UpdateChannel()
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return !IsValid(item.entity)
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.channel = {
|
||||
name = "Définir channel",
|
||||
isMulti = true,
|
||||
multiOptions = function(item, player)
|
||||
local channels = {}
|
||||
for i = 1, 16 do
|
||||
channels[i] = {name = i, data = {i}}
|
||||
end
|
||||
|
||||
return channels
|
||||
end,
|
||||
OnRun = function(item, data)
|
||||
item:SetData("ch", data[1])
|
||||
item:UpdateChannel()
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return !IsValid(item.entity)
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.qt = {
|
||||
name = "Définir QT/DQT",
|
||||
OnClick = function(item)
|
||||
local zone, channel = item:GetData("zone", 1), item:GetData("ch", 1)
|
||||
local max = zone == 1 and 16 or 99
|
||||
local text = zone == 1 and "Ton QT" or "Code DQT"
|
||||
|
||||
local qt = item:GetData("qt")
|
||||
Derma_StringRequest(text, "Que souhaitez-vous définir "..text.." pour ? 1-"..max, qt[zone][channel] or channel,
|
||||
function(newQT)
|
||||
newQT = math.floor(tonumber(newQT))
|
||||
if (newQT < 1 or newQT > max) then return end
|
||||
|
||||
net.Start("ixInventoryAction")
|
||||
net.WriteString("qt")
|
||||
net.WriteUInt(item.id, 32)
|
||||
net.WriteUInt(item.invID, 32)
|
||||
net.WriteTable({newQT})
|
||||
net.SendToServer()
|
||||
end)
|
||||
end,
|
||||
OnRun = function(item, data)
|
||||
local qt = item:GetData("qt")
|
||||
qt[item:GetData("zone", 1)][item:GetData("ch", 1)] = data[1]
|
||||
item:SetData("qt", qt)
|
||||
item:UpdateChannel()
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return !IsValid(item.entity)
|
||||
end
|
||||
}
|
||||
79
gamemodes/helix/plugins/radio/items/radio/sh_lrr.lua
Normal file
79
gamemodes/helix/plugins/radio/items/radio/sh_lrr.lua
Normal file
@@ -0,0 +1,79 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Radio Longue Portée"
|
||||
ITEM.model = Model("models/props_lab/citizenradio.mdl")
|
||||
ITEM.description = "A big powerful long-range radio allowing for communication across large distances - or through thick obstructions."
|
||||
|
||||
ITEM.height = 4
|
||||
ITEM.width = 3
|
||||
|
||||
function ITEM:GetChannel(bForce)
|
||||
if (bForce or self:GetData("enabled")) then
|
||||
return self:GetData("channel", "freq_10")
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnInstanced()
|
||||
self:SetData("channel", "freq_11")
|
||||
self:UpdateChannel("10")
|
||||
end
|
||||
|
||||
function ITEM:UpdateChannel(newFreq)
|
||||
local client = self:GetOwner()
|
||||
local oldChannel = client and self:GetChannel()
|
||||
self:SetData("channel", "freq_"..newFreq)
|
||||
|
||||
if (client and self:GetChannel() != oldChannel) then
|
||||
ix.radio:RemoveListenerFromChannel(client, oldChannel)
|
||||
ix.radio:AddListenerToChannel(client, self:GetChannel())
|
||||
end
|
||||
end
|
||||
|
||||
ITEM.functions.setRadioFrequency = {
|
||||
name = "Set Frequency",
|
||||
icon = "icon16/transmit.png",
|
||||
OnClick = function(item)
|
||||
local freq = item:GetChannel(true)
|
||||
local freqText = freq and string.match(freq, "^freq_(%d%d)$") or ""
|
||||
Derma_StringRequest("Select Frequency", "Please enter the frequency you wish to switch to:", freqText, function(text)
|
||||
local newFreq = tonumber(text)
|
||||
if (string.len(text) == 2 and newFreq and newFreq >= 10) then
|
||||
net.Start("ixInventoryAction")
|
||||
net.WriteString("setRadioFrequency")
|
||||
net.WriteUInt(item.id, 32)
|
||||
net.WriteUInt(item.invID, 32)
|
||||
net.WriteTable({text})
|
||||
net.SendToServer()
|
||||
elseif (IsValid (item.player)) then
|
||||
item.player:Notify("Please enter a frequency between 10 and 99")
|
||||
end
|
||||
end)
|
||||
|
||||
return false
|
||||
end,
|
||||
OnRun = function(item, data)
|
||||
if (!data or !data[1]) then return false end
|
||||
local newFreq = tonumber(data[1])
|
||||
if (string.len(data[1]) != 2 or !newFreq or newFreq < 10) then return false end
|
||||
|
||||
item:UpdateChannel(data[1])
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
if (IsValid(item.entity)) then return false end
|
||||
|
||||
return true
|
||||
end
|
||||
}
|
||||
97
gamemodes/helix/plugins/radio/items/radio/sh_old_radio.lua
Normal file
97
gamemodes/helix/plugins/radio/items/radio/sh_old_radio.lua
Normal file
@@ -0,0 +1,97 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Radio de fortune"
|
||||
ITEM.model = Model("models/willardnetworks/skills/handheld_radio.mdl")
|
||||
ITEM.description = "Radio de fortune qui ne prend en charge que les fréquences analogiques."
|
||||
ITEM.category = "Radios"
|
||||
|
||||
function ITEM:OnInstanced()
|
||||
self:SetData("qt", {})
|
||||
self:UpdateChannel()
|
||||
end
|
||||
|
||||
function ITEM:UpdateChannel()
|
||||
local client = self:GetOwner()
|
||||
local oldChannel = client and self:GetChannel()
|
||||
|
||||
local channel = self:GetData("ch", 1)
|
||||
local qt = self:GetData("qt")
|
||||
self:SetData("channel", "freq_1_"..channel.."_"..(qt[channel] or channel))
|
||||
|
||||
if (client and self:GetChannel() != oldChannel) then
|
||||
ix.radio:RemoveListenerFromChannel(client, oldChannel)
|
||||
ix.radio:AddListenerToChannel(client, self:GetChannel())
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:GetChannel(bForce)
|
||||
if (bForce or self:GetData("enabled")) then
|
||||
return self:GetData("channel")
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
ITEM.functions.channel = {
|
||||
name = "Définir channel",
|
||||
isMulti = true,
|
||||
multiOptions = function(item, player)
|
||||
local channels = {}
|
||||
for i = 1, 16 do
|
||||
channels[i] = {name = i, data = {i}}
|
||||
end
|
||||
|
||||
return channels
|
||||
end,
|
||||
OnRun = function(item, data)
|
||||
item:SetData("ch", data[1])
|
||||
item:UpdateChannel()
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return !IsValid(item.entity)
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.qt = {
|
||||
name = "Définir QT",
|
||||
OnClick = function(item)
|
||||
local channel = item:GetData("ch", 1)
|
||||
local text = "Ton QT"
|
||||
|
||||
local qt = item:GetData("qt")
|
||||
Derma_StringRequest(text, "Que souhaitez-vous définir "..text.." pour ? 1-16", qt[channel] or channel,
|
||||
function(newQT)
|
||||
newQT = math.floor(tonumber(newQT))
|
||||
if (newQT < 1 or newQT > 16) then return end
|
||||
|
||||
net.Start("ixInventoryAction")
|
||||
net.WriteString("qt")
|
||||
net.WriteUInt(item.id, 32)
|
||||
net.WriteUInt(item.invID, 32)
|
||||
net.WriteTable({newQT})
|
||||
net.SendToServer()
|
||||
end)
|
||||
end,
|
||||
OnRun = function(item, data)
|
||||
local qt = item:GetData("qt")
|
||||
qt[item:GetData("ch", 1)] = data[1]
|
||||
item:SetData("qt", qt)
|
||||
item:UpdateChannel()
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return !IsValid(item.entity)
|
||||
end
|
||||
}
|
||||
18
gamemodes/helix/plugins/radio/items/radio_m2/sh_lrr_mc.lua
Normal file
18
gamemodes/helix/plugins/radio/items/radio_m2/sh_lrr_mc.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
ITEM.name = "Multi-Channel Long-Range Radio"
|
||||
ITEM.model = Model("models/props_lab/citizenradio.mdl")
|
||||
ITEM.description = "A big powerful long-range radio allowing for communication across large distances - or through thick obstructions. It has multiple channels"
|
||||
ITEM.category = "Radio"
|
||||
|
||||
ITEM.height = 4
|
||||
ITEM.width = 4
|
||||
Reference in New Issue
Block a user