Hey everyone, this is my first post as I've only just started coding Lua in the past few days. One of my friends told me the simplest and best way to learn Lua was to jump straight in and start looking through code and making some of my own; he specified making a hack first as they are "very simple" and a good base to start scripting. So the past few days I've been making a hack, which, before I get an angry mob flooding down my street I just want to say I don't plan on using in-game (either way most servers have sv_allowcslua 0). Anyway. back to the point, I used the GMod wikis tutorial for making an aimbot but however, I noticed it was pretty awful. So, because I to code "my own" I started writing my own but I'm having some trouble. This is what I have done but I don't know if I'm on the right track because it gets no errors when run.
[CODE]CreateClientConVar( "aimbot_enabled", 0, true, false )
function aimbot_enabled()
if ConVarExists("aimbot_enabled") and GetConVar("aimbot_enabled"):GetInt() == 1 then
local aimpos = LocalPlayer():GetAimVector():ToScreen()
for k,v in pairs (player.GetAll()) do
local targetpos = v:GetAimVector():ToScreen()
if aimpos.x - 40 >= targetpos.x and aimpos.y - 40 >= targetpos.y == true then
local target = v:Name()
local BoneIndx = v:LookupBone("ValveBiped.Bip01_Head1")
local head = target:GetBonePosition( BoneIndx )
LocalPlayer():SetEyeAngles((head - LocalPlayer():GetShootPos()):Angle())
end
end
end
end
hook.Add("Think","aimbot_enabled",aimbot_enabled)[/CODE]
I'm sorry if this annoys anyone because:
A) I am making an aimbot.
B) I posted in the wrong place, sorry I'm new and not too sure.
[QUOTE=goosey;39036489]Hey everyone, this is my first post as I've only just started coding Lua in the past few days. One of my friends told me the simplest and best way to learn Lua was to jump straight in and start looking through code and making some of my own; he specified making a hack first as they are "very simple" and a good base to start scripting. So the past few days I've been making a hack, which, before I get an angry mob flooding down my street I just want to say I don't plan on using in-game (either way most servers have sv_allowcslua 0). Anyway. back to the point, I used the GMod wikis tutorial for making an aimbot but however, I noticed it was pretty awful. So, because I to code "my own" I started writing my own but I'm having some trouble. This is what I have done but I don't know if I'm on the right track because it gets no errors when run.
[CODE]CreateClientConVar( "aimbot_enabled", 0, true, false )
function aimbot_enabled()
if ConVarExists("aimbot_enabled") and GetConVar("aimbot_enabled"):GetInt() == 1 then
local aimpos = LocalPlayer():GetAimVector():ToScreen()
for k,v in pairs (player.GetAll()) do
local targetpos = v:GetAimVector():ToScreen()
if aimpos.x - 40 >= targetpos.x and aimpos.y - 40 >= targetpos.y == true then
local target = v:Name()
local BoneIndx = v:LookupBone("ValveBiped.Bip01_Head1")
local head = target:GetBonePosition( BoneIndx )
LocalPlayer():SetEyeAngles((head - LocalPlayer():GetShootPos()):Angle())
end
end
end
end
hook.Add("Think","aimbot_enabled",aimbot_enabled)[/CODE]
I'm sorry if this annoys anyone because:
A) I am making an aimbot.
B) I posted in the wrong place, sorry I'm new and not too sure.[/QUOTE]
This is really bad and unoptimized.
Also you're checking if a convar exists that you just created.
The advice of your "friend" was really bad.
Please, try reading others code then experimenting with theirs, creating own small stuff and then more and more and bigger stuff.
Sorry, you need to Log In to post a reply to this thread.