Problem with datastream

Hello world,

I have a problem with my datastream
I make hook on “jukebox_maj” on client but when I send from the server,

it return “DataStreamClient: Unhandled stream jukebox_maj!”

But I already make other datastream. I have a limit of datastream ?

Are you sure the code with the hook runs? AddCSLuaFile doesn’t make the Lua file automatically run.

but if it downloads to the autorun file :science:

:wtc: the last 5 of your posts I have read have been complete gibberish.

@OP: Post your code please.

[lua]jukebox_hud = { };
local sound_name = “Aucun son actuellement !”;
local sound_time = 0;
local sound_timeMax = 0;
local sound_timeStr = “”;
local sound_actName = “”;

local function clr( color ) return color.r, color.g, color.b, color.a; end

function jukebox_hud:PaintBar( x, y, w, h, colors, value )

self:PaintPanel( x, y, w, h, colors );

x = x + 1; y = y + 1;
w = w - 2; h = h - 2;

local width = w * math.Clamp( value, 0, 1 );
local shade = 4;

surface.SetDrawColor( clr( colors.shade ) );
surface.DrawRect( x, y, width, shade );

surface.SetDrawColor( clr( colors.fill ) );
surface.DrawRect( x, y + shade, width, h - shade );

end

function jukebox_hud:PaintPanel( x, y, w, h, colors )

surface.SetDrawColor( clr( colors.border ) );
surface.DrawOutlinedRect( x, y, w, h );

x = x + 1; y = y + 1;
w = w - 2; h = h - 2;

surface.SetDrawColor( clr( colors.background ) );
surface.DrawRect( x, y, w, h );

end

function jukebox_hud:PaintText( x, y, text, font, colors )

surface.SetFont( font );

surface.SetTextPos( x + 1, y + 1 );
surface.SetTextColor( clr( colors.shadow ) );
surface.DrawText( text );

surface.SetTextPos( x, y );
surface.SetTextColor( clr( colors.text ) );
surface.DrawText( text );

end

function jukebox_hud:TextSize( text, font )

surface.SetFont( font );
return surface.GetTextSize( text );

end

local vars =
{

font = "Trebuchet18",

padding = 10,
margin = 35,

text_spacing = 2,
bar_spacing = 5,

bar_height = 8,

width = 0.25

};

local colors =
{

background =
{

	border = Color( 10,10,100,230 ),
	background = Color( 150,150,250,200 )

},

text =
{

	shadow = Color( 0, 0, 0, 200 ),
	text = Color( 255, 255, 255, 255 )

},

jukebox_bar =
{

	border = Color( 10,10,100,230 ),
	background = Color( 150,150,250,200 ),
	shade = Color( 255, 104, 104, 255 ),
	fill = Color( 232, 0, 0, 255 )

}

};

function HUDJukeBoxPaint()

client = client or LocalPlayer( );				-- set a shortcut to the client
--if( !client:Alive( ) ) then return; end				-- don't draw if the client is dead

local _, th = jukebox_hud:TextSize( "TEXT", vars.font );		-- get text size( height in this case )

local width = 250;				-- calculate width
local bar_width = 240;			-- calculate bar width and element height
local height = 60;

local x = ScrW()/2-width/2;						-- get x position of element
local y = 10;			-- get y position of element

local cx = x + vars.padding;					-- get x and y of contents
local cy = y + vars.padding;

jukebox_hud:PaintPanel( x, y, width, height, colors.background );	-- paint the background panel

local by = th + vars.text_spacing;	

local text = string.format( "%s", sound_name );	-- get health text
jukebox_hud:PaintText( cx, cy, text, vars.font, colors.text );	-- paint health text and health bar	

cy = cy + vars.padding*2;	

local text = string.format( "%s", sound_timeStr );	-- get health text	
jukebox_hud:PaintBar( cx-5, cy, bar_width, vars.bar_height, colors.jukebox_bar, (sound_time/sound_timeMax) );

if(text == "") then
	text = "00:00";
end

cy = cy + vars.padding;
jukebox_hud:PaintText( x+5, cy, text, vars.font, colors.text );	-- paint health text and health bar	

end

hook.Add(“HUDPaint”, “HUDJukeBoxPaint”, HUDJukeBoxPaint);

– JukeBox HTML System
local jukebox_frame = vgui.Create(“DFrame”);
jukebox_frame:SetPos( 50,50 );
jukebox_frame:SetSize( 300, 200 );
jukebox_frame:SetTitle( “JukeBox Frame” );
jukebox_frame:SetVisible( false );
jukebox_frame:SetDraggable( true );
jukebox_frame:ShowCloseButton( true );
jukebox_frame:MakePopup();

local html = vgui.Create(“HTML”, jukebox_frame);
html:SetSize( jukebox_frame:GetWide() - 20, jukebox_frame:GetTall()- 50);
html:SetPos( 10, 30 ) ;

require(“datastream”);

function jukebox_setVars(handler, id, encoded, decoded)
if(decoded[1] != sound_actName) then
html:OpenURL(“http://217.16.8.44/playSound.php?s="..decoded[1].."&from=”…decoded[2]-1);
sound_actName = decoded[1];
end

if(decoded[1] != "Aucun son actuellement !") then
	sound_name = decoded[1].." ( "..string.ToMinutesSeconds(decoded[3]).." )";
else
	sound_name = "Aucun son actuellement !";
end

sound_timeStr = string.ToMinutesSeconds(decoded[2]);

sound_time = tonumber(decoded[2]);
sound_timeMax = tonumber(decoded[3]);

end
datastream.Hook( “SSKjukeboxMAJ”, jukebox_setVars );

– Panel d’administration

local DermaListView;
local DermaListView2;

function getPlayList(handler, id, encoded, decoded)
for k,v in pairs(decoded[1]) do
local jukebox_titre = string.Explode(".", v );
local jukebox_titre2 = string.Explode(" - ", jukebox_titre[1] );

	DermaListView:AddLine(jukebox_titre2[1], jukebox_titre2[2]);		
end

end
datastream.Hook( “getPlayList”, getPlayList );

– Permet d’encoder un fichier en url
function url_encode(str)
if (str) then
str = string.gsub (str, "
“, "
“)
str = string.gsub (str, “([^%w ])”,
function © return string.format (”%%%02X”, string.byte©) end)
str = string.gsub (str, " ", “+”)
end
return str
end

local list = {}

function biblioGet(contents , size)
local tablet = string.Explode("||", contents);

for k,v in pairs(tablet) do
	local jukebox_titre = string.Explode(".", v );
	local jukebox_titre2 = string.Explode(" - ", jukebox_titre[1] );

	DermaListView2:AddLine(jukebox_titre2[1], jukebox_titre2[2]);
	table.Add(list, {v});
end

end

function openBiblioWin()
local window = vgui.Create(“DFrame”);

window:SetPos( 50,50 ) -- Position on the players screen
window:SetSize( 600, 400 ) -- Size of the frame
window:SetTitle( "JukeBox Bibliothèque" ) -- Title of the frame
window:SetVisible( true )
window:SetDraggable( true ) -- Draggable by mouse?
window:ShowCloseButton( true ) -- Show the close button?
window:MakePopup() -- Show the frame	

DermaListView2 = vgui.Create("DListView");
DermaListView2:SetParent(window);
DermaListView2:SetPos(25, 25);
DermaListView2:SetSize(550, 340);
DermaListView2:SetMultiSelect(false);
DermaListView2:AddColumn("Artiste");
DermaListView2:AddColumn("Morceau");	

http.Get("http://217.16.8.44/allSound.php", "", biblioGet);

local btnAdd = vgui.Create("DButton", window);
btnAdd:SetSize( 150, 25 );
btnAdd:SetPos( 25, 370 );
btnAdd:SetText( "Ajouter cette musique" );
btnAdd.DoClick = function( button )
	local nb = DermaListView2:GetSelectedLine( )
	datastream.StreamToServer( "addToPlayList", {list[nb]} );
end

end

function JBWindow()
local window = vgui.Create(“DFrame”);

window:SetPos( 50,50 ) -- Position on the players screen
window:SetSize( 600, 400 ) -- Size of the frame
window:SetTitle( "JukeBox PlayList" ) -- Title of the frame
window:SetVisible( true )
window:SetDraggable( true ) -- Draggable by mouse?
window:ShowCloseButton( true ) -- Show the close button?
window:MakePopup() -- Show the frame	

DermaListView = vgui.Create("DListView");
DermaListView:SetParent(window);
DermaListView:SetPos(25, 25);
DermaListView:SetSize(550, 340);
DermaListView:SetMultiSelect(false);
DermaListView:AddColumn("Artiste");
DermaListView:AddColumn("Morceau");	

datastream.StreamToServer( "givePlayList", {} );

local btnAdd = vgui.Create("DButton", window);
btnAdd:SetSize( 150, 25 );
btnAdd:SetPos( 25, 370 );
btnAdd:SetText( "Ajouter une musique" );
btnAdd.DoClick = function( button )
	openBiblioWin();
end

end

concommand.Add( “JBPanel”, JBWindow);[/lua]

There is the client lua autorun file :stuck_out_tongue:

And the lua server work :stuck_out_tongue:

Can you find my error ?

The hook is named “SSKjukeboxMAJ” not “jukebox_maj”

Oopss, it is a old release but I have change the hook and it do the same error

You can’t really expect us to fix this based on an old release; post the current code. Also, separate the client and server parts into 2 lua code boxes because it is very confusing…

Ok I post the 2 lua with SSKjukeboxMAJ

Client-side :
[lua]jukebox_hud = { };
local sound_name = “Aucun son actuellement !”;
local sound_time = 0;
local sound_timeMax = 0;
local sound_timeStr = “”;
local sound_actName = “”;

local function clr( color ) return color.r, color.g, color.b, color.a; end

function jukebox_hud:PaintBar( x, y, w, h, colors, value )

self:PaintPanel( x, y, w, h, colors );

x = x + 1; y = y + 1;
w = w - 2; h = h - 2;

local width = w * math.Clamp( value, 0, 1 );
local shade = 4;

surface.SetDrawColor( clr( colors.shade ) );
surface.DrawRect( x, y, width, shade );

surface.SetDrawColor( clr( colors.fill ) );
surface.DrawRect( x, y + shade, width, h - shade );

end

function jukebox_hud:PaintPanel( x, y, w, h, colors )

surface.SetDrawColor( clr( colors.border ) );
surface.DrawOutlinedRect( x, y, w, h );

x = x + 1; y = y + 1;
w = w - 2; h = h - 2;

surface.SetDrawColor( clr( colors.background ) );
surface.DrawRect( x, y, w, h );

end

function jukebox_hud:PaintText( x, y, text, font, colors )

surface.SetFont( font );

surface.SetTextPos( x + 1, y + 1 );
surface.SetTextColor( clr( colors.shadow ) );
surface.DrawText( text );

surface.SetTextPos( x, y );
surface.SetTextColor( clr( colors.text ) );
surface.DrawText( text );

end

function jukebox_hud:TextSize( text, font )

surface.SetFont( font );
return surface.GetTextSize( text );

end

local vars =
{

font = "Trebuchet18",

padding = 10,
margin = 35,

text_spacing = 2,
bar_spacing = 5,

bar_height = 8,

width = 0.25

};

local colors =
{

background =
{

	border = Color( 10,10,100,230 ),
	background = Color( 150,150,250,200 )

},

text =
{

	shadow = Color( 0, 0, 0, 200 ),
	text = Color( 255, 255, 255, 255 )

},

jukebox_bar =
{

	border = Color( 10,10,100,230 ),
	background = Color( 150,150,250,200 ),
	shade = Color( 255, 104, 104, 255 ),
	fill = Color( 232, 0, 0, 255 )

}

};

function HUDJukeBoxPaint()

client = client or LocalPlayer( );				-- set a shortcut to the client
--if( !client:Alive( ) ) then return; end				-- don't draw if the client is dead

local _, th = jukebox_hud:TextSize( "TEXT", vars.font );		-- get text size( height in this case )

local width = 250;				-- calculate width
local bar_width = 240;			-- calculate bar width and element height
local height = 60;

local x = ScrW()/2-width/2;						-- get x position of element
local y = 10;			-- get y position of element

local cx = x + vars.padding;					-- get x and y of contents
local cy = y + vars.padding;

jukebox_hud:PaintPanel( x, y, width, height, colors.background );	-- paint the background panel

local by = th + vars.text_spacing;	

local text = string.format( "%s", sound_name );	-- get health text
jukebox_hud:PaintText( cx, cy, text, vars.font, colors.text );	-- paint health text and health bar	

cy = cy + vars.padding*2;	

local text = string.format( "%s", sound_timeStr );	-- get health text	
jukebox_hud:PaintBar( cx-5, cy, bar_width, vars.bar_height, colors.jukebox_bar, (sound_time/sound_timeMax) );

if(text == "") then
	text = "00:00";
end

cy = cy + vars.padding;
jukebox_hud:PaintText( x+5, cy, text, vars.font, colors.text );	-- paint health text and health bar	

end

hook.Add(“HUDPaint”, “HUDJukeBoxPaint”, HUDJukeBoxPaint);

– JukeBox HTML System
local jukebox_frame = vgui.Create(“DFrame”);
jukebox_frame:SetPos( 50,50 );
jukebox_frame:SetSize( 300, 200 );
jukebox_frame:SetTitle( “JukeBox Frame” );
jukebox_frame:SetVisible( false );
jukebox_frame:SetDraggable( true );
jukebox_frame:ShowCloseButton( true );
jukebox_frame:MakePopup();

local html = vgui.Create(“HTML”, jukebox_frame);
html:SetSize( jukebox_frame:GetWide() - 20, jukebox_frame:GetTall()- 50);
html:SetPos( 10, 30 ) ;

require(“datastream”);

function jukebox_setVars(handler, id, encoded, decoded)
if(decoded[1] != sound_actName) then
html:OpenURL(“http://217.16.8.44/playSound.php?s="..decoded[1].."&from=”…decoded[2]-1);
sound_actName = decoded[1];
end

if(decoded[1] != "Aucun son actuellement !") then
	sound_name = decoded[1].." ( "..string.ToMinutesSeconds(decoded[3]).." )";
else
	sound_name = "Aucun son actuellement !";
end

sound_timeStr = string.ToMinutesSeconds(decoded[2]);

sound_time = tonumber(decoded[2]);
sound_timeMax = tonumber(decoded[3]);

end
datastream.Hook( “SSKjukeboxMAJ”, jukebox_setVars );

– Panel d’administration

local DermaListView;
local DermaListView2;

function getPlayList(handler, id, encoded, decoded)
for k,v in pairs(decoded[1]) do
local jukebox_titre = string.Explode(".", v );
local jukebox_titre2 = string.Explode(" - ", jukebox_titre[1] );

	DermaListView:AddLine(jukebox_titre2[1], jukebox_titre2[2]);		
end

end
datastream.Hook( “getPlayList”, getPlayList );

– Permet d’encoder un fichier en url
function url_encode(str)
if (str) then
str = string.gsub (str, "
“, "
“)
str = string.gsub (str, “([^%w ])”,
function © return string.format (”%%%02X”, string.byte©) end)
str = string.gsub (str, " ", “+”)
end
return str
end

local list = {}

function biblioGet(contents , size)
local tablet = string.Explode("||", contents);

for k,v in pairs(tablet) do
	local jukebox_titre = string.Explode(".", v );
	local jukebox_titre2 = string.Explode(" - ", jukebox_titre[1] );

	DermaListView2:AddLine(jukebox_titre2[1], jukebox_titre2[2]);
	table.Add(list, {v});
end

end

function openBiblioWin()
local window = vgui.Create(“DFrame”);

window:SetPos( 50,50 ) -- Position on the players screen
window:SetSize( 600, 400 ) -- Size of the frame
window:SetTitle( "JukeBox Bibliothèque" ) -- Title of the frame
window:SetVisible( true )
window:SetDraggable( true ) -- Draggable by mouse?
window:ShowCloseButton( true ) -- Show the close button?
window:MakePopup() -- Show the frame	

DermaListView2 = vgui.Create("DListView");
DermaListView2:SetParent(window);
DermaListView2:SetPos(25, 25);
DermaListView2:SetSize(550, 340);
DermaListView2:SetMultiSelect(false);
DermaListView2:AddColumn("Artiste");
DermaListView2:AddColumn("Morceau");	

http.Get("http://217.16.8.44/allSound.php", "", biblioGet);

local btnAdd = vgui.Create("DButton", window);
btnAdd:SetSize( 150, 25 );
btnAdd:SetPos( 25, 370 );
btnAdd:SetText( "Ajouter cette musique" );
btnAdd.DoClick = function( button )
	local nb = DermaListView2:GetSelectedLine( )
	datastream.StreamToServer( "addToPlayList", {list[nb]} );
end

end

function JBWindow()
local window = vgui.Create(“DFrame”);

window:SetPos( 50,50 ) -- Position on the players screen
window:SetSize( 600, 400 ) -- Size of the frame
window:SetTitle( "JukeBox PlayList" ) -- Title of the frame
window:SetVisible( true )
window:SetDraggable( true ) -- Draggable by mouse?
window:ShowCloseButton( true ) -- Show the close button?
window:MakePopup() -- Show the frame	

DermaListView = vgui.Create("DListView");
DermaListView:SetParent(window);
DermaListView:SetPos(25, 25);
DermaListView:SetSize(550, 340);
DermaListView:SetMultiSelect(false);
DermaListView:AddColumn("Artiste");
DermaListView:AddColumn("Morceau");	

datastream.StreamToServer( "givePlayList", {} );

local btnAdd = vgui.Create("DButton", window);
btnAdd:SetSize( 150, 25 );
btnAdd:SetPos( 25, 370 );
btnAdd:SetText( "Ajouter une musique" );
btnAdd.DoClick = function( button )
	openBiblioWin();
end

end

concommand.Add( “JBPanel”, JBWindow);[/lua]

Server-side :
[lua]local jukebox_playlist = {};
local jukebox_maxid = 0;
local jukebox_currentid = 0;

local jukebox_isPlaying = 0;

local jukebox_currentTime = 0;
local jukebox_maxTime = 0;

– Permet d’encoder un fichier en url
function url_encode(str)
if (str) then
str = string.gsub (str, "
“, "
“)
str = string.gsub (str, “([^%w ])”,
function © return string.format (”%%%02X”, string.byte©) end)
str = string.gsub (str, " ", “+”)
end
return str
end

function httpCallBack(contents , size)
jukebox_maxTime = tonumber(contents);
end

function jukebox_playSound(str)
jukebox_isPlaying = 1;
http.Get(“http://217.16.8.44/length.php?mp3=”…url_encode(str), “”, httpCallBack);
end

function jukebox_stopSound()
–datastream.StreamToClients( player.GetAll( ), “SSKjukebox_openSound”, {jukebox_titre[1], jukebox_currentTime, jukebox_maxTime} );
end

– Fonction pour ajouter un son à la playlist
function jukebox_addSound(str)
jukebox_maxid = jukebox_maxid + 1;

jukebox_playlist[jukebox_maxid] = str;

end

– Gestion de la playlist
require(“datastream”);

function jukebox_gest_playlist()
if(jukebox_isPlaying == 1) then
jukebox_currentTime = jukebox_currentTime + 1;

	local jukebox_titre = string.Explode(".", jukebox_playlist[jukebox_currentid] );

	datastream.StreamToClients( player.GetAll( ), "SSKjukeboxMAJ", {jukebox_titre[1], jukebox_currentTime, jukebox_maxTime} );		
	
	if(jukebox_currentTime > jukebox_maxTime) then
		jukebox_isPlaying = 0;
	end
else		
	if(jukebox_playlist[jukebox_currentid+1] != nil) then
		jukebox_currentid = jukebox_currentid + 1;
		jukebox_playSound(jukebox_playlist[jukebox_currentid]);
		jukebox_currentTime = 0;
	else
		datastream.StreamToClients( player.GetAll( ), "SSKjukeboxMAJ", {"Aucun son actuellement !", 0, 0} );	
	end
	
end

end

timer.Create(“jukebox_timer”, 1, 0, jukebox_gest_playlist);

function givePlayList( pl, handler, id, encoded, decoded )
datastream.StreamToClients( pl, “getPlayList”, {jukebox_playlist} );
end
datastream.Hook( “givePlayList”, givePlayList );

function addToPlayList( pl, handler, id, encoded, decoded )
jukebox_addSound(decoded[1]);
end
datastream.Hook( “addToPlayList”, addToPlayList );[/lua]

First off, there really is an overuse of data-streams. You are even sending a blank table via data-stream to trigger another data-stream; this could easily be achieved with a single user-message.

What exactly is the error you’re getting now? Seeing as there is no mention of “jukebox_maj” in your new code, I am forced to believe that your error message differs from the one in the original post.