I'm trying to make a aimbot and I can't get it to aim at NPC's.
I tried adding [CODE] if (!aimNpc:GetBool()) and v:IsNPC() == v:IsNPC() then
continue
end[/CODE] to the aimbot but it still wont work.
This is the code for the function aimbot
[CODE]local function Aimbot(ucmd)
local ply = LocalPlayer()
if (!aiming) then return end
local closest, dist = nil, 0
for k, v in next, player.GetAll() do
if (!IsValid(v)) then continue end
if v == ply then continue end
if (!v:Alive()) then continue end
if (!aimFriends:GetBool()) and v:GetFriendStatus() == "friend" then
continue
end
if (!aimTeam:GetBool()) and v:Team() == ply:Team() then
continue
end
if (!aimNpc:GetBool()) and v:IsNPC() == v:IsNPC() then
continue
end
if (!InFov(ply:GetAngles(),(v:GetPos() - ply:GetShootPos()):Angle())) then
continue
end
if (!IsVisible(v,GetHead(v))) then continue end
local _dist = math_dist(GetHead(v):ToScreen().x, GetHead(v):ToScreen().y, ScrW() * 0.50, ScrH() * 0.50)
if (!closest or _dist < dist) then
dist = _dist
closest = v
targ = v
local angle = (GetHead(v) - ply:GetShootPos()):Angle()
if aimNospread:GetBool() then
angle = PredictSpread(ucmd, angle)
end
angle.y = math.NormalizeAngle(angle.y)
angle.p = math.NormalizeAngle(angle.p)
ucmd:SetViewAngles(angle)
if aimShoot:GetBool() then
ucmd:SetButtons(bit.bor(ucmd:GetButtons(), IN_ATTACK))
end
end
end
end
concommand.Add("+crouch", function() aiming = true end)
concommand.Add("-crouch", function() aiming = false end)
hook.Add("CreateMove","Aimbot", Aimbot)[/CODE]
Can anybody help?
player.GetAll() doesn't include npcs
v:IsNPC() == v:IsNPC() will always be true
did you make aimNpc?
[QUOTE=PortalGod;45723657]player.GetAll() doesn't include npcs
v:IsNPC() == v:IsNPC() will always be true
did you make aimNpc?[/QUOTE]
Yes I did make aimNpc, This is the whole code for the aimbot
[CODE]
local function Aimbot(ucmd)
local ply = LocalPlayer()
if (!aiming) then return end
local closest, dist = nil, 0
for k, v in next, player.GetAll() do
if (!IsValid(v)) then continue end
if v == ply then continue end
if (!v:Alive()) then continue end
if (!aimFriends:GetBool()) and v:GetFriendStatus() == "friend" then
continue
end
if (!aimTeam:GetBool()) and v:Team() == ply:Team() then
continue
end
if (!aimNpc:GetBool()) and v:IsNPC() == v:IsNPC() then
continue
end
if (!InFov(ply:GetAngles(),(v:GetPos() - ply:GetShootPos()):Angle())) then
continue
end
if (!IsVisible(v,GetHead(v))) then continue end
local _dist = math_dist(GetHead(v):ToScreen().x, GetHead(v):ToScreen().y, ScrW() * 0.50, ScrH() * 0.50)
if (!closest or _dist < dist) then
dist = _dist
closest = v
targ = v
local angle = (GetHead(v) - ply:GetShootPos()):Angle()
if aimNospread:GetBool() then
angle = PredictSpread(ucmd, angle)
end
angle.y = math.NormalizeAngle(angle.y)
angle.p = math.NormalizeAngle(angle.p)
ucmd:SetViewAngles(angle)
if aimShoot:GetBool() then
ucmd:SetButtons(bit.bor(ucmd:GetButtons(), IN_ATTACK))
end
end
end
end
end
concommand.Add("+crouch", function() aiming = true end)
concommand.Add("-crouch", function() aiming = false end)
hook.Add("CreateMove","Aimbot", Aimbot)[/CODE]
[editline]18th August 2014[/editline]
[QUOTE=PortalGod;45723657]player.GetAll() doesn't include npcs
v:IsNPC() == v:IsNPC() will always be true
did you make aimNpc?[/QUOTE]
How would I make it include NPCs?
I don't really mess with anything related to NPCs, but I'm assuming you could run a search to get all of the entities, and then out of that search search for all the NPCs in those entities. So something to run ents.GetAll() or whatever, and then if ents is NPC or something along those lines
[QUOTE=Chimpanzee;45723724]I don't really mess with anything related to NPCs, but I'm assuming you could run a search to get all of the entities, and then out of that search search for all the NPCs in those entities. So something to run ents.GetAll() or whatever, and then if ents is NPC or something along those lines[/QUOTE]
I dont know how to do that
I knew you were making an aimbot you little rascal.
Thinking back on it now, an easier way would be ents.FindByClass, so you would do something like
[lua]
local npcs = ents.FindByClass("npc_*")
[/lua]
and npcs would be the variable that stores all of the npc's
[QUOTE=Chimpanzee;45723895]Thinking back on it now, an easier way would be ents.FindByClass, so you would do something like
[lua]
local npcs = ents.FindByClass("npc_*")
[/lua]
and npcs would be the variable that stores all of the npc's[/QUOTE]
So if I did that I just needed to do
[CODE] if (!aimNpc:GetBool()) and v:NPC then
continue
end[/CODE] ?
[QUOTE=Chimpanzee;45723895]Thinking back on it now, an easier way would be ents.FindByClass, so you would do something like
[lua]
local npcs = ents.FindByClass("npc_*")
[/lua]
and npcs would be the variable that stores all of the npc's[/QUOTE]
I tried doing it like this [CODE] if (!aimNpc:GetBool()) and npcs() then
continue
end[/CODE] and like this
[CODE] if (!aimNpc:GetBool()) and v:npcs() then
continue
end[/CODE] and still it didn't work
bump
try adding npcs name to the end of the aimbot
[QUOTE=mrweegeeman;45732921]try adding npcs name to the end of the aimbot[/QUOTE]
That's not lua...
Where are you placing the aforementioned code?
[QUOTE=kittix;45727551]I tried doing it like this [CODE] if (!aimNpc:GetBool()) and npcs() then
continue
end[/CODE] and like this
[CODE] if (!aimNpc:GetBool()) and v:npcs() then
continue
end[/CODE] and still it didn't work[/QUOTE]
"npcs" is now a table of all entities started with npc_
Loop through the table.
for k, v in pairs( ents.GetAll() ) do loop through all entities, npc's are stored in there (players too)
Fix your check
if ( aimNpc:GetBool() ) and !( v:IsNPC() ) then continue end
You will no longer target players, just npcs
[QUOTE=nettsam;45740929]for k, v in pairs( ents.GetAll() ) do loop through all entities, npc's are stored in there (players too)
Fix your check
if ( aimNpc:GetBool() ) and !( v:IsNPC() ) then continue end
You will no longer target players, just npcs[/QUOTE]
Thanks so much! I did it and I made it aim at players too. How can I make it not target dead npcs? the v:Alive thing is only for players
[CODE]if ( aimPlayers:GetBool() ) and !( v:IsNPC() ) then
continue
end[/CODE]
Entity:Health() > 0? Not sure of too many other ways to check if dead.
[QUOTE=KevinnTCG;45744476]Entity:Health() > 0? Not sure of too many other ways to check if dead.[/QUOTE]
I tried this
[QUOTE]if ( aimPlayers:GetBool() ) and !( v:IsPlayer() and (v:Health() > 0) ) then
continue
end
if ( aimNpc:GetBool() ) and !( v:IsNPC() ( Entity:Health() > 0 ) ) then
continue
end[/QUOTE]
but for the npc one, it says Entity is a nil value
Entity was just a placeholder for whatever variable you were using,
[CODE]if ( aimNpc:GetBool() ) and !( v:IsNPC() and ( v:Health() > 0 ) ) then [/CODE]
Not sure what you are doing with your code but the ! in front of the conditions seems out of place to me.
i doubt you made this aimbot, you have no idea what you're doing
[QUOTE=mrweegeeman;45732921]try adding npcs name to the end of the aimbot[/QUOTE]
kay, will report back on findings
[B]EDIT:[/B]
I tried both this:
[lua]
local function Aimbot(ucmd)
npcs name
end
[/lua]
and this:
[lua]local function Aimbot(ucmd)
pls attak npcs!!!!1!
end[/lua]
It doesn't work, and to think you didn't know, I thought you were a Lua pro! :pwn:
EDIT: Oh man this post is way too big, it needs to be shrinked, shrinked it
dude u should ask at ur home mpgh yes????
[QUOTE=Liota;45749601]dude u should ask at ur home mpgh yes????[/QUOTE]
nah, mpgh will rape me
[QUOTE=kittix;45788782]nah, mpgh will rape me[/QUOTE]
Considering it's full of people like you they don't have much room to speak.
Sorry, you need to Log In to post a reply to this thread.