get Players weapon?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

get Players weapon?

Post by Elgan »

Hey, is it possible to detect what weapon or what weapon class/type is being used?


ive tried everything but everything returned NILL :(
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

There's several ways, this is probably the easiest:

Code: Select all

local.randomnum = randomint 1000
local.player weaponcommand dual targetname local.randomnum
local.thisplayersweapon = entity local.randomnum // or $(local.randomnum)
local.thisplayersweapon targetname "" // clear targetname
Do not execute a weaponcommand each frame though, they will stack and cause major lag after about a minute or so.
Image
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

cool...out of intrest..whats the hardest way?:)
User avatar
At0miC
General
Posts: 1164
Joined: Fri Feb 27, 2004 11:29 pm
Location: The Netherlands

Post by At0miC »

LOL, the hardest way is to find out yourself :lol:
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Well that's probably true At0mic :wink:

Another way would be this:

Code: Select all

parm.weapplayer = local.player
local.player weaponcommand dual exec somescript.scr
local.weapon = local.player.lastdetectedweapon
And then in main somescript.scr have:

Code: Select all

main:
  parm.weapplayer.lastdetectedweapon = self
end
Image
Post Reply