1

i made a script for garry's mode, using lua to code a script that allows me to when i bind a key, it will do a jump, then a 360 turn and shoot, but when i finished coding it, it won't let me run a test on it, why is this, and can you by chance tell me what i did wrong in the code. I am also 90% sure that the turn doesn't make a full 360, so if you could help me with that, i will be greatful. thanks. Code:

function 360JumpShot()
    timer.simple(.01,jump)
    timer.simple(.02,turn)
    timer.simple(.04,turn)
    timer.simple(.06,turn)
    timer.simple(.08,turn)
    timer.simple(.10,turn)
    timer.Simple(.12,Turn)
    timer.Simple(.14,Turn)
    timer.Simple(.16,Turn)
    timer.Simple(.18,Turn)
    timer.Simple(.20,Turn)
    timer.Simple(.22,Turn)
    timer.Simple(.24,Turn)
    timer.Simple(.26,Turn)
    timer.Simple(.28,Turn)
    timer.Simple(.30,Turn)
    timer.Simple(.32,Turn)
    timer.Simple(.34,Turn)
    timer.Simple(.36,Turn)
    timer.Simple(.36,Turn)
    timer.Simple(.40,Turn)
    timer.Simple(.45,Turn)
    timer.Simple(.50,Turn)
    timer.Simple(.55,Turn)
    timer.Simple(.60,Turn)
    timer.Simple(.65,Turn)
    timer.Simple(.70,Turn)
-- Get Noscoped
    timer.simple(.7,function() RunConsoleCommand("+attack") end)
    timer.simple(.72,function() RunConsoleCommand("-attack") end)
end
function Turn()
-- Turn(360)
    LocalPlayer():SetEyeAngles(LocalPlayer():EyeAngles()-Angle(0,10,0))
end
function jump()
    LocalPlayer():EyeAngles() LocalPlayer():SetEyeAngles(Angle(a.p-a.p-a.p, a.y-180, a.r))
end
-- Console Command
concommand.ADD("360Jump",360JumpShot)
hjpotter92
  • 78,589
  • 36
  • 144
  • 183
WetCactus
  • 11
  • 1
  • 4
  • 6
    function names can not begin with digits. – hjpotter92 Jul 09 '14 at 23:58
  • 2
    "It won't let me", what does that mean, do you get an error? if yes then provide complete error msg in your question. – Oliver Jul 10 '14 at 03:25
  • Also, there are times you write `simple` with uppercase 's' and sometimes lowercase. It should be either lowercase or uppercase – Ivo Jul 10 '14 at 12:32
  • Please read [Write a title that summarizes the specific problem](http://stackoverflow.com/help/how-to-ask). – Tom Blodget Jul 11 '14 at 00:15

1 Answers1

0

alright, i got it to work.

Firstly, you cannot start your functions with digits so change

function 360JumpShot()
concommand.ADD("360Jump",360JumpShot)

to

function JumpShot()
concommand.Add("360Jump",JumpShot)

note that i also changed ADD to Add because LUA is case sensitive, considering that.. change

timer.simple(.01,jump)
timer.simple(.02,turn)
timer.simple(.04,turn)
timer.simple(.06,turn)
timer.simple(.08,turn)
timer.simple(.10,turn)
timer.simple(.7,function() RunConsoleCommand("+attack") end)
timer.simple(.72,function() RunConsoleCommand("-attack") end)

to

timer.Simple(.01,jump)
timer.Simple(.02,Turn)
timer.Simple(.04,Turn)
timer.Simple(.06,Turn)
timer.Simple(.08,Turn)
timer.Simple(.10,Turn)
timer.Simple(.7,function() RunConsoleCommand("+attack") end)
timer.Simple(.72,function() RunConsoleCommand("-attack") end)

after these changes your script works fine but you might want to find a way to move faster because your camera movement is very slow and is probably not exactly what you want.

Kyle Casey
  • 11
  • 1