Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Vehicle is moving back and forth


abdelmoez
 Share

Recommended Posts

hi guys

 

i wrote a script in c# for gta v

 

i create Ped and vehicle and i give to the Ped a target so he will to

 

but when the ped enter the car and drive he do strange thing he drive 1 cm forward the 1 cm backward !!!

 

this is my code

vehicle = World.CreateVehicle(new Model("Crusader"), new GTA.Math.Vector3(-1572f, 2772f, 17f), 228f);                var ped = World.CreatePed(PedHash.Marine01SMM, new GTA.Math.Vector3(-1572f, 2772f, 17f));                ped.Task.DriveTo(vehicle, new GTA.Math.Vector3(443f, 2036f, 107f),70f, 550f);Function.Call(Hash.SET_PED_INTO_VEHICLE, ped, vehicle, -1f); 
by the way in the drive to task the 3rd argument is radius and i dont know what should i put for so i keep it 70

 

 

Link to comment
Share on other sites

vehicle = World.CreateVehicle(new Model("Crusader"), new GTA.Math.Vector3(-1572f, 2772f, 17f), 228f);            var ped = vehicle.CreatePedOnSeat(VehicleSeat.Driver, PedHash.Marine01SMM); //create ped directly on seat instead of spawning, tasking to drive, then warping ped into vehicle            ped.Task.DriveTo(vehicle, new GTA.Math.Vector3(443f, 2036f, 107f), 10f, 50f); //70 meters is quite far away, and I don't think 550 meters per second is even possible in GTA

No idea if this will help, but they are some things that I thought could be improved.

Link to comment
Share on other sites

bhavinbhai2707

hi guys

 

i wrote a script in c# for gta v

 

i create Ped and vehicle and i give to the Ped a target so he will to

 

but when the ped enter the car and drive he do strange thing he drive 1 cm forward the 1 cm backward !!!

 

this is my code

vehicle = World.CreateVehicle(new Model("Crusader"), new GTA.Math.Vector3(-1572f, 2772f, 17f), 228f);                var ped = World.CreatePed(PedHash.Marine01SMM, new GTA.Math.Vector3(-1572f, 2772f, 17f));                ped.Task.DriveTo(vehicle, new GTA.Math.Vector3(443f, 2036f, 107f),70f, 550f);Function.Call(Hash.SET_PED_INTO_VEHICLE, ped, vehicle, -1f); 

by the way in the drive to task the 3rd argument is radius and i dont know what should i put for so i keep it 70

 

heyyy i found some mistakes

1. i suggest u too use ped.setintovehicle bcause its implemented in scripthook so why to mess up with params n yess use it before driveto function because u know c# compiles line by line so it will first give command to drive n then set which is not right n check ur params i think u r doing something wrong or either upload the native over here so i can check because m in phone so its difficult to browse native db

 

n about radius it means that upto how much distance around destination u want to drive

 

for ex:- if u put radius 5f the ped will drive around 5f radius of desti point :)

Link to comment
Share on other sites

Thanks both for replying

but the vehicle is still moving so slow and back and forth !!

Link to comment
Share on other sites

check ur params i think u r doing something wrong or either upload the native over here so i can check because m in phone so its difficult to browse native db

Besides him making the third parameter a float he did nothing wrong.

void SET_PED_INTO_VEHICLE(Ped ped, Vehicle vehicle, int seatIndex) //correct function params

-1 (int) is the driver's seat.

Link to comment
Share on other sites

 

check ur params i think u r doing something wrong or either upload the native over here so i can check because m in phone so its difficult to browse native db

Besides him making the third parameter a float he did nothing wrong.

void SET_PED_INTO_VEHICLE(Ped ped, Vehicle vehicle, int seatIndex) //correct function params

-1 (int) is the driver's seat.

 

 

I changed my code to this and nothing changed '

vehicle = World.CreateVehicle(new Model("Crusader"), new GTA.Math.Vector3(-1572f, 2772f, 20f), 228f);var ped = vehicle.CreatePedOnSeat(VehicleSeat.Driver, PedHash.Marine01SMM); //create ped directly on seat instead of spawning, tasking to drive, then warping ped into vehicleped.SetIntoVehicle(vehicle, VehicleSeat.Driver);ped.Task.DriveTo(vehicle, new GTA.Math.Vector3(443f, 2036f, 107f), 10f, 50f); //70 meters is quite far away, and I don't think 550 meters per second is even possible in GTA

 

Edited by abdelmoez
Link to comment
Share on other sites

Remove "ped.SetIntoVehicle(vehicle, VehicleSeat.Driver);", you don't need it, because vehicle.CreatePedOnSeat already does that.

Edited by Jitnaught
Link to comment
Share on other sites

 

Hello guys !

 

I have a problem with my code... The same problem than here :

 

http://gtaforums.com/topic/817640-police-car-stuck-driveto-task-not-working/?hl=drive

 

My police car is very slowly ... I don't know how can i fixe it, i have tried the solution in the link but it's don't work...

 

This is my code :

 

VoiturePoliceRenfort = World.CreateVehicle(ModelVehiculePolice, joueur.GetOffsetInWorldCoords(new Vector3(0.0f, 50.0f, 0.0f))); // joueur.Position.Around(250f); don't work too...VoiturePoliceRenfort.PlaceOnNextStreet();VoiturePoliceRenfort.PlaceOnGround();VoiturePoliceRenfort.LightsOn = true;VoiturePoliceRenfort.SirenActive = true;RenfortPoliceConducteur.DrivingStyle = DrivingStyle.Rushed;RenfortPoliceConducteur.Task.DriveTo(VoiturePoliceRenfort, joueurPosition, 20.0f, 100.0f);

Please do you can help me ?

 

[stAfF]MaN

 

 

 

EDIT :

 

Problem found !!

 

Don't report in the tick() method this :

 

Game.Player.IgnoredByPolice; OR Game.Player.IgnoredByEveryone;

 

If you don't want police, juste set the wanted level to 0 in the tick() method ;) !!

 

I think it'll help you :p

Link to comment
Share on other sites

@abdelmoez

I tested the code I gave you and this is the result:

. I do not get the problem you have. There must be another part of your mod that is causing the problem.

 

@StAfFMaN

I tested the code I gave him with IgnoredByEveryone and IgnoredByPolice set to true in a Tick, and I got the result you had in your post, but not the result he has, which is the ped driving forward and back repeatedly.

Edited by Jitnaught
Link to comment
Share on other sites

@StAfFMaN

 

I tested the code I gave him with IgnoredByEveryone and IgnoredByPolice set to true in a Tick, and I got the result you had in your post, but not the result he has, which is the ped driving forward and back repeatedly.

 

Oh okay sorry :/I thought it was the same problem

But... i think there must be code in a loop that causes the problem

Link to comment
Share on other sites

Oh okay sorry :/ I thought it was the same problem

But... i think there must be code in a loop that causes the problem

If he does have that code in his Tick I still think he should try removing the code to see if it helps.

Link to comment
Share on other sites

@abdelmoez

I tested the code I gave you and this is the result:

. I do not get the problem you have. There must be another part of your mod that is causing the problem.

 

@StAfFMaN

I tested the code I gave him with IgnoredByEveryone and IgnoredByPolice set to true in a Tick, and I got the result you had in your post, but not the result he has, which is the ped driving forward and back repeatedly.

 

I started new project and deleted all of the other code but the problem still there

 

 

this is the code

using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;using GTA;using GTA.Native;public class ArmyAttach : Script{    private Vehicle vehicle;    public ArmyAttach()    {        Tick += OnTick;        KeyDown += OnKeyDown;        KeyUp += OnKeyUp;    }    void OnTick(object sender, EventArgs e)    {    }    void OnKeyDown(object sender, KeyEventArgs e)    {    }    void OnKeyUp(object sender, KeyEventArgs e)    {        if (e.KeyCode == Keys.H)        {            vehicle = World.CreateVehicle(new Model("Crusader"), new GTA.Math.Vector3(-1572f, 2772f, 20f), 228f);            var ped = vehicle.CreatePedOnSeat(VehicleSeat.Driver, PedHash.Marine01SMM);            ped.Armor = 75;            ped.Weapons.Give(WeaponHash.SMG, 900, true, true);            ped.Task.DriveTo(vehicle, new GTA.Math.Vector3(443f, 2036f, 107f), 10f, 50f);            UI.Notify("~b~Army~w~ Has Been Spawned");        }    }}
Edited by abdelmoez
Link to comment
Share on other sites

Hm, maybe there is another mod that is conflicting?

 

thanks for every thing

i made new copy of my GTA V folder and i deleted all the mods and it worked fin thanks :)

Link to comment
Share on other sites

bhavinbhai2707

 

Hm, maybe there is another mod that is conflicting?

thanks for every thing

i made new copy of my GTA V folder and i deleted all the mods and it worked fin thanks :)

just try to figure out which mod is conflicting with urs :)

Link to comment
Share on other sites

 

 

Hm, maybe there is another mod that is conflicting?

thanks for every thing

i made new copy of my GTA V folder and i deleted all the mods and it worked fin thanks :)

just try to figure out which mod is conflicting with urs :)

 

I have about 50 mods :blink: it's very hard to figure out

Link to comment
Share on other sites

bhavinbhai2707

 

 

 

Hm, maybe there is another mod that is conflicting?

 

thanks for every thing

i made new copy of my GTA V folder and i deleted all the mods and it worked fin thanks :)

just try to figure out which mod is conflicting with urs :)

 

I have about 50 mods :blink: it's very hard to figure out

 

if u will upload it somewhere then u have to find which mod is causing problem otherwise it can conflict for them too :)

Link to comment
Share on other sites

 

 

 

 

Hm, maybe there is another mod that is conflicting?

thanks for every thing

i made new copy of my GTA V folder and i deleted all the mods and it worked fin thanks :)

just try to figure out which mod is conflicting with urs :)

I have about 50 mods :blink: it's very hard to figure out

if u will upload it somewhere then u have to find which mod is causing problem otherwise it can conflict for them too :)

 

 

 

Yeah i know that , but I made this mod for myself :colgate: so no need for that :cool:

 

thanks by the way

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.