• Pass hook PlayerLeaveVehicle argument self
    12 replies, posted
Good Evening. How can I get an argument self in the hook PlayerLeaveVehicle ? (not veh)
self? You mean a player or a vehicle?
You're very unclear in what you're trying to do here, self is the first argument passed for methods and just references the current object. In the case of a player self is the player the function is currently running on. The hook passes two arguments to the callback function the first being the player and the second being the vehicle, I'm not sure what else you'd want.
Look. I have an entity and it creates prop_vehicle_prisoner_pod. When player leaves pod I want to check if self == "something". So I need to get argument self in the hook PlayerLeaveVehicle. How can I do it?
'Self' is not a specific argument, in fact the names of the arguments don't matter, it depends on how you name them inside hooks. In the PlayerLeaveVehicle, the first argument will always be the player and the second one will always be the vehicle.
I know, but I need to get self value in the hook PlayerLeaveVehicle
What is self value? There is no such thing as self value.
The car creates a chair. I need to get self - a car
The vehicle you left is the second argument
Can you provide us with the code you have already? For both the chair/car/whatever
=) That is the problem. I don't need a vehicle argument. I need an argument of the car (self ​ ) in the hook PlayerLeaveVehicle
In the ENT:InitializeVehicle function, you will need to do something like self.DriverSeat.ParentCar = self and your PlayerLeaveVehicle will look something like this: hook.Add( "PlayerLeaveVehicle", "DESNA1", function(ply, veh)     if veh:GetClass() == "prop_vehicle_prisoner_pod" and veh.ParentCar then             local self = veh.ParentCar // now self is your car entity     end     end )
Got it! Thank you too much!
Sorry, you need to Log In to post a reply to this thread.