I'm busy building a pistol-only area in a map and I've into a problem.
As soon as you enter the area I give a 'useweaponclass pistol'.
This works fine, but if the player dropped its pistol this doesn't do anything.
If the player doesn't have a pistol I want to force the player to holster the weapon.
But how do I find if a player has a weapon?
I can't find any link to the inventory besides 'listinventory' which doesn't seem to do the job I want it to do.
Yes, I know there is a way to detect which gun someone is using using weaponcommand targetname. But this only gives the weapon you are using which is useless if the weapon is holstered.
Btw, I also have a script in RAISE_WEAPON to prevent switching to != pistol.
Checking if a player has a gun.
Moderator: Moderators
-
HeavenBound
- Colour Sergeant
- Posts: 85
- Joined: Thu Sep 11, 2008 12:55 am
I'm doing that now, but its kind of awkward if you dump the gun that you get a new one. That, plus new ammo.
Takeall is not an option because the rest of the guns are used again if you leave that area (its just 1 'room' in the level)
I think its strange that there are plenty of use/give/etc command (found at least 3 ways to give or switch to a gun) but none apparent one that can check if there is a weapon.
Takeall is not an option because the rest of the guns are used again if you leave that area (its just 1 'room' in the level)
I think its strange that there are plenty of use/give/etc command (found at least 3 ways to give or switch to a gun) but none apparent one that can check if there is a weapon.
-
HeavenBound
- Colour Sergeant
- Posts: 85
- Joined: Thu Sep 11, 2008 12:55 am
Well here's your script:
Code: Select all
main:
self weaponcommand dual targetname ("weapon" + self.entnum)
local.weapon = $("weapon" + self.entnum )
if(local.weapon != NULL)
{
self.weapon = $("weapon" + self.entnum ).model
local.weapon targetname ""
}
else
{
self.weapon = "models/weapons/unarmed.tik"
}
end
HeavenBound
I'm new at this
I'm new at this
Read the second line from the bottom again.HeavenBound wrote:Well here's your script:
...
I already use that script, but it only gives me the active weapon, I'm not interested in that.
What I'm interested in is if the player has a pistol or not.
If you run the game, and type listinventory you get the info I want, but for some reason that info cannot be reached from the script.
I can run listinventory, but getting the info in the console is pointless.
-
HeavenBound
- Colour Sergeant
- Posts: 85
- Joined: Thu Sep 11, 2008 12:55 am
