Author Topic: How can I get the weapon used when you damage someone.  (Read 2266 times)

0 Members and 1 Guest are viewing this topic.

Offline Deathtitan77

  • Jr. Member
  • **
  • Posts: 63
  • Karma: 6
How can I get the weapon used when you damage someone.
« on: June 18, 2013, 08:55:15 AM »
How can I do that?

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: How can I get the weapon used when you damage someone.
« Reply #1 on: June 18, 2013, 08:59:45 AM »
There's an OnDamage hook that gives you this information.
Experiencing God's grace one day at a time.

Offline Deathtitan77

  • Jr. Member
  • **
  • Posts: 63
  • Karma: 6

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Experiencing God's grace one day at a time.

Offline Deathtitan77

  • Jr. Member
  • **
  • Posts: 63
  • Karma: 6
Re: How can I get the weapon used when you damage someone.
« Reply #4 on: June 18, 2013, 09:10:15 AM »
Well, I have a question for you. In this example: http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe50a.html using dmginfo:GetInflictor():GetClass() prints 'player', any idea why?
It also says here: Entity Inflictor(usually a weapon)
« Last Edit: June 18, 2013, 09:12:45 AM by Deathtitan77 »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: How can I get the weapon used when you damage someone.
« Reply #5 on: June 18, 2013, 12:37:41 PM »
You just have to explore all the options. There is a lot of information you haven't checked into yet. The gmod documentation is wrong (or at least misleading) 49% of the time.
Experiencing God's grace one day at a time.