Files
wnsrc/gamemodes/darkrp/plugins/ln_songplayer/sh_plugin.lua
lifestorm df294d03aa Upload
2024-08-04 23:54:45 +03:00

92 lines
2.1 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--[[
| 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/
--]]
PLUGIN.name = "Song Player"
PLUGIN.author = "'impulse, DevulTj, Erin & Aspect™"
PLUGIN.description = "Adds a Song Player, allowing to play videos from YouTube."
ix.util.Include("cl_hooks.lua")
ix.util.Include("cl_plugin.lua")
ix.util.Include("sv_plugin.lua")
ix.lang.AddTable("english", {
cmdPlaySong = "Sunucudaki her oyuncu için YouTube'dan bir şarkı çalın.",
cmdStopSong = "Geçerli YouTube şarkısını durdurma.",
songPlaying = "Bir şarkı çalmaya başladınız.",
songStopped = "Geçerli şarkıyı durdurdunuz.",
invalidURL = "Bu geçerli bir YouTube video URL'si değil!"
})
do
local COMMAND = {}
COMMAND.description = "@cmdPlaySong"
COMMAND.adminOnly = true
COMMAND.arguments = {
ix.type.string,
bit.bor(ix.type.number, ix.type.optional),
bit.bor(ix.type.number, ix.type.optional)
}
COMMAND.argumentNames = {
"Song URL",
"Start Time",
"Radius"
}
function COMMAND:OnRun(client, url, time, radius)
time = time or 0
if (!string.find(url, "https://www.youtube.com/watch?v", 1, true) and !string.find(url, "https://youtu.be/", 1, true)) then
return "@invalidURL"
end
if (radius) then
local receivers = {}
for _, player in pairs(ents.FindInSphere(client:GetPos(), radius)) do
if (!IsValid(player) or !player:IsPlayer()) then continue end
receivers[#receivers + 1] = player
end
net.Start("lnSongPlayerPlay")
net.WriteString(url)
net.WriteFloat(time)
net.Send(receivers)
else
net.Start("lnSongPlayerPlay")
net.WriteString(url)
net.WriteFloat(time)
net.Broadcast()
end
return "@songPlaying"
end
ix.command.Add("PlaySong", COMMAND)
end
do
local COMMAND = {}
COMMAND.description = "@cmdStopSong"
COMMAND.adminOnly = true
function COMMAND:OnRun(client)
net.Start("lnSongPlayerStop")
net.Broadcast()
return "@songStopped"
end
ix.command.Add("StopSong", COMMAND)
end