• Making this script for TEAM_DJ only? *DarkRP*
    3 replies, posted
Would anyone know how to make this script for the team DJ only (TEAM_DJ)? It would be much appreciated if you could help me with this (this is for DarkRP) [lua] //Addon created by Overlord Spamalot if SERVER then AddCSLuaFile("gtube.lua") util.AddNetworkString("GTubePlay") util.AddNetworkString("GTubeStop") net.Receive("GTubePlay",function(len,ply) if(!ply:IsAdmin())then return end net.Start("GTubePlay") net.WriteString(net.ReadString()) net.Broadcast() end) net.Receive("GTubeStop",function(len,ply) if(!ply:IsAdmin())then return end net.Start("GTubeStop") net.Broadcast() end) print("Server Loaded G-Tube Player!") else surface.CreateFont("GTubeFont",{ font = "UiBold", size = ScreenScale(10), weight = 300, antialias = true, shadow = false}) local Enabled=CreateClientConVar("gtube_enabled",1,true,false) local URL=CreateClientConVar("gtube_url","",false,false) local Playing=false local StartTime=0 local SongLength=0 local SongName="" local function GtubeParseYoutube(str) if string.find(str,"youtube")!=nil then str=string.match(str,"[?&]v=([^&]*)") end return str end local function secToTime(sec) local m=math.floor(sec/60) local s=tostring(math.floor(sec-m*60)) if string.len(s)==1 then s="0"..s end return m..":"..s end local function GtubeMsg(str) chat.AddText(Color(0,255,255),"[G-Tube Player] ",Color(255,255,255),str) end local function GtubeErr(str) chat.AddText(Color(255,0,0),"[G-Tube Player]",Color(200,0,0)," ERROR: "..str) end local function GtubePanel(Panel) Panel:ClearControls() Panel:AddControl("CheckBox",{Label = "Enabled",Command = "gtube_enabled"}) if(LocalPlayer():IsAdmin())then Panel:AddControl("Textbox",{Label = "Youtube URL: ",Command = "gtube_url"}) Panel:AddControl("Button",{Label = "Play",Command = "gtube_play"}) Panel:AddControl("Button",{Label = "Stop",Command = "gtube_stop"}) end end hook.Add("PopulateToolMenu","G-TubePAMenu",function() spawnmenu.AddToolMenuOption("Utilities","G-Tube","G-Tube Player","#G-Tube Player","","",GtubePanel) end) html = vgui.Create("HTML") html:SetEnabled(true) html:SetPos(0,0) html:SetSize(0,0) html:SetPaintedManually(true) html:SetMouseInputEnabled(false) html:OpenURL("http://www.youtube.com/v/") local function PlaySong(URI) if(Enabled:GetBool())then http.Fetch("http://gdata.youtube.com/feeds/api/videos/"..URI,function(data,code,headers) SongName=string.match(data,"<title type='text'>([^<]+)</title>") SongLength=tonumber(string.match(data,"<yt:duration seconds='([^<]+)'/>")) if SongName==nil or SongLength==nil then SongName="" SongLength=0 GtubeErr("Could not load URI: "..URI) else GtubeMsg("Playing: "..SongName.." ("..URI..")") Playing=true StartTime=RealTime() html:OpenURL("http://youtube.googleapis.com/v/"..URI.."&autoplay=1&enablejsapi=1") end end,nil) end end local function StopSong() if(Playing)then html:OpenURL("http://www.youtube.com/v/") Playing=false GtubeMsg("Audio stopped.") end end local function GtubeHUD() if Playing and !Enabled:GetBool() then StopSong() end if RealTime()-StartTime >= SongLength+5 and Playing then StopSong() end if Playing then local w=string.len(SongName)*12 draw.RoundedBox(0,ScrW()/2-w/2,10,w,20,Color(30,190,190,255)) draw.SimpleText(SongName,"GTubeFont",ScrW() / 2,21,Color(0,0,0,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER) draw.RoundedBox(0,ScrW()/2-110/2,30,110,20,Color(200,200,200,150)) draw.SimpleText(secToTime(RealTime()-StartTime).."/"..secToTime(SongLength),"GTubeFont",ScrW() / 2,41,Color(0,0,0,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER) surface.SetDrawColor(0,0,0,255) surface.DrawLine(ScrW()/2-w/2,10,ScrW()/2+w/2,10) surface.DrawLine(ScrW()/2+w/2,10,ScrW()/2+w/2,30) surface.DrawLine(ScrW()/2-w/2,10,ScrW()/2-w/2,30) surface.DrawLine(ScrW()/2-w/2,30,ScrW()/2-45,30) surface.DrawLine(ScrW()/2-45,30,ScrW()/2+w/2,30) surface.DrawLine(ScrW()/2-55,30,ScrW()/2-55,50) surface.DrawLine(ScrW()/2+55,30,ScrW()/2+55,50) surface.DrawLine(ScrW()/2-55,50,ScrW()/2+55,50) end end hook.Add("HUDPaint","GtubePAHUD",GtubeHUD) concommand.Add("gtube_play",function(ply,c,args) net.Start("GTubePlay") net.WriteString(GtubeParseYoutube(URL:GetString())) net.SendToServer() end) concommand.Add("gtube_stop",function(ply,c,args) net.Start("GTubeStop") net.SendToServer() end) net.Receive("GTubePlay",function(len) PlaySong(net.ReadString()) end) net.Receive("GTubeStop",function(len) StopSong() end) print("Client Loaded G-Tube Player!") end [/lua] Thank you! [editline]10th December 2012[/editline] Nevermind.
I dont do much Lua but wouldn't it be something like this? [code]if !ply:IsTeam("TEAM_DJ") then return end[/code] [b][i]Edited:[/b][/i] Nevermind
It would be if ply:Team() ~= TEAM_DJ then return end :P
Haha thanks for the help, but I realized that I should not use this script because there is no radio entity :P
Sorry, you need to Log In to post a reply to this thread.