• Extra objects damage
    19 replies, posted
Hello friends, I add objects on my server for fix bug sites. Example: Bug on css office: [IMG]http://i.imgur.com/wEYDjRul.jpg[/IMG] My solution: [IMG]http://i.imgur.com/3koQZ1kl.jpg[/IMG] The props can hide in these sites and is completely invisible to the hunters. The problem is that when a hunter shoots an object added by me, they are damaged, I wish this were not so. This is my code. Object example: [CODE]function Think() if ( string.find( string.lower( game.GetMap() ), "cs_office" ) ) or ( string.find( string.lower( game.GetMap() ), "ph_cs_office" ) ) then SpawnStaticMesh(Vector( -1419.0256, 891.9169, -294.7175 ),Angle( 85.2319, -93.7798, -7.7572 ), "models/hunter/triangles/05x05.mdl") return end function SpawnStaticMesh(pos, angle, model) local Static = ents.Create("prop_physics") // print("StaticMesh spawn with model: " .. model) Static:SetAngles( angle ) Static.StaticModelName = Model Static:SetModel( model ) Static:SetPos( pos ) Static:Spawn() local phys = Static:GetPhysicsObject() if phys and phys:IsValid() then phys:Wake() phys:EnableMotion( false ) end end[/CODE] Thanks in advance, regards.
Don't use think to spawn a prop. Just add a check in prop hunt if the model is equal to models/hunter/triangles/05x05.mdl and return no damage, make the model unique
[QUOTE=AnonTakesOver;44829247]Don't use think to spawn a prop. Just add a check in prop hunt if the model is equal to models/hunter/triangles/05x05.mdl and return no damage, make the model unique[/QUOTE] Hello, thanks for your reply, I understand your message but I don't know how done. Maybe the code is a lot to ask, with some horientacion maybe I can learn to do this, do not want to read a book, but maybe some example may serve me, I'm not a programmer, so I only read the code and modified it a bit to work. Thanks
Firstly, use this hook instead of think: [url]http://wiki.garrysmod.com/page/GM/Initialize[/url] I will look at the prop hunt code and see what I can do for you.
Use InitPostEntity hook to spawn entities on maps; if you spawn them earlier it'll change the EntIndex of all entities on the map, or may not spawn correctly. Weld the props to the world, and change their material so they look like they belong there ( such as changing the panel to look like snow )..
[QUOTE=Acecool;44829801]Use InitPostEntity hook to spawn entities on maps; if you spawn them earlier it'll change the EntIndex of all entities on the map, or may not spawn correctly. Weld the props to the world, and change their material so they look like they belong there ( such as changing the panel to look like snow )..[/QUOTE] Sorry, I can not understand you very well, I think you say to change the map and not add objects? You could get some example to understand him better? Likewise I also want to add objects and do no harm, as car decoration. Greetings.
[QUOTE=Yona;44831765]Sorry, I can not understand you very well, I think you say to change the map and not add objects? You could get some example to understand him better? Likewise I also want to add objects and do no harm, as car decoration. Greetings.[/QUOTE] I sure hope this works. Objetos de Spawn dentro InitPostEntity. Encontrar donde se da el daño y añade una lista negra de los modelos.
[QUOTE=Walrus Viking;44832195]I sure hope this works. Objetos de Spawn dentro InitPostEntity. Encontrar donde se da el daño y añade una lista negra de los modelos.[/QUOTE] Thanks for your reply, I'm a newbie to Lua and I would know how to create that function. But I would like to select which objects can hurt and what not from that code what I post, it maybe not be possible but I think it would be the best solution. Regards.
¿Any suggestion? Regards.
Change prop_physics to a custom entity.
[QUOTE=Robotboy655;44997420]Change prop_physics to a custom entity.[/QUOTE] thanks for your reply but if I change this I get this error and don't load any custom prop on the map. [IMG]http://i.imgur.com/wHfI1qc.png[/IMG] I only replace this: local Static = ents.Create("prop_physics") by this: local Static = ents.Create("prop_physics2") Regards.
Register the actual entity, make <gamemode>/entities/entities/prop_physics2.lua, and put in appropriate code.
[QUOTE=Robotboy655;44997696]Register the actual entity, make <gamemode>/entities/entities/prop_physics2.lua, and put in appropriate code.[/QUOTE] What you mean with "put in appropriate code"? I don't know what code I need to put on prop_physics2.lua Thanks.
You expect me to do everything for you? Copy and paste bouncy ball source code there, and edit it until you get desired effect. Remove ENT:Draw(), remove the NetworkVar stuff, etc.
[QUOTE=Robotboy655;44997872]You expect me to do everything for you? Copy and paste bouncy ball source code there, and edit it until you get desired effect. Remove ENT:Draw(), remove the NetworkVar stuff, etc.[/QUOTE] I really do not, what happens is that I have no idea really much, I appreciate all your help. I have this code on init.lua for extra objects. [QUOTE]function SpawnStaticMesh(pos, angle, model) local Static = ents.Create("prop_physics2") // print("StaticMesh spawn with model: " .. model) Static:SetAngles( angle ) Static.StaticModelName = Model Static:SetModel( model ) Static:SetPos( pos ) Static:Spawn() local phys = Static:GetPhysicsObject() if phys and phys:IsValid() then phys:Wake() phys:EnableMotion( false ) end end[/QUOTE] And this are an object example: [QUOTE]elseif ( string.find( string.lower( game.GetMap() ), "cs_italy" ) ) then SpawnProps(Vector( 520.4049, 2475.9099, 152.2313 ),Angle( 0.9623, -106.4752, 0.2139 ), "models/props/de_tides/vending_turtle.mdl")[/QUOTE] Then I put the first code on prop_physics2.lua? I'm confused sorry, thanks you.
UP, I continue waiting how learn to fix this, regards.
[QUOTE=Robotboy655;44997696]Register the actual entity, make <gamemode>/entities/entities/prop_physics2.lua, and put in appropriate code.[/QUOTE] I continue without know what are the appropriate code for put in prop_physics2.lua I search but no find nothing about this problem. Any guidance will be helpful for me to look with more certainty and find I need to add that file to fix the problem. since we were so close to solving the problem we still stuck in this last step. Thanks in advance, regards.
[lua]function CreateProp( mdl, pos, ang ) local e = ents.Create( "prop_physics2" ) e:SetModel( mdl ) e:SetPos( pos or vector_origin ) e:SetAngles( ang or angle_zero ) e:Spawn() return e end CreateProp( "models/props/de_tides/vending_turtle.mdl", Vector( 0, 0, -90 ), Angle( 0, 0, 0 ) ) [/lua] [lua] AddCSLuaFile() DEFINE_BASECLASS( "base_anim" ) ENT.RenderGroup = RENDERGROUP_OPAQUE function ENT:Initialize() if SERVER then self:PhysicsInit( SOLID_VPHYSICS ) local phys = self:GetPhysicsObject() if IsValid( phys ) then phys:EnableMotion( false ) end end end[/lua]
[QUOTE=Walrus Viking;45475740][lua]function CreateProp( mdl, pos, ang ) local e = ents.Create( "prop_physics2" ) e:SetModel( mdl ) e:SetPos( pos or vector_origin ) e:SetAngles( ang or angle_zero ) e:Spawn() return e end CreateProp( "models/props/de_tides/vending_turtle.mdl", Vector( 0, 0, -90 ), Angle( 0, 0, 0 ) ) [/lua] [lua] AddCSLuaFile() DEFINE_BASECLASS( "base_anim" ) ENT.RenderGroup = RENDERGROUP_OPAQUE function ENT:Initialize() if SERVER then self:PhysicsInit( SOLID_VPHYSICS ) local phys = self:GetPhysicsObject() if IsValid( phys ) then phys:EnableMotion( false ) end end end[/lua][/QUOTE] The firsts code work fine how the old code. but the second code does nothing (I put the second code in "garrysmod\gamemodes\prop_hunt\entities\entities\prop_physics2.lua" But when a hunter shoots an object created with this code, continue removing life. But thanks for your support. Regards.
That's because you're suppose to add an exception specifically for that entity class. So that if it equals prop_physics2, then you don't remove health.
Sorry, you need to Log In to post a reply to this thread.