im new to code so dont hate help instead! code might betotally off YOU HAVE BEEN WARNED!!!!
so im trying to create a simple script that automaticly assigns F9 Bound to "say /calladmin" for All players on the server as default(when they join)
[CODE]function GM:PlayerBindPress( ply, bind, pressed )
if ( string.find( bind, "load quick" ) ) then return true
if (true then (ply concommand.Run ("bind F9 "say /calladmin"") end
end[/CODE]
please reply with a more accurate solution if you know one!
I wouldn't force them to directly BIND the key, but to automaticly make them say 'CallAdmin' instead, its way better than fucking up their bindings.
[code]
local antispam = false -- Dont edit c:
local time = 60 -- Set your anti spam time here
hook.Add("Think", "Call_Admin_Thingy", function()
if input.IsKeyDown(KP_F9) and antispam == false then
antispam = true -- Enables antispam, doesn't make them like say it 5000 times a second lol
LocalPlayer():ConCommand("say /calladmin") -- makes them say the command
timer.Simple(time, function() -- This part resets the antispam, making it re-useable after _N_ seconds.
antispam = false
end)
end
end)
[/code]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/input/IsKeyDown]input.IsKeyDown[/url]
[url]http://wiki.garrysmod.com/page/Enums/KEY[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/Think]GM:Think[/url]
Hope that helps, its untested though.
Edit: besides your string is false, you cant have a [B]"[/B] inside [B]"[/B], either have it inside [B]'[/B] or use [B]\"[/B] to mark 'incode [B]"[/B]s'
[QUOTE=whitestar;50071728]I wouldn't force them to directly BIND the key, but to automaticly make them say 'CallAdmin' instead, its way better than fucking up their bindings.
[code]
local antispam = false -- Dont edit c:
local time = 60 -- Set your anti spam time here
hook.Add("Think", "Call_Admin_Thingy", function()
if input.IsKeyDown(KP_F9) and antispam == false then
antispam = true -- Enables antispam, doesn't make them like say it 5000 times a second lol
LocalPlayer():ConCommand("say /calladmin") -- makes them say the command
timer.Simple(time, function() -- This part resets the antispam, making it re-useable after _N_ seconds.
antispam = false
end)
end
end)
[/code]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/input/IsKeyDown]input.IsKeyDown[/url]
[url]http://wiki.garrysmod.com/page/Enums/KEY[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/Think]GM:Think[/url]
Hope that helps, its untested though.
Edit: besides your string is false, you cant have a [B]"[/B] inside [B]"[/B], either have it inside [B]'[/B] or use [B]\"[/B] to mark 'incode [B]"[/B]s'[/QUOTE]
nice im making it be that way because of my f4 menu i got added support tabs and one is calladmin,
but the F9 bind connected to the tab button won't execute the command and instead directs to the Q bind
Hello. I am working with the above poster in making a DarkRP server using your script. We are unsure where to place the lua file in the server directory. We are also unsure what would be an appropriate name for it, is 'calladmindlc.lua' okay? Thanks in advance.
[editline]5th April 2016[/editline]
[QUOTE=whitestar;50071728]I wouldn't force them to directly BIND the key, but to automaticly make them say 'CallAdmin' instead, its way better than fucking up their bindings.
[code]
local antispam = false -- Dont edit c:
local time = 60 -- Set your anti spam time here
hook.Add("Think", "Call_Admin_Thingy", function()
if input.IsKeyDown(KP_F9) and antispam == false then
antispam = true -- Enables antispam, doesn't make them like say it 5000 times a second lol
LocalPlayer():ConCommand("say /calladmin") -- makes them say the command
timer.Simple(time, function() -- This part resets the antispam, making it re-useable after _N_ seconds.
antispam = false
end)
end
end)
[/code]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/input/IsKeyDown]input.IsKeyDown[/url]
[url]http://wiki.garrysmod.com/page/Enums/KEY[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/Think]GM:Think[/url]
Hope that helps, its untested though.
Edit: besides your string is false, you cant have a [B]"[/B] inside [B]"[/B], either have it inside [B]'[/B] or use [B]\"[/B] to mark 'incode [B]"[/B]s'[/QUOTE]
Hello. I am working with the above poster in making a DarkRP server using your script. We are unsure where to place the lua file in the server directory. We are also unsure what would be an appropriate name for it, is 'calladmindlc.lua' okay? Thanks in advance.
Its a clientside script, so lets say "[B]/addons/addonname/lua/autorun/client/script.lua[/B]" should do the trick, or simply "[B]lua/autorun/client/script.lua[/B]".
[QUOTE=whitestar;50073054]Its a clientside script, so lets say "[B]/addons/addonname/lua/autorun/client/script.lua[/B]" should do the trick, or simply "[B]lua/autorun/client/script.lua[/B]".[/QUOTE]
Get spammed with this lua error constantly when the script is in either one of your suggested locations:
[CODE][ERROR] lua/autorun/client/calladmindlc.lua:5: bad argument #1 to 'IsKeyDown' (number expected, got nil)
1. IsKeyDown - [C]:-1
2. fn - lua/autorun/client/calladmindlc.lua:5
3. unknown - addons/ulib/lua/ulib/shared/hook.lua:110[/CODE]
[QUOTE=IllumiNAUGHTY;50073578]Get spammed with this lua error constantly when the script is in either one of your suggested locations:
[CODE][ERROR] lua/autorun/client/calladmindlc.lua:5: bad argument #1 to 'IsKeyDown' (number expected, got nil)
1. IsKeyDown - [C]:-1
2. fn - lua/autorun/client/calladmindlc.lua:5
3. unknown - addons/ulib/lua/ulib/shared/hook.lua:110[/CODE][/QUOTE]
try 100 instead of KEY_F9
[QUOTE=whitestar;50073595]try 100 instead of KEY_F9[/QUOTE]
It works, thank you very much :)
Sorry, you need to Log In to post a reply to this thread.