• Print

Author Topic: Entites  (Read 4324 times)

0 Members and 1 Guest are viewing this topic.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Entites
« on: September 04, 2016, 12:08:56 am »
Generally I just want to ask if anyone here knows a lot about entities, but I'm sure people will say a lot about that. I myself do not know entities very well, but I will soon have to learn either way. I know server side more then all the other fun stuff. Though, if anyone can assist me with these two things, so I have a better understanding exactly how I want to proceed on my idea, that would be great.

First off I want to be able to press the use key, and then words pop up on said entity saying who owns it. I got as far as to tell me who owns it, but my issue is I don't recall a way to show it up on screen who owns it.
Code: Lua
  1. function ENT:Use( ply, ply2 )
  2.         if SERVER then
  3.                 if ply:IsPlayer() == true then
  4.                         local findplayer = nil
  5.                         for k, v in pairs(player.GetAll()) do
  6.                                 if v == self:GetNWEntity( "owner" ) then
  7.                                         findplayer = v
  8.                                 end
  9.                         end
  10.                         if findplayer != nil then
  11.                                 MsgN(findplayer:Name())
  12.                         else
  13.                                 MsgN("World")
  14.                         end
  15.                 end
  16.         end
  17. end
  18.  

Now the second to last request is I have no clue how to do. I want to be able to hit entity (which is going to be square/rectangle) and where ever I hit it, it makes a small black line at it. I will draw this out on photoshop to show you exactly what I mean.

This is our tree/square


Meet Mr. Crowbar


Mr. Crowbar smacks the tree at said location making a black line all the way through it. This black line is only relative to the amount of damage mr. crowbar did to that object as a whole


As damage increases, and the health decreases as an entire entity, the line gets bigger before reaching 0


Tree them falls apart, becoming two entites




I'm now realizing how difficult this request is becoming.
« Last Edit: September 04, 2016, 12:26:03 am by Bite That Apple »
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Entites
« Reply #1 on: September 04, 2016, 05:24:45 am »
If you need to do the owner checking server side, you can use a net message to send the client the owner and then have them draw it with 3D2D or just the surface library.

As for the black line, I'm sure there are multiple options. I've seen people 'cut' into the world with stencils, but I'm not exactly sure how. You'd probably be better off asking this on Facepunch, simply because of the volume of users making it more likely that someone can help you. You could also just use 3D2D to draw a line in front of the tree, but that would need to be changed each time they moved and would probably look strange.

I found a few threads and a tool after a quick search, they might be helpful.
Stencils to cut holes in things
Physical Clip Tool
Stencil tutorial

For the splitting-into-two-entities part, you should be able to just spawn two new entities. I'm not sure if it's possible to scale entities or anything, if so then you could just spawn two with lengths according to where the 'cut' was made.

It's a shame there is so little documentation for Garry's Mod. There seem to be so many cool things you can do, but it's quite the uphill battle to figure it out.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

  • Print