Oh hello there, i’ve been trying to make a little script that toggles GodMode on a player if the player is located in a specified space, like the spawn on flatgrass. Can anybody make a fast script? I believe its quite easy, but i am not thinking the right way. You would be my hero.
I could actually use this too if this would be made
I’m going to learn lua further soon, cuz I took a long ass break and I lost alot of the knowledge =)
So yeah, this could be handy
Next = 0; local meta = FindMetaTable( "Player" ); function meta:IsInBox( min, max ) local Result = ents.FindInBox( min, max ); for k,v in pairs( Result ) do if( v && ValidEntity( v ) && v:IsPlayer() ) then return true; else return false; end end end function Check() if( CurTime() >= Next ) then for k,v in pairs( player.GetAll() ) do if( ValidEntity( v ) ) then if( v:IsInBox( Vector( INSERT X,Y,Z ), Vector( INSERT X,Y,Z ) ) ) then v:SetNWBool( "TakeDamage", false ); else v:SetNWBool( "TakeDamage", true ); end end end Next = CurTime() + 1; end end hook.Add("Think", "Check", Check) function playershouldtakedamage(victim, attacker) if( victim:GetNWBool( "TakeDamage" ) == false ) then return false; end end hook.Add( "PlayerShouldTakeDamage", "playershouldtakedamage", playershouldtakedamage)
There ya go, not sure how efficient this script is or anything when there’s like 30 players, but I guess you’ll find out.
Save as godmode.lua inside garrysmod/lua/autorun/server, if the folders doesn’t exist, just create them.
All you have to do it put in the 2 vectors.
how do I find the vectors? (X,Y,Z)
In the console, type