Log in to reply
 

Ped doesnt know where he is



  • i want ped runto thegun and immidiately reload when he arrived there (not script.wait)
    private void OnKeyDown(object sender, KeyEventArgs e)
    {
    if (e.KeyCode == Keys.U)
    {
    PedGroup nho = playerPed.CurrentPedGroup;
    Vector3 hereme = playerPed.Position + (playerPed.ForwardVector * 2);
    Ped companion = World.CreatePed(PedHash. Armoured01, hereme);
    Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, companion, nho);
    companion.Weapons.Give(WeaponHash.Musket, 9999, true, true);
    Prop randomgun = Function.Call<Prop>(Hash.GET_CLOSEST_OBJECT_OF_TYPE, companion.Position.X, companion.Position.Y, companion.Position.Z, 35f, Function.Call<int>(Hash.GET_HASH_KEY, "w_sb_microsmg"), 0, 0, 0);
    if (randomgun.Exists())
    {
    float HowFar = World.GetDistance(companion.Position, randomgun.Position);
    while (HowFar < 1)
    {
    companion.Task.ReloadWeapon(); //reload means pickup
    }

                while(HowFar>1)
                {
                    companion.Task.RunTo(randomgun.Position);
                    float NewHowFar = World.GetDistance(companion.Position, randomgun.Position); // creat new distance after his run
                    if(NewHowFar < 1) // recheck the new distance
                    companion.Task.ReloadWeapon();   // if new distance is close reload
                }
            }
        }

Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.