Hello there!
I'm pretty new at LUA coding, and Im starting to create my first LUA scripts..
I want to make an errorfix for my server.. That means when a player types: !errorfix then a window will pop up, with the steam workshop ineed..
I've tried to do this, but with no luck.. Any ideas why this is not working?
[CODE]function errorfix( fly, text, public )
if(string.sub ( text, 1, 9) ) == "!errorfix" ) then
PrintMessage( HUD_PRINTTALK, "Player: "..ply:Nick().." used the !errorfix command, and will be back in a minute.")
gui.OpenURL("URL HERE")
end
end[/CODE]
Thank you for your time and help!
Why don't you just pop a [url=http://wiki.garrysmod.com/page/resource/AddWorkshop]resource.AddWorkshop[/url] in an init.lua?
All players that then connect to the server are forced to download the workshop while connecting.
[QUOTE=Internet1001;42841727]Why don't you just pop a [url=http://wiki.garrysmod.com/page/resource/AddWorkshop]resource.AddWorkshop[/url] in an init.lua?[/QUOTE]
Well, I would like to be able doing this, because I often find problems with the resource.AddWorkshop.. Belive it or not
I'm not seeing where ply is defined. Did you misspell it in the function's arguments(ply instead of fly)?
Also, do you get any errors? Also make sure you're running this clientside.
[QUOTE=wakeboarderCWB;42842839]I'm not seeing where ply is defined. Did you misspell it in the function's arguments(ply instead of fly)?
Also, do you get any errors? Also make sure you're running this clientside.[/QUOTE]
Well, I did change the fly to ply.. But since this is going to run on my server, I guess it's not clientside? Are there any other ways to do this? Because I don't think it's that complicated.. :c
[CODE] if ( SERVER ) then
hook.Add( "PlayerSay", "playersaywebsite", function( _p, _text, public )
if ( _text == "!fixerros" ) then
_p:ConCommand( "fixerrors" );
return "";
end
end );
else
concommand.Add( "fixerrors", function()
gui.OpenURL( "URL here" );
end );
end[/CODE]
Put this in garrysmod/lua/autorun
[QUOTE=Riticx;42843059][CODE] if ( SERVER ) then
hook.Add( "PlayerSay", "playersaywebsite", function( _p, _text, public )
if ( _text == "!fixerros" ) then
_p:ConCommand( "fixerrors" );
return "";
end
end );
else
concommand.Add( "fixerrors", function()
gui.OpenURL( "URL here" );
end );
end[/CODE]
Put this in garrysmod/lua/autorun[/QUOTE]
Thank you so much! I have been looking for this, and since Im not a good coder myself, I have problems doing it! Thanks!
Sorry, you need to Log In to post a reply to this thread.