Page 1 of 3

How to check if instigator of inventory is inside a vehicle

Posted: Thu 24 Nov , 2011 2:28 am
by LegendaryAgent
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!

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

Posted: Thu 24 Nov , 2011 4:20 am
by Azarael
Passengers are attached to ONSWeaponPawns, not the Vehicle. The Vehicle should have a list of these pawns. Look through the list.

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

Posted: Thu 24 Nov , 2011 4:25 am
by LegendaryAgent
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?

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

Posted: Thu 24 Nov , 2011 3:15 pm
by Azarael
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.

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

Posted: Fri 25 Nov , 2011 6:49 am
by LegendaryAgent
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.

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

Posted: Fri 25 Nov , 2011 12:45 pm
by iZumo
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.

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

Posted: Fri 25 Nov , 2011 4:59 pm
by LegendaryAgent
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?

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

Posted: Fri 25 Nov , 2011 5:10 pm
by Azarael

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.

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

Posted: Fri 25 Nov , 2011 5:19 pm
by LegendaryAgent
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?

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

Posted: Fri 25 Nov , 2011 6:54 pm
by Azarael
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).