Quantcast

Jump to content

» «
Photo

Update ped position

7 replies to this topic
nordi
  • nordi

    Crackhead

  • Members
  • Joined: 17 Mar 2014
  • France

#1

Posted 31 July 2014 - 10:51 AM

Hey

 

I have a ped sitting  inside a vehicle, and what I would like to do, is to place this ped on the ground. but, my code isn't working, the ped is placed on the ground, but under the vehicle, not next to the vehicle. My code:

injuredped.Task.LeaveVehicleImmediately(injuredped.CurrentVehicle);
                                    injuredped.Position = injuredped.GetOffsetPosition(new Vector3(-3, 0, 0));
                                    injuredped.Position.ToGround();

Thanks.


LetsPlayOrDy
  • LetsPlayOrDy

    Too fast for ya

  • Members
  • Joined: 24 Aug 2013
  • United-States

#2

Posted 31 July 2014 - 11:04 AM

Vehicle veh = injuredped.CurrentVehicle;

injuredped.Task.LeaveVehicleImmediately(veh);
injuredped.Position = veh.GetOffsetPosition(new Vector3(-3, 0, 0)).ToGround();
//Something like that. If there are errors, that is because I'm on my phone and I just woke up lol

nordi
  • nordi

    Crackhead

  • Members
  • Joined: 17 Mar 2014
  • France

#3

Posted 31 July 2014 - 12:39 PM

Vehicle veh = injuredped.CurrentVehicle;

injuredped.Task.LeaveVehicleImmediately(veh);
injuredped.Position = veh.GetOffsetPosition(new Vector3(-3, 0, 0)).ToGround();
//Something like that. If there are errors, that is because I'm on my phone and I just woke up lol

 

Now, the ped move, but also the vehicle ! (and the ped is still under the vehicle) ... Here is the current code:

//Code I use to place the ped on the vehicle:
injuredped.WarpIntoVehicle(car_call, VehicleSeat.Driver);


//Code i use to get him out, on the ground:

Vehicle veh = injuredped.CurrentVehicle;
                            injuredped.Task.LeaveVehicleImmediately(injuredped.CurrentVehicle);
                            injuredped.Position = veh.GetOffsetPosition(new Vector3(-3, 0, 0)).ToGround();

LetsPlayOrDy
  • LetsPlayOrDy

    Too fast for ya

  • Members
  • Joined: 24 Aug 2013
  • United-States

#4

Posted 31 July 2014 - 01:00 PM


Vehicle veh = injuredped.CurrentVehicle;

injuredped.Task.LeaveVehicleImmediately(veh);
injuredped.Position = veh.GetOffsetPosition(new Vector3(-3, 0, 0)).ToGround();
//Something like that. If there are errors, that is because I'm on my phone and I just woke up lol

 
Now, the ped move, but also the vehicle ! (and the ped is still under the vehicle) ... Here is the current code:
//Code I use to place the ped on the vehicle:
injuredped.WarpIntoVehicle(car_call, VehicleSeat.Driver);


//Code i use to get him out, on the ground:

Vehicle veh = injuredped.CurrentVehicle;
                            injuredped.Task.LeaveVehicleImmediately(injuredped.CurrentVehicle);
                            injuredped.Position = veh.GetOffsetPosition(new Vector3(-3, 0, 0)).ToGround();
You never said to move the vehicle.
I really don't know what's wrong. Maybe put a while statement in between the LeaveVehicleImmediately and injuredped.Position, like this:

int count = 0;
while (injuredped.isInVehicle(veh) && count < 3000)
{
count++;
Wait(1);
}
This makes sure the ped is outside of the vehicle before you teleport him. The count variable is there so we do not create an infinite loop.
  • nordi likes this

Rugz007
  • Rugz007

    Scripters ... roll out !

  • Members
  • Joined: 19 Apr 2014
  • India

#5

Posted 31 July 2014 - 02:01 PM

Lol do 1 simple trick
1) delete the ped
2) spawn the ped near the car again :p

I think some guys do have a better option

nordi
  • nordi

    Crackhead

  • Members
  • Joined: 17 Mar 2014
  • France

#6

Posted 31 July 2014 - 02:02 PM

 You never said to move the vehicle.

I really don't know what's wrong. Maybe put a while statement in between the LeaveVehicleImmediately and injuredped.Position, like this:

int count = 0;
while (injuredped.isInVehicle(veh) && count < 3000)
{
count++;
Wait(1);
}
This makes sure the ped is outside of the vehicle before you teleport him. The count variable is there so we do not create an infinite loop.

 

 

 

It's working now, thanks !

  • LetsPlayOrDy likes this

LetsPlayOrDy
  • LetsPlayOrDy

    Too fast for ya

  • Members
  • Joined: 24 Aug 2013
  • United-States

#7

Posted 31 July 2014 - 04:15 PM

Lol do 1 simple trick
1) delete the ped
2) spawn the ped near the car again :p

I think some guys do have a better option

That's a horrible option compared to teleporting him.

Wiebrendh
  • Wiebrendh

    C# Programmer

  • Members
  • Joined: 22 Mar 2014
  • Netherlands

#8

Posted 31 July 2014 - 05:52 PM

Hahaha rugz Sorry, But that is even dumb for you
  • PlayPrey likes this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users