How to check if instigator of inventory is inside a vehicle

You need help? It's here!
LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

How to check if instigator of inventory is inside a vehicle

Post by LegendaryAgent » Thu 24 Nov , 2011 2:28 am

Hey all, im having a hard time making my powerup vehicle compatible, basically i need to check if the instigator of an inventory subclass is inside a vehicle, so far it works fine for driver with:
instigator.drivenvehicle

however as passenger some weird things happen, how can i check if the instigator of an inventory is inside a vehicle not as driver but as passenger?

Thanks in advance as usual!

User avatar
Azarael
UT2004 Administrator
Posts: 5365
Joined: Thu 11 Feb , 2010 10:52 pm

Re: How to check if instigator of inventory is inside a vehi

Post by Azarael » Thu 24 Nov , 2011 4:20 am

Passengers are attached to ONSWeaponPawns, not the Vehicle. The Vehicle should have a list of these pawns. Look through the list.

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to check if instigator of inventory is inside a vehi

Post by LegendaryAgent » Thu 24 Nov , 2011 4:25 am

Azarael wrote:Passengers are attached to ONSWeaponPawns, not the Vehicle. The Vehicle should have a list of these pawns. Look through the list.
hey aza i was just thinking that but, wouldnt it cause problems with non gunned seats? like for example, custom hellbenders with only passenger seats and no rear or side turret?

User avatar
Azarael
UT2004 Administrator
Posts: 5365
Joined: Thu 11 Feb , 2010 10:52 pm

Re: How to check if instigator of inventory is inside a vehi

Post by Azarael » Thu 24 Nov , 2011 3:15 pm

If the weapon isn't actually on the vehicle, the ONSWeaponPawn doesn't exist. An ONSWeaponPawn can be attached to any bone - nothing is left behind if a weapon is removed from a vehicle.

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to check if instigator of inventory is inside a vehi

Post by LegendaryAgent » Fri 25 Nov , 2011 6:49 am

Azarael wrote:If the weapon isn't actually on the vehicle, the ONSWeaponPawn doesn't exist. An ONSWeaponPawn can be attached to any bone - nothing is left behind if a weapon is removed from a vehicle.
thanks aza what i meant was, what about the seats with no weapons at all, i mean u still can seat in the vehicles, but u cant fire, just shoot, those too count as weapons?
EDIT, also how can i check if instigator is currently in a vehicle? ive tried this:

Code: Select all

if(ONSVehicle(Instigator)!=None)
{
for(i=0;i<ONSVehicle(Instigator).WeaponPawns.Length;i++)
{
if(ONSVehicle(Instigator).WeaponPawns[i].Driver==Instigator)
//whatever
}
}

but it always returns false, what gives? :S Please note Instigator is the reference to the owner of an inventory class.

iZumo
Disappeared Administrator
Posts: 4196
Joined: Fri 19 Mar , 2010 1:21 am
Location: Earth
Contact:

Re: How to check if instigator of inventory is inside a vehi

Post by iZumo » Fri 25 Nov , 2011 12:45 pm

LegendaryAgent wrote:
Azarael wrote:If the weapon isn't actually on the vehicle, the ONSWeaponPawn doesn't exist. An ONSWeaponPawn can be attached to any bone - nothing is left behind if a weapon is removed from a vehicle.
thanks aza what i meant was, what about the seats with no weapons at all, i mean u still can seat in the vehicles, but u cant fire, just shoot, those too count as weapons?
EDIT, also how can i check if instigator is currently in a vehicle? ive tried this:

Code: Select all

if(ONSVehicle(Instigator)!=None)
{
for(i=0;i<ONSVehicle(Instigator).WeaponPawns.Length;i++)
{
if(ONSVehicle(Instigator).WeaponPawns[i].Driver==Instigator)
//whatever
}
}

but it always returns false, what gives? :S Please note Instigator is the reference to the owner of an inventory class.
Use "Vehicle" when casting instead of ONSVehicle, because ONSWeaponPawn is not ONSVehicle.

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to check if instigator of inventory is inside a vehi

Post by LegendaryAgent » Fri 25 Nov , 2011 4:59 pm

Izumo_CZ wrote:
LegendaryAgent wrote:
Azarael wrote:If the weapon isn't actually on the vehicle, the ONSWeaponPawn doesn't exist. An ONSWeaponPawn can be attached to any bone - nothing is left behind if a weapon is removed from a vehicle.
thanks aza what i meant was, what about the seats with no weapons at all, i mean u still can seat in the vehicles, but u cant fire, just shoot, those too count as weapons?
EDIT, also how can i check if instigator is currently in a vehicle? ive tried this:

Code: Select all

if(ONSVehicle(Instigator)!=None)
{
for(i=0;i<ONSVehicle(Instigator).WeaponPawns.Length;i++)
{
if(ONSVehicle(Instigator).WeaponPawns[i].Driver==Instigator)
//whatever
}
}

but it always returns false, what gives? :S Please note Instigator is the reference to the owner of an inventory class.
Use "Vehicle" when casting instead of ONSVehicle, because ONSWeaponPawn is not ONSVehicle.

Thats weird o.O, but if i try: Vehicle(Instigator).WeaponPawns it will give me an error saying weaponpawns is not part of vehicle, and if i use onsvehicle such error doesnt happen, any ideas?

User avatar
Azarael
UT2004 Administrator
Posts: 5365
Joined: Thu 11 Feb , 2010 10:52 pm

Re: How to check if instigator of inventory is inside a vehi

Post by Azarael » Fri 25 Nov , 2011 5:10 pm

Code: Select all

if(ONSVehicle(Instigator)!=None)
{
for(i=0;i<ONSVehicle(Instigator).WeaponPawns.Length;i++)
{
if(ONSVehicle(Instigator).WeaponPawns[i].Driver==Instigator)
//whatever
}
}
Bad logic.

Instigator is the owner of some Inventory class. You're first checking that the ONSVehicle is the Instigator. Then you're checking the WeaponPawn drivers to see if they're also the instigator.

ONSVehicle(Instigator).WeaponPawns.Driver==Instigator

For this to evaluate true, the driver for one of the vehicle's weapon pawns would have to be the actual vehicle itself.

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: How to check if instigator of inventory is inside a vehi

Post by LegendaryAgent » Fri 25 Nov , 2011 5:19 pm

Azarael wrote:

Code: Select all

if(ONSVehicle(Instigator)!=None)
{
for(i=0;i<ONSVehicle(Instigator).WeaponPawns.Length;i++)
{
if(ONSVehicle(Instigator).WeaponPawns[i].Driver==Instigator)
//whatever
}
}
Bad logic.

Instigator is the owner of some Inventory class. You're first checking that the ONSVehicle is the Instigator. Then you're checking the WeaponPawn drivers to see if they're also the instigator.

ONSVehicle(Instigator).WeaponPawns.Driver==Instigator

For this to evaluate true, the driver for one of the vehicle's weapon pawns would have to be the actual vehicle itself.


Yeah i was kinda suspecting that lol, how can i see in what vehicle the instigator is in, considering i can only access the properties of the player through its inventory class?

User avatar
Azarael
UT2004 Administrator
Posts: 5365
Joined: Thu 11 Feb , 2010 10:52 pm

Re: How to check if instigator of inventory is inside a vehi

Post by Azarael » Fri 25 Nov , 2011 6:54 pm

Is "DrivenVehicle" actually intended to be a reference to the player's current mode of transport? Looking through the code I would have suggested that the purpose of it is to give kill credit when a player exits a vehicle and that vehicle later somehow kills a player. Note the past tense of "Driven".

If you're checking for a player in a weapon turret, cast ONSWeaponPawn(Instigator). If you're looking for a player in a driving seat, cast (Vehicle(Instigator) != None && ONSWeaponPawn(Instigator) == None).

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests