• Area and Godemode
    16 replies, posted
Hi, Lets say you have a area on a map and you want when a player comes in there that there will be enabled Godmode? Any idea how to do this?
Godemode?
Thanks HumbleTH such help, such pointless
You could specify a specific location in the map and save it as the origin of your safe-area (probably from a player, you could use a console command), then use [url=http://wiki.garrysmod.com/page/ents/FindInSphere]ents.FindInSphere[/url] to find all entities within a circular area around the point. You can then check if the player is in the area - and thus should take damage within the [url=http://wiki.garrysmod.com/page/GM/PlayerShouldTakeDamage]PlayerShouldTakeDamage[/url] hook: [lua] hook.Add( "PlayerShouldTakeDamage", "GodModeArea", function( ply, att ) local tbl = ents.FindInSphere( pos, 50 ) if table.HasValue( tbl, ply ) or table.HasValue( tbl, att ) then return false end -- Because you should prevent damage when either player is in the area end [/lua] Alternatively you could attempt the same using a [url=http://wiki.garrysmod.com/page/util/TraceHull]Hull Trace[/url] but that would require two points, the start position and the end position. [editline]15th March 2014[/editline] Also I recommend that you refrain from using memes in your replies to others, I doubt anyone appreciates it. If someone posts something stupid then ignore them.
So basically i create a sphere at spawn and make like 300 large, so and every player is protected then. But how exacly can i put the sphere on the spawn? I found this: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4e84.html[/url] and this: render.DrawSphere( Vector position, number radius, number longitudeSteps, number latitudeSteps, Color color ) How bring i these cordinates into it? setpos 820.942139 931.235779 -12223.968750;setang 45.979595 -125.704727 0.000000 setpos -859.101379 -890.403870 -12223.968750;setang 11.879611 37.175220 0.000000 basically from gm_flatgrass spawn. Thanks
[QUOTE=JackBauerr;44244757]So basically i create a sphere at spawn and make like 300 large, so and every player is protected then. But how exacly can i put the sphere on the spawn? I found this: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4e84.html[/url] and this: render.DrawSphere( Vector position, number radius, number longitudeSteps, number latitudeSteps, Color color ) How bring i these cordinates into it? setpos 820.942139 931.235779 -12223.968750;setang 45.979595 -125.704727 0.000000 setpos -859.101379 -890.403870 -12223.968750;setang 11.879611 37.175220 0.000000 basically from gm_flatgrass spawn. Thanks[/QUOTE] Get the center of the sphere, spawn the entity there, and set the radius in that function to the (pos1-pos2):Length() ( Big enough so it covers all of the spawn area )
I would like to use: render.DrawBox( Vector position, Angle angles, Vector mins, Vector maxs, Color color, boolean writeZ ) but how do i use it with these cordinates? i have no idea.
I tried: render.DrawBox(Vector(820.942139, 931.235779, -12223.968750), Angle(0, 0, 90), Vector(820.942139, 931.235779, -12223.968750), Vector(-859.101379, -890.403870, -12223.968750), Color(0, 255, 0, 255)) It says: attempt to index global 'render' (a nil value) SO dosent works.
If render is a nil value, that means you're probably trying to call it serverside.
Yes i need it for a server, otherwise it would be pointless in singleplayer.
You miss the point - you can't use the render library serverside. You need to call that function in a clientside file.
And How do i protect the spawn now?
[QUOTE=JackBauerr;44247037]And How do i protect the spawn now?[/QUOTE] You can't protect the spawn by drawing a sphere around it. You need to actually write some amount of code to achieve this. Basically you want to find every player in the sphere and make them not take damage via ScalePlayerDamage hook.
- yeah sorry it's 10 pm and I can't think straight -
Sorry, you need to Log In to post a reply to this thread.