• Youtube Player, Simple chat command.
    2 replies, posted
So, I'm trying to make this code take the link that I say after and play it as the url on the DFrame, but the command isn't even registering. I am running this on single player I don't know if this is the problem [CODE] function grapes() local frame = vgui.Create( "DFrame" ) frame:SetTitle( "youtube" ) frame:SetSize( ScrW() * 0.75, ScrH() * 0.75 ) frame:Center() frame:MakePopup() local html = vgui.Create( "HTML", frame ) html:Dock( FILL ) html:OpenURL( DankMemes() ) end function chatCommand( ply, text, public ) if (string.sub(text, 1, 8) == "/player") then DankMemes = string.sub( text, 8 ) grapes() return "Now Playing: " .. string.sub( text, 8 ) end end hook.Add( "PlayerSay", "chatCommand", chatCommand ); [/CODE]
PlayerSay is a serverside hook. Use [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/GM/OnPlayerChat"]GM:OnPlayerChat[/URL]. You might also want to fix your indentation.
Yeah I noticed that after I posted after looking at the playersay hook on the wiki, I guess I will just use it on my server 2 test. [editline]11th November 2017[/editline] So, now I have this, but when I try it with just /playnow it says grapes() returns a nill value, and when I type a url at then end, it just says nothing, and my gamemode says it's not a command [CODE] function grapes() local frame = vgui.Create( "DFrame" ) frame:SetTitle( "youtube" ) frame:SetSize( ScrW() * 0.75, ScrH() * 0.75 ) frame:Center() frame:MakePopup() local html = vgui.Create( "HTML", frame ) html:Dock( FILL ) html:OpenURL( DankMemes() ) end hook.Add( "PlayerSay", "PlayerSayExample", function( ply, text, team ) if ( string.lower( text ) == "/playnow" ) then local DankMemes = string.sub( text, 9 ) grapes() return "Now Playing: " .. string.sub( text, 9 ) end end ) [/CODE]
Sorry, you need to Log In to post a reply to this thread.