How to check if instigator of inventory is inside a vehicle
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
How to check if instigator of inventory is inside a vehicle
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!
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!
- 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
Passengers are attached to ONSWeaponPawns, not the Vehicle. The Vehicle should have a list of these pawns. Look through the list.
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: How to check if instigator of inventory is inside a vehi
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?Azarael wrote:Passengers are attached to ONSWeaponPawns, not the Vehicle. The Vehicle should have a list of these pawns. Look through the list.
- 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
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.
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: How to check if instigator of inventory is inside a vehi
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?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.
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.
-
- 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
Use "Vehicle" when casting instead of ONSVehicle, because ONSWeaponPawn is not ONSVehicle.LegendaryAgent wrote: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?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.
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.
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: How to check if instigator of inventory is inside a vehi
Izumo_CZ wrote:Use "Vehicle" when casting instead of ONSVehicle, because ONSWeaponPawn is not ONSVehicle.LegendaryAgent wrote: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?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.
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.
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?
- 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
Code: Select all
if(ONSVehicle(Instigator)!=None)
{
for(i=0;i<ONSVehicle(Instigator).WeaponPawns.Length;i++)
{
if(ONSVehicle(Instigator).WeaponPawns[i].Driver==Instigator)
//whatever
}
}
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.
-
- Member
- Posts: 80
- Joined: Thu 29 Sep , 2011 12:26 am
- Contact:
Re: How to check if instigator of inventory is inside a vehi
Azarael wrote:Bad logic.Code: Select all
if(ONSVehicle(Instigator)!=None) { for(i=0;i<ONSVehicle(Instigator).WeaponPawns.Length;i++) { if(ONSVehicle(Instigator).WeaponPawns[i].Driver==Instigator) //whatever } }
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?
- 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
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).
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).
Who is online
Users browsing this forum: No registered users and 33 guests