I'm having trouble... I want to make a timer that announces the time war (DoctorWhoRP) yet have ulx functions with sound, It does not appear in game.
timewar.lua:
--------------------------
-- BY RYANM2711
--------------------------
if SERVER then
AddCSLuaFile()
resource.AddFile("sound/TimeWarStart.mp3")
end
DoctorWhoRP_Options = 1
DoctorWhoRP_OptionsList = {
"ADD HERE | Location: Time 1",
}
if SERVER then
timer.Create("TimeWarStart"),720,0function()
DoctorWhoRP_Options = DoctorWhoRP_OptionsList + 1
if DoctorWhoRP_Options ? table.Count(DoctorWhoRP_OptionsList) then DoctorWhoRP_Options = 1 end
for k,ply in pairs(player.GetAll()) do
ply:SetNWFloat( "DWRP_Options", DoctorWhoRP_Options )
ply:SendLua("surface.PlaySound(\"TimeWarStart.mp3\")")
end
end)
function TimeWarMenu(timewar,time,force)
if not force then
timer.Create("NextTimerEventBegins",timer.TimeLeft("TimeWarEnds"),1,function()
timer.Stop("TimeWarEnds")
net.Start("TimeWarClientComm")
net.WriteString(timewar)
net.WriteBool(true)
net.WriteBool(false)
net.Broadcast()
table.insert(timewar)
for k,ply in pairs(player.GetAll()) do
ply:SendLua("surface.PlaySound(\"TimeWarStart.mp3\")")
ply:SetNWFloat("DWRP_Options",table.Count(DoctorWhoRP_OptionsList))
end
timer.Create("RestoreTimeWarStart",time,1,function()
net.Start("TimeWarClientComm")
net.WriteString(timewar)
net.WriteBool(false)
net.WriteBool(true)
net.Broadcast()
table.RemoveByValue(timewar)
timer.Remove("NextTimerEventBegins")
timer.Start("TimeWarStart")
if not DoctorWhoRP_Options == table.Count(DoctorWhoRP_OptionsList) then
DoctorWhoRP_Options = DoctorWhoRP_Options + 1
else
DoctorWhoRP_Options = 1
end
for k,ply in pairs(player.GetAll()) do
SetNWFloat("DWRP_Options",DoctorWhoRP_Options)
end
timer.Remove("TimeWarStart")
end)
end)
else
timer.Stop("TimeWarStart")
net.Start("TimeWarClientComm")
net.WriteString(timewar)
net.WriteBool(false)
net.WriteBool(true)
net.Broadcast()
table.RemoveByValue( DoctorWhoRP_OptionsList, timewar )
timer.Start("TimeWarStart")
if not DoctorWhoRP_Options == table.Count(DoctorWhoRP_OptionsList) then
DoctorWhoRP_Options = DoctorWhoRP_Options + 1
else
DoctorWhoRP_Options = 1
end
for k,ply in pairs(player.GetAll()) do
ply:SetNWFloat("DWRP_Options",DoctorWhoRP_Options)
end
timer.Remove("TimeWarStart")
end)
end
end
net.Receive("TimeWarComm"),function()
TimeWarMenu(net.ReadString(),net.ReadInt(16),net.ReadBool())
end)
timer.Create("UpdateTimeLeft",1,0,function()
if timer.Exists("TimeWarStart") then
for _,ply in pairs(player.GetAll()) do
ply:SetNWInt("DWRP_CTimeLeft",math.Round(timer.TimeLeft("TimeWarEnds")))
end
else
for _,ply in pairs(player.GetAll()) do
ply:SetNWInt("DWRP_CTimeLeft",math.Round(timer.TimeLeft("TimeWarStart")))
end
end
end)
local function PlyInitSpawn(ply)
ply:SetNWFloat( "DWRP_Options", DoctorWhoRP_Options )
end
hook.Add("PlayerInitialSpawn","SyncClass",PlyInitSpawn)
else
hook.Add("HUDPaint","DrawClassDisplay",function()
if DoctorWhoRP_OptionsList[LocalPlayer():GetNWFloat("DWRP_Class")] != nil then
surface.SetFont("Trebuchet24")
local time_text = string.Explode("|",DoctorWhoRP_OptionsList[LocalPlayer():GetNWFloat("DWRP_Class")])
if #time_text > 1 then
local size = math.max(surface.GetTextSize(time_text[1]),surface.GetTextSize(time_text[2]))
hg_text_add = 9 + size + 9
hg_text_add2 = 9 + size + 9
else
hg_text_add = 400
hg_text_add2 = 0
end
draw.RoundedBoxEx(6,9,20,hg_text_add,70,Color(0,0,0,210),false,true,false,true)
draw.RoundedBoxEx(6,9,90,hg_text_add2,70,Color(0,0,0,210),false,true,false,true)
draw.SimpleText(class_text[1],"Trebuchet24",20,43,Color(255,255,255,255))
draw.SimpleText(class_text[2] or "","Trebuchet24",15,113,Color(255,255,255,255))
if hg_text_add2 == 0 then
draw.RoundedBoxEx(6,9,98,400,70,Color(0,0,0,210),false,true,false,true)
draw.SimpleText("TimeWar ends in: "..LocalPlayer():GetNWInt("DWRP_CTimeLeft"),"Trebuchet24",20,121,Color(255,255,255,255))
else
draw.RoundedBoxEx(6,9,176,400,70,Color(0,0,0,210),false,true,false,true)
draw.SimpleText("TimeWar ends in: "..LocalPlayer():GetNWInt("DWRP_CTimeLeft"),"Trebuchet24",20,199,Color(255,255,255,255))
end
end
end)
net.Receive("TimeWarClientComm",function()
local name = net.ReadString()
local write = net.ReadBool()
local remove = net.ReadBool()
if write and not remove then
table.insert(DoctorWhoRP_OptionsList, name )
end
end)
timewar_svcheck.lua:
util.AddNetworkString("AllowtimerMenu")
util.AddNetworkString("TimeWarComm")
util.AddNetworkString("TimeWarClientComm")
hook.Add( "PlayerSay", "TimerServersideCheck", function( ply, text)
if ( string.sub( string.lower(text), 1, 11 ) == "/timewar" or string.sub( string.lower(text), 1, 11 ) == "!timewar" ) then
if ply:IsSuperAdmin() or ply:IsAdmin() then
net.Start("AllowtimerMenu")
net.WriteString("pass")
net.Send(ply)
end
return ""
end
end )
timewar_adminpanel.lua:
net.Receive("AllowtimerMenu",function()
if not net.ReadString() == "pass" then return end
local DP = vgui.Create( "DFrame" )
DP:SetSize( 500,250 )
DP:SetPos( ScrW()/2 - DP:GetWide()/2, ScrH()/2 - DP:GetTall()/2 )
DP:SetTitle( " " )
DP:SetDraggable( false )
DP:MakePopup()
DP:ShowCloseButton( false )
function DP:Paint( w, h )
draw.RoundedBoxEx( 6, 0, 0, w, h, Color(192,197,206),false,false,true,true)
draw.RoundedBox( 0, 0, 0, w, 20, Color(79,91,102) )
end
local title = vgui.Create( "DLabel", DP )
title:SetTextColor(Color(167,173,186))
title:SetFont("Trebuchet18")
title:SetText( "Time system admin panel" )
title:SizeToContents()
title:SetPos( DP:GetWide()/2 - title:GetWide()/2,2.5 )
local close = vgui.Create( "DButton", DP )
close:SetText( "X" )
close:SetSize( 20, 20 )
close:SetPos( DP:GetWide() - close:GetWide(), 0 )
close.DoClick = function()
DP:Close()
end
function close:Paint(w,h)
draw.RoundedBox( 0, 0, 0, w, h, Color(101,115,126) )
end
local entry = vgui.Create( "DTextEntry", DP )
entry:SetSize( 150, 20 )
entry:SetPos( DP:GetWide()/2 - entry:GetWide()/2, DP:GetTall()/2 - entry:GetTall()/2 - 30 )
entry:SetText( "" )
local classname = vgui.Create( "DLabel", DP )
classname:SetTextColor(Color(79,91,102))
classname:SetFont("Trebuchet18")
classname:SetText( "Class name" )
classname:SizeToContents()
classname:SetPos( DP:GetWide()/2 - entry:GetWide() , DP:GetTall()/2 - classname:GetTall()/2 - 30 )
local tentry = vgui.Create( "DTextEntry", DP )
tentry:SetSize( 50, 20 )
tentry:SetPos( DP:GetWide()/2 - entry:GetWide()/2, DP:GetTall()/2 - entry:GetTall()/2 )
tentry:SetText( "" )
local time = vgui.Create( "DLabel", DP )
time:SetTextColor(Color(79,91,102))
time:SetFont("Trebuchet18")
time:SetText( "Duration" )
time:SizeToContents()
time:SetPos( DP:GetWide()/2 - entry:GetWide() , DP:GetTall()/2 - time:GetTall()/2 )
local CB = vgui.Create( "DCheckBox" , DP )// Create the checkbox
CB:SetPos( DP:GetWide()/2 - entry:GetWide()/2, DP:GetTall()/2 - entry:GetTall()/2 + 30 )
CB:SetValue( 0 )
local force = vgui.Create( "DLabel", DP )
force:SetTextColor(Color(79,91,102))
force:SetFont("Trebuchet18")
force:SetText( "Force" )
force:SizeToContents()
force:SetPos( DP:GetWide()/2 - entry:GetWide() , DP:GetTall()/2 - classname:GetTall()/2 + 30)
local cl = vgui.Create( "DButton", DP )
cl:SetTextColor(Color(79,91,102))
cl:SetFont("Trebuchet18")
cl:SetText( "Complete" )
cl:SizeToContents()
cl:SetPos( DP:GetWide()/2 - cl:GetWide()/2 , DP:GetTall()/2 - cl:GetTall()/2 + 60)
cl.DoClick = function()
print(CB:GetChecked())
if not isnumber(tonumber(tentry:GetValue())) then
notification.AddLegacy( "Duration isnt a number or is empty", 1, 2 )
surface.PlaySound( "buttons/button2.wav" )
return false
end
net.Start("ClassTimerComm")
net.WriteString(entry:GetValue())
net.WriteInt(tentry:GetValue(),16)
net.WriteBool(CB:GetChecked())
net.SendToServer()
DP:Close()
end
function cl:Paint(w,h)
draw.RoundedBox( 0, 0, 0, w, h, Color(167,173,186) )
end
end)
ULX:
local function cac (ply)
if not ply:IsValid() then
Msg ("Ey, du kannst keine Events von der Konsole Starten!.\n")
return
end
ply:ConCommand ("/classtimer")
end
local command = ulx.command ("Menus", "ulx timewar", timewar)
command:defaultAccess (ULib.ACCESS_ALL)
command:help ("Shows the Timewar event screen")
Your ULX command function says timewar yet the function is called cac
Last box
Still doesn't work I changed cac to ulx
Sorry, you need to Log In to post a reply to this thread.