Help with script loading

Post Reply
Ollie
New to forums
New to forums
Posts: 1
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Sun Nov 24, 2013 10:26 pm

Help with script loading

Post by Ollie »

Hi iv been trying to put a script in dupes.lua which only allows people to spawn there own dupes and not workshop dupes, but it says something about critical error or something, it was working on another host so I don't understand why it isn't working on this host.

Also, I have a custom chat-box that I'm trying to put on the server but it doesn't seem to be loading on it at all, I'm not sure whether It's something that the host doesn't allow or Iv done something wrong.

Thanks in advanced.

Also, here is what I'm trying to put into dupes.lua

Code: Select all

local HTML	 = nil
local DupeInClipboard	= false;

spawnmenu.AddCreationTab( "#spawnmenu.category.dupes", function()

HTML = vgui.Create( "DHTML" );
JS_Language( HTML )
HTML:SetAllowLua( true );
HTML:OpenURL( "asset://garrysmod/html/dupes.html" );
HTML:Call( "SetDupeSaveState( " .. tostring( DupeInClipboard ).. " );" );	

ws_dupe = WorkshopFileBase( "dupe", { "dupe" } )
ws_dupe.HTML = HTML

function ws_dupe:FetchLocal( offset, perpage )

local f = file.Find( "dupes/*.dupe", "MOD", "datedesc" )

local saves = {}

for k, v in pairs( f ) do

if ( k <= offset ) then continue end
if ( k > offset + perpage ) then break end

local entry = 
{
file	= "dupes/" .. v,
name	= v:StripExtension(),
preview	= "dupes/" .. v:StripExtension() .. ".jpg"
}

table.insert( saves, entry );

end

local results = 
{
totalresults	= #f,
results	 = saves
}

local json = util.TableToJSON( results, false );
HTML:Call( "dupe.ReceiveLocal( "..json.." )" );

end

function ws_dupe:Arm( filename )

RunConsoleCommand( "dupe_arm", filename ); 

end

function ws_dupe:DownloadAndArm( id )

chat.AddText( Color(200,50,50), "Disabled Feature", Color(200,200,200), ": Sorry, Spawn your own dupes or make something yourself. o.O" )
--[[MsgN( "Downloading Dupe...\n" )
steamworks.Download( id, true, function( name )

MsgN( "Finished - arming!\n" )
ws_dupe:Arm( name ); 

end )]]

end

function ws_dupe:Publish( filename, imagename )

RunConsoleCommand( "dupe_publish", filename, imagename )

end

return HTML

end, "icon16/control_repeat_blue.png", 200 )


hook.Add( "DupeSaveAvailable", "UpdateDupeSpawnmenuAvailable", function()

DupeInClipboard = true;

if ( !HTML ) then return end

HTML:Call( "SetDupeSaveState( true );" );

end )

hook.Add( "DupeSaveUnavailable", "UpdateDupeSpawnmenuUnavailable", function()

DupeInClipboard = false;

if ( !HTML ) then return end

HTML:Call( "SetDupeSaveState( false );" );

end )

hook.Add( "DupeSaved", "DuplicationSavedSpawnMenu", function()

if ( !HTML ) then return end

HTML:Call( "ShowLocalDupes();" );

end )


concommand.Add( "dupe_show", function()

g_SpawnMenu:OpenCreationMenuTab( "#spawnmenu.category.dupes" );

timer.Simple( 1.0, function() if ( !IsValid( HTML ) ) then return end HTML:Call( "ShowLocalDupes();" ); end )

end, nil, "", { FCVAR_DONTRECORD } )
Post Reply