How to make a simple wallhack

Posts 1–15 of 19 · Page 1 of 2
How to make a simple wallhack
Getting started

We'll start by creating the lua file, just create "Wallhack.lua" to the lua directory of Garry's Mod(Friend). And when you want to test it, just type lua_openscript_cl Wallhack.lua

Wallhack tutorial

Okay, so lets get started. This is the main part, it will make a hook, which will draw our text to the screen.
Code:
hook.Add( "HUDPaint", "Wallhack", function()


end )
But of course, that's not the wallhack itself, we'll still need to add something to it. Because it's an wallhack, we'll have to go through the players of course.
Code:
hook.Add( "HUDPaint", "Wallhack", function()

for k,v in pairs ( player.GetAll() ) do
-- This is a loop going across all players.
Code:
end

end )
Now that we have got all the players, we just need the text above their head. With this we are getting the players position, and converting it into a position on our screen. The vector addition is because we don't want to have the name on the players feet, do we.
Code:
local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
Optional additions

You might end up wanting to have a on/off switch for the wallhack, or you may have noticed that it draws the name for you also. I'll show you examples how to do some of these.
On/Off switch

First, I'll show you how to make a on/off switch. The first argument is the convar name, feel free to change it. The second argument is the default value, 0 is disabled, and 1 is enabled. The third argument is an option that should it save, we'll but yes. The fourth one is an option that is it userdata, for us, no
Code:
CreateClientConVar( "wallhack_enabled", 0, true, false )
Now that we have the ConVar, we'll have to find a way how to use it. The best way would be to have it in the hook.
Code:
hook.Add( "HUDPaint", "Wallhack", function()

if ConVarExists( "wallhack_enabled" ) and GetConVar("wallhack_enabled"):GetInt() == 1 then

for k,v in pairs ( player.GetAll() ) do

local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
draw.DrawText( v:Name(), "MenuLarge", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )

end

end

end )

Now what did I do there? I first checked does the convar exist, and then I'm using the function GetConVar to get the value of the ConVar we created, and because it would only return the convar itself, I added GetInt() to get the value.

And now you're done! You only have to type wallhack_enabled 1 in console to enable it, and wallhack_enabled 0 to disable it.
Removing your name

Isn't it annoying that if you look on the ground or the sky, you might see your own name, I'll show you how to fix that.

Just add this if statement around the call to draw.DrawText
Code:
hook.Add( "HUDPaint", "Wallhack", function()

for k,v in pairs ( player.GetAll() ) do

local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()

if v ~= LocalPlayer() then

draw.DrawText( v:GetName(), "MenuLarge", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )

end

end

end )
Now we'll just need to implement this into the script you made. This is the most important function on this, it will draw the players name above his head. I'll explain about the function, The first argument is the text to draw, in this case it would be the players. The second argument is the font, feel free to find a suitable for you from the Working with Fonts page. The third and the fourth are the texts position X, and Y. The fifth is the color, feel free to change it. The sixth and the last one is just the Xalign, you can just leave it. More info about this function on the draw.DrawText page.
Code:
draw.DrawText( v:Name(), "MenuLarge", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )
Now you just have to add these two new functions to the loop and you're done!
Code:
hook.Add( "HUDPaint", "Wallhack", function()

for k,v in pairs ( player.GetAll() ) do

local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
draw.DrawText( v:Name(), "MenuLarge", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )

end

end )

Can SomeOne Fix This With [/C0de] Im Bizzy! Sorry Credits Who Going To Do This
What is this ? Put your codes inside [C0de] [/C0de]
No offence but this aint a good tutorial unless you fix it , make it more readable / descriptive
Yes, hard to read.
dude it's hard to read put around the code
Am a try to fix it a little bit..:




Getting started

We'll start by creating the lua file, just create "Wallhack.lua" to the lua directory of Garry's Mod(Friend). And when you want to test it, just type lua_openscript_cl Wallhack.lua

Wallhack tutorial

Okay, so lets get started. This is the main part, it will make a hook, which will draw our text to the screen.
Code:
hook.Add( "HUDPaint", "Wallhack", function()


end )
But of course, that's not the wallhack itself, we'll still need to add something to it. Because it's an wallhack, we'll have to go through the players of course.
Code:
hook.Add( "HUDPaint", "Wallhack", function()

for k,v in pairs ( player.GetAll() ) do
-- This is a loop going across all players.
Code:
end

end )
Now that we have got all the players, we just need the text above their head. With this we are getting the players position, and converting it into a position on our screen. The vector addition is because we don't want to have the name on the players feet, do we.
Code:
local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
Optional additions

You might end up wanting to have a on/off switch for the wallhack, or you may have noticed that it draws the name for you also. I'll show you examples how to do some of these.
On/Off switch

First, I'll show you how to make a on/off switch. The first argument is the convar name, feel free to change it. The second argument is the default value, 0 is disabled, and 1 is enabled. The third argument is an option that should it save, we'll but yes. The fourth one is an option that is it userdata, for us, no
Code:
CreateClientConVar( "wallhack_enabled", 0, true, false )
Now that we have the ConVar, we'll have to find a way how to use it. The best way would be to have it in the hook.
Code:
hook.Add( "HUDPaint", "Wallhack", function()

if ConVarExists( "wallhack_enabled" ) and GetConVar("wallhack_enabled"):GetInt() == 1 then

for k,v in pairs ( player.GetAll() ) do

local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
draw.DrawText( v:Name(), "MenuLarge", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )

end

end

end )

Now what did I do there? I first checked does the convar exist, and then I'm using the function GetConVar to get the value of the ConVar we created, and because it would only return the convar itself, I added GetInt() to get the value.

And now you're done! You only have to type wallhack_enabled 1 in console to enable it, and wallhack_enabled 0 to disable it.
Removing your name

Isn't it annoying that if you look on the ground or the sky, you might see your own name, I'll show you how to fix that.

Just add this if statement around the call to draw.DrawText
Code:
hook.Add( "HUDPaint", "Wallhack", function()

for k,v in pairs ( player.GetAll() ) do

local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()

if v ~= LocalPlayer() then

draw.DrawText( v:GetName(), "MenuLarge", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )

end

end

end )
Now we'll just need to implement this into the script you made. This is the most important function on this, it will draw the players name above his head. I'll explain about the function, The first argument is the text to draw, in this case it would be the players. The second argument is the font, feel free to find a suitable for you from the Working with Fonts page. The third and the fourth are the texts position X, and Y. The fifth is the color, feel free to change it. The sixth and the last one is just the Xalign, you can just leave it. More info about this function on the draw.DrawText page.
Code:
draw.DrawText( v:Name(), "MenuLarge", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )
Now you just have to add these two new functions to the loop and you're done!
Code:
hook.Add( "HUDPaint", "Wallhack", function()

for k,v in pairs ( player.GetAll() ) do

local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
draw.DrawText( v:Name(), "MenuLarge", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )

end

end )
what the hell is this lua shit?
Quote Originally Posted by _corn_ View Post
what the hell is this lua shit?
dunno lol....i edited his tut but i dont understand any thing from it
Guys you've never heard of lua?
Code:
What is Lua?

Lua is a powerful, fast, lightweight, embeddable scripting language.

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics.
Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.
Learn more here :
More About Lua
Quote Originally Posted by Fly3r View Post
Guys you've never heard of lua?
Code:
What is Lua?

Lua is a powerful, fast, lightweight, embeddable scripting language.

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics.
Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.
Learn more here :
More About Lua
LOL i meant i didnt understand any thing from his TUT
haha lol fail tut.. wtf is lua.. (i noticed the homepage) but where the hell is that from.. i never heard about this before
Quote Originally Posted by Code[VB] View Post
haha lol fail tut.. wtf is lua.. (i noticed the homepage) but where the hell is that from.. i never heard about this before
"Lua is designed, implemented, and maintained by a team at PUC-Rio, the Pontifical Catholic University of Rio de Janeiro in Brazil. Lua was born and raised in Tecgraf, the Computer Graphics Technology Group of PUC-Rio, and is now housed at Lablua. Both Tecgraf and Lablua are laboratories of the Department of Computer Science of PUC-Rio."

I don't think x-trap deletes/detects this type of programing...
lua is just a pile of C source files...
i dont think this is working.
and next time use [CODE ] [/ CODE]
are you sure this is for CF?
Posts 1–15 of 19 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?