Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      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

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

Help with code a bit


jstq
 Share

Recommended Posts

i've tried to modify code from code request thread

using GTA;using [email protected];using GTA.value;using GTA.Native;using System;using System.Text;using System.Windows.Forms;using System.Xml;using System.Collections.Generic;namespace Riot {public class Main : Script{            List<Ped> g_armedPeds;       List<Ped> g_unArmedPeds; Random random; RelationshipGroup[] groups; bool toggle;      public Main()      {                     g_armedPeds = new List<Ped>();          g_unArmedPeds = new List<Ped>();          groups = new RelationshipGroup[] { RelationshipGroup.Bum, RelationshipGroup.Civillian_Female, RelationshipGroup.Civillian_Male, RelationshipGroup.Cop, RelationshipGroup.Criminal, RelationshipGroup.Dealer, RelationshipGroup.Fireman, RelationshipGroup.Gang_AfricanAmerican, RelationshipGroup.Gang_Albanian, RelationshipGroup.Gang_Biker1, RelationshipGroup.Gang_Biker2, RelationshipGroup.Gang_ChineseJapanese, RelationshipGroup.Gang_Irish, RelationshipGroup.Gang_Italian, RelationshipGroup.Gang_Jamaican, RelationshipGroup.Gang_Korean, RelationshipGroup.Gang_PuertoRican, RelationshipGroup.Gang_Russian1, RelationshipGroup.Gang_Russian2, RelationshipGroup.Medic, RelationshipGroup.Player, RelationshipGroup.Prostitute, RelationshipGroup.Special };          random = new Random();          BindKey(Keys.Insert, Toggle);      }      private void Toggle()      {          toggle = !toggle;                     if (toggle) { Tick += Main_Tick; }          else { Tick -= Main_Tick; }          Game.DisplayText("Riot " + (toggle ? "En" : "Dis") + "abled");      }      private void Main_Tick(object sender, EventArgs e)      {          foreach (Ped ped in World.GetPeds(Game.LocalPlayer.Character.Position, 30f))          {                             if (!ped.Exists()) continue;              if (Game.LocalPlayer.Character == ped) continue;              if (!ped.isAliveAndWell || ped.RelationshipGroup == GTA.RelationshipGroup.Medic) continue;              if (ped.isMissionCharacter||ped.isRequiredForMission) continue;              if (ped.RelationshipGroup == GTA.RelationshipGroup.Cop)              {                  if (!Player.Character.isInVehicle() && Player.Character.Weapons.Current != GTA.Weapon.Unarmed)                      if (ped.PedType == PedType.Cop)                          if (Function.Call<bool>("HAS_CHAR_SPOTTED_CHAR_IN_FRONT", ped, Game.LocalPlayer.Character))                          {                              if (Game.LocalPlayer.WantedLevel < 1) Game.LocalPlayer.WantedLevel = 1;                          }                  continue;              }              if (g_armedPeds.Contains(ped)||g_unArmedPeds.Contains(ped)) continue;              if (random.Next(0, 100) > 70)              {                  MadPed(ped);                  if (ped.isInVehicle())                  {                      ped.WillDoDrivebys = true;                      ped.Weapons.Uzi.Ammo = 500;                      ped.Weapons.Uzi.Select();                      List<Ped> tmpL = new List<Ped>();                      if (!ped.CurrentVehicle.isSeatFree(VehicleSeat.LeftRear)) tmpL.Add(ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.LeftRear));                      if (!ped.CurrentVehicle.isSeatFree(VehicleSeat.RightFront)) tmpL.Add(ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightFront));                      if (!ped.CurrentVehicle.isSeatFree(VehicleSeat.RightRear)) tmpL.Add(ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightRear));                      foreach (Ped curr_ped in tmpL) if (curr_ped.Exists()) curr_ped.RelationshipGroup = ped.RelationshipGroup;                      g_armedPeds.Add(ped);                      //ped.Task.CruiseWithVehicle(ped.CurrentVehicle, 40f, true);                      Game.DisplayText("DriveBy Ped Spawned, mad ped count: " + g_armedPeds.Count +" unarmed peds: "+ g_unArmedPeds.Count);                                         }                  else                  {                      ArmPed(ped);                      ped.Task.FightAgainstHatedTargets(45f);                      g_armedPeds.Add(ped);                      if (ped.Weapons.Current == GTA.Weapon.Unarmed)                                                 ped.Weapons.Select(GTA.Weapon.Misc_AnyWeapon);                                             Game.DisplayText("Mad Pet On foot Spawned, mad ped count: " + g_armedPeds.Count + " unarmed peds: " + g_unArmedPeds.Count);                  }                  break;              }              else g_unArmedPeds.Add(ped);          }          CleanList();          this.Wait(5000);	      }            private void MadPed(Ped ex_ped)      {          HateEveryone(ex_ped);          //ex_ped.BlockGestures = true;          ex_ped.BlockPermanentEvents = true;          ex_ped.Task.AlwaysKeepTask = true;          ex_ped.CowerInsteadOfFleeing = true;          ex_ped.StartKillingSpree(true);          ex_ped.WillUseCarsInCombat = true;          //ex_ped.WantedByPolice = true;          ex_ped.Armor = 100;          ex_ped.AttachBlip();      }      private void HateEveryone(Ped ex_ped)      {          foreach (RelationshipGroup group in groups)          {              if (ex_ped.RelationshipGroup == group || ex_ped.RelationshipGroup == RelationshipGroup.Cop) continue;              if (ex_ped.RelationshipGroup == RelationshipGroup.Cop && group == RelationshipGroup.Cop) continue;              ex_ped.ChangeRelationship(group, Relationship.Hate);          }      }      private void ArmPed(Ped ped)      {          int selection = random.Next(0, 5);          switch (selection)          {              case 0:                  ped.Weapons.Glock.Ammo = 500;                  ped.Weapons.Glock.Select();                  break;              case 1:                  ped.Weapons.Uzi.Ammo = 500;                  ped.Weapons.Uzi.Select();                  break;              case 2:                  ped.Weapons.BasicShotgun.Ammo = 100;                  ped.Weapons.BasicShotgun.Select();                  break;              case 3:                  ped.Weapons.AssaultRifle_AK47.Ammo = 500;                  ped.Weapons.AssaultRifle_AK47.Select();                  break;              case 4:                  ped.Weapons.MolotovCocktails.Ammo = 10;                  ped.Weapons.MolotovCocktails.Select();                  break;          };      }      private void CleanList()      {          for (int i = g_armedPeds.Count -1; i > -1; i--)              if (!g_armedPeds[i].Exists() || !g_armedPeds[i].isAlive)  g_armedPeds.RemoveAt(i);          for (int i = g_unArmedPeds.Count - 1; i > -1; i--)              if (!g_unArmedPeds[i].Exists()||!g_unArmedPeds[i].isAlive) g_unArmedPeds.RemoveAt(i);      }  }  }

1) driver ped stop his car and attack his passengers, but i've changed their rel group to similar as driver has

2) all mad peds not selecting their weapons

3) all mad peds is just crouching in fear

4) script often gives error:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.                        at Scripting.?A0xf88de8d2.SetCharRelationshipGroup(Int32 , UInt32 )                        at GTA.Ped.set_RelationshipGroup(RelationshipGroup value)                        at Riot.Main.Main_Tick(Object sender, EventArgs e)                        at GTA.Script.TryTick()                        at GTA.Script.DoTick()                        at GTA.ScriptThread.OnTick()

why? i've checked everything...

5) driver ped never do drivebys

help plz user posted image

 

also:

Vehicle veh = GTA.World.GetClosestVehicle(Player.Character.Position,10f);          if (veh.Exists())          {              Ped jacked_ped = veh.GetPedOnSeat(VehicleSeat.Driver);              if (jacked_ped.Exists())                   if (Function.Call<bool>("IS_PED_BEING_JACKED", jacked_ped))                      Game.DisplayText("It works!");

this gives me a null reference exception, why?

Edited by jstq
Link to comment
Share on other sites

one step forward

 

foreach (Ped curr_ped in tmpL) if (curr_ped.Exists()) curr_ped.RelationshipGroup = ped.RelationshipGroup;

 

i believe that this line (69) its causing the error cited in item 4

 

 

other thing, startKillingSpree (called at line 98, after MadPed method) will change the relationship to hate all, it will change cops relationship too, so it conflicts with the HateEveryone method

 

this is one part of the startKillingSpree:

 

int i = 1;

if (alsoAttackPlayer) i = 0;

for (; i <= 22; i++) {

//if (i != (int)grp)

ChangeRelationship((GTA::RelationshipGroup)i, GTA::Relationship::Hate);

}

 

im doing some tests here, this is it for now

 

 

Link to comment
Share on other sites

 

2) all mad peds not selecting their weapons

3) all mad peds is just crouching in fear

 

add this before MadPed(ped); line 59:

 

ped.BecomeMissionCharacter();

Link to comment
Share on other sites

thanks man! user posted image

so madped is like this now:

 private void MadPed(Ped ex_ped)      {          ex_ped.BecomeMissionCharacter();          //HateEveryone(ex_ped);          //ex_ped.BlockGestures = true;          ex_ped.BlockPermanentEvents = true;          ex_ped.Task.AlwaysKeepTask = true;          ex_ped.CowerInsteadOfFleeing = true;          ex_ped.StartKillingSpree(true);          ex_ped.WillUseCarsInCombat = true;          //ex_ped.WantedByPolice = true;          ex_ped.Armor = 100;          ex_ped.AttachBlip();      }

i'll try test this now

can you tell me whats better, use my hateEveryone func or use startKillingSpree?

 

and i modifed foreach:

 

 foreach (Ped curr_ped in tmpL) if (curr_ped.Exists()&&!curr_ped.Equals(null)) curr_ped.RelationshipGroup = ped.RelationshipGroup;

maybe it'll dont give me any errors...

ok, in game there were two mad peds spawned at one street, so one just standed and do nothing and another killed him from a cover. After he kill him, script gave me the same error like in item 4

Edited by jstq
Link to comment
Share on other sites

 

can you tell me whats better, use my hateEveryone func or use startKillingSpree?

 

well, your hateEveryone ignore cops, startKillingSpree dont, but if you use startKillingSpree you will need to use:

 

ped.Task.FightAgainstHatedTargets(45f);

 

when the Ped isInVehicle, otherwise he dont will fight, i think

Link to comment
Share on other sites

thanks

i noticed, that ped after he become mad and he killed all targets in his radius 45f just stands still, even if i shoot at him hi did no react

i think this will help:

 private void CleanList()      {          if (g_armedPeds.Count>0)              for (int i = g_armedPeds.Count - 1; i > -1; i--)              {                  if (!g_armedPeds[i].Exists() || !g_armedPeds[i].isAlive)                  {                      g_armedPeds[i].NoLongerNeeded();                      g_armedPeds.RemoveAt(i);                      Game.DisplayText("Ped " + i + " removed cus he died!");                  }                  else                      if (Player.Character.Position.DistanceTo(g_armedPeds[i].Position) > 200) //r(a,b)= sqrt((x1-x2)^2 + (y1-y2)^2 +(z1-z2)^2) { a=(x1,y1,z1) и b=(x2,y2,z2)} ???                      {                          g_armedPeds[i].NoLongerNeeded();                          g_armedPeds.RemoveAt(i);                          Game.DisplayText("Ped " + i + " removed cus of distance!");                      }                      else                      {                          g_armedPeds[i].Task.FightAgainstHatedTargets(45f, 20000);                          Game.DisplayText("Ped " + i + " got refreshed his mission!");                      }              }          if (g_unArmedPeds.Count > 0)              for (int i = g_unArmedPeds.Count - 1; i > -1; i--)                  if (!g_unArmedPeds[i].Exists() || !g_unArmedPeds[i].isAlive) g_unArmedPeds.RemoveAt(i);      }

called every 20 seconds

doesnt work sad.gif

how to remove blip from character? http://www.gtamodding.com/index.php?title=REMOVE_BLIP there is no info about that function

 

 

how to get char id?

there is Player.ID and it doesnt match to function

Function.Call<bool>("IS_CHAR_TRYING_TO_ENTER_A_LOCKED_CAR", Player.ID)

 

there is function

Function.Call<int>("GET_PLAYER_ID")

and it still doesnt match to

Function.Call<bool>("IS_CHAR_TRYING_TO_ENTER_A_LOCKED_CAR", Function.Call<int>("GET_PLAYER_ID"))

 

and there is function

Function.Call<int>("CONVERT_INT_TO_PLAYERINDEX", Function.Call<int>("GET_PLAYER_ID")) 

and it still doesnt match for

 Function.Call<bool>("IS_CHAR_TRYING_TO_ENTER_A_LOCKED_CAR", Function.Call<int>("CONVERT_INT_TO_PLAYERINDEX", Function.Call<int>("GET_PLAYER_ID")))

 

WTF)))))

Edited by jstq
Link to comment
Share on other sites

 

...

called every 20 seconds

doesnt work

 

try adding the fight task again

 

 

how to remove blip from character? http://www.gtamodding.com/index.php?title=REMOVE_BLIP there is no info about that function

 

well, when you call AttachBlip method, you will probably receive an Blip object, with this object you can use the blip methods like Delete();

if this code was in VB, i would suggest to use Metadata to store this blip object, and in your cleanlist method, you can retrive this blip and delete it from g_armedPeds for example. But you are using C#, metadata dont work fine when the script its not compiled into a DLL, this make hard to develop and test this method, so you can use an list of blips like the g_armedPeds list, and add each blip to this list:

 

 

//in the atttachblip part:g_blips.Add(ex_ped.AttachBlip());//in the clean method:for (int i = g_armedPeds.Count -1; i > -1; i--){ if (!g_armedPeds[i].Exists() || !g_armedPeds[i].isAlive)  {    //add an FOR to try to find what blip is attached to this ped    if  (!g_armedPeds[i].isAlive) {     for (int j = g_blips.Count - 1; j > -1; j--)      {        if (g_blips[j].GetAttachedItem() == g_armedPeds[i]) {          g_blips[j].Delete();          g_blips.RemoveAt(j);        }      }   }   //    g_armedPeds.RemoveAt(i); }}

 

 

 

how to get char id?

 

try Player.Character instead of Player.ID (i didnt tested, in vb should work ^^)

 

but seems that you are trying to see if the players's Ped its getting inside an vehicle right? do this check instead:

 

Player.Character.isGettingIntoAVehicle

Edited by julionib
Link to comment
Share on other sites

Where can i find string values for PlayAudioEvent function?

How can i get saved cars near player safehouses?

 

GetAttachedItem()
there is no such metod...

 

and another problem... i want to spawn ped, for example cop

Ped NewCop = GTA.World.CreatePed(Model.BasicCopModel, g_armedPeds[i].Position + g_armedPeds[i].Direction.Around(50),RelationshipGroup.Cop);NewCop.Task.AlwaysKeepTask = true;                          NewCop.Task.FightAgainstHatedTargets(100);                          NewCop.Weapons.BasicShotgun.Ammo = 100;

cop flying in air and reacts nothing. also he is immortal. but when im attack him im getting stars.

im trying to google first but all i found is:

dll/asi mods

list of native functions with no comments at all

some other useless crap

dead topics on gtaforums with no answer user posted image

also i need help with this func: "IS_CAR_IN_GARAGE_AREA"

static b8 IsCarInGarageArea(const ch *garageName, Vehicle vehicle) { return NativeInvoke::Invoke<b8>("IS_CAR_IN_GARAGE_AREA", garageName, vehicle); }

where can i find garageName list?

i want to get all saved cars or just to know is it in garage area

Edited by jstq
Link to comment
Share on other sites

mmm

 

i failed in trying to use the PlayAudioEvent in past ^^

realy didnt worked

i cant find a list of this audio events but, we have some examples of use out there:

 

https://bitbucket.org/ThreeSocks/gtaiv-trai...enu/menu_core.c

 

 

 

the GetAttachedItem its from Blip objects, you used with Blip.GetAttachedItem()?

 

 

 

in your cop spawn, use an close position, without adding ped direction:

 

Ped NewCop = GTA.World.CreatePed(Model.BasicCopModel, g_armedPeds.Position.around(3), RelationshipGroup.Cop);

NewCop.Task.AlwaysKeepTask = true;

NewCop.Task.FightAgainstHatedTargets(100);

NewCop.Weapons.BasicShotgun.Ammo = 100;

 

and add an task to WanderAorund or Goto, to make him move

 

 

Link to comment
Share on other sites

user posted image

dozingoff.gif

 

and add an task to WanderAorund or Goto, to make him move
TaskSequence ts = new TaskSequence();

ts.AddTask.GoTo(Player.Character.Position);

ts.AddTask.FightAgainstHatedTargets(50f);

like this?

 

i saw this but not exactly what i want

i want mad peds to shout some phrases like "die moterf*ckers" sly.gif

anyway thanks

blip remover nervous.gif

 

class Blip_and_obj       {           public Ped AttachedToPed;           public Vehicle AttachedToVeh;           public Blip blip;           public bool NoLongerNeeded;           public Blip_and_obj(Ped ex_ped, Blip ex_blip)           {               AttachedToPed = ex_ped;               blip = ex_blip;               AttachedToVeh = null;               NoLongerNeeded = false;           }           public Blip_and_obj(Vehicle ex_veh, Blip ex_blip)           {               AttachedToVeh = ex_veh;               blip = ex_blip;               AttachedToPed = null;               NoLongerNeeded = false;           }       }private void removeblips()      {          if (g_blips.Count > 0)              for (int i = g_blips.Count - 1; i > -1; i--)              {                  if (g_blips[i].AttachedToPed != null)                  {                      if (!g_blips[i].AttachedToPed.Exists())                      {                          g_blips[i].blip.Delete();                          g_blips.RemoveAt(i);                      }                      else                          if (!g_blips[i].AttachedToPed.isAlive || g_blips[i].NoLongerNeeded)                          {                              g_blips[i].blip.Delete();                              g_blips[i].AttachedToPed.NoLongerNeeded();                              g_blips.RemoveAt(i);                          }                  } else                  if (g_blips[i].AttachedToVeh != null)                      if (!g_blips[i].AttachedToVeh.Exists())                      {                          g_blips[i].blip.Delete();                          g_blips.RemoveAt(i);                      }                      else                      {                          if (!g_blips[i].AttachedToVeh.isDriveable || g_blips[i].NoLongerNeeded)                          {                              g_blips[i].blip.Delete();                              g_blips[i].AttachedToVeh.NoLongerNeeded();                              g_blips.RemoveAt(i);                          }                      }                                        }      }

 

lmao xD
you should visit psychologist or surgeon yawn.gif
ped.BecomeMissionCharacter();                                              TaskSequence ts = new TaskSequence();                          ts.AddTask.RunTo(stealed_veh.Position);                                                ts.AddTask.EnterVehicle(stealed_veh, VehicleSeat.Driver);                          ts.AddTask.CruiseWithVehicle(stealed_veh, 100, true);                          ped.BlockPermanentEvents = true;                          ped.Task.AlwaysKeepTask = true;                          ped.Task.PerformSequence(ts);                          ped.WantedByPolice = true;

i want ped to steal a car, but he just stands still. ped exists and car exists and drivable. He dont even run to it

also, when mad ped is first spawned, he just stands still

MadPed(ped);                  if (ped.isInVehicle())                  {                      ped.WillDoDrivebys = true;                      ped.Weapons.Uzi.Ammo = 500;                      ped.Weapons.Uzi.Select();                      List<Ped> tmpL = new List<Ped>();                      if (!ped.CurrentVehicle.isSeatFree(VehicleSeat.LeftRear)) tmpL.Add(ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.LeftRear));                      if (!ped.CurrentVehicle.isSeatFree(VehicleSeat.RightFront)) tmpL.Add(ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightFront));                      if (!ped.CurrentVehicle.isSeatFree(VehicleSeat.RightRear)) tmpL.Add(ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightRear));                      //foreach (Ped curr_ped in tmpL) if (curr_ped.Exists()&&!curr_ped.Equals(null)) curr_ped.RelationshipGroup = ped.RelationshipGroup;                      g_armedPeds.Add(ped);                                     }                  else                  {                      ArmPed(ped);                      g_armedPeds.Add(ped);                      if (ped.Weapons.Current == GTA.Weapon.Unarmed)                                                 ped.Weapons.Select(GTA.Weapon.Misc_AnyWeapon);                  }private void MadPed(Ped ex_ped)      {          if (!ex_ped.isMissionCharacter)              ex_ped.BecomeMissionCharacter();          HateEveryone(ex_ped);          ex_ped.BlockPermanentEvents = true;          ex_ped.Task.AlwaysKeepTask = true;          ex_ped.CowerInsteadOfFleeing = true;          ex_ped.CanSwitchWeapons = true;          ex_ped.WillUseCarsInCombat = true;          ex_ped.WantedByPolice = true;          ex_ped.Armor = 100;          ex_ped.Task.FightAgainstHatedTargets(45f);      }      private void HateEveryone(Ped ex_ped)      {          if (ex_ped.Exists()&&Exists(ex_ped))              foreach (RelationshipGroup group in groups)              {                  if (ex_ped.RelationshipGroup == group || ex_ped.RelationshipGroup == RelationshipGroup.Cop) continue;                  if (ex_ped.RelationshipGroup == RelationshipGroup.Cop && group == RelationshipGroup.Cop) continue;                  ex_ped.ChangeRelationship(group, Relationship.Hate);              }      }      private void ArmPed(Ped ped)      {          Random random = new Random();          int selection = random.Next(0, 3);          selection = selection * random.Next(0, 3);          ped.Weapons.Grenades.Ammo = 50;          switch (selection)          {              case 0:                  ped.Weapons.Uzi.Ammo = 1000;                  ped.Weapons.Uzi.Select();                                     break;              case 1:                  ped.Weapons.Grenades.Ammo = 20;                  ped.Weapons.Grenades.Select();                  break;              case 2:                  ped.Weapons.BasicShotgun.Ammo = 100;                  ped.Weapons.BasicShotgun.Select();                  break;              case 3:                  ped.Weapons.AssaultRifle_AK47.Ammo = 1000;                  ped.Weapons.AssaultRifle_AK47.Select();                  break;              case 4:                                     ped.Weapons.MolotovCocktails.Ammo = 25;                  ped.Weapons.MolotovCocktails.Select();                  break;          };      }

but when i'm updating his task in cleaning thread (it searches for dead/non exists peds/vehs, and if it is a mad ped, updates his mission), and find alive mad ped

g_armedPeds[i].Task.FightAgainstHatedTargets(45f);g_armedPeds[i].Health += 10;

he starts search targets and kills them

so i need to apply task twice to make ped do it? wtf?

Edited by jstq
Link to comment
Share on other sites

i tested the code of steal car:

 

ped.BecomeMissionCharacter();

TaskSequence ts = new TaskSequence();

ts.AddTask.RunTo(stealed_veh.Position);

ts.AddTask.EnterVehicle(stealed_veh, VehicleSeat.Driver);

ts.AddTask.CruiseWithVehicle(stealed_veh, 100, true);

ped.BlockPermanentEvents = true;

ped.Task.AlwaysKeepTask = true;

ped.Task.PerformSequence(ts);

ped.WantedByPolice = true;

 

and worked, i think that you are mistakenly cleaning the task in another part of the code

 

i added that part in the else of the "if (ped.isInVehicle())" to make this test:

 

 

if (ped.isInVehicle())

{

ped.WillDoDrivebys = true;

ped.Weapons.Uzi.Ammo = 500;

ped.Weapons.Uzi.Select();

//List<Ped> tmpL = new List<Ped>();

//if (!ped.CurrentVehicle.isSeatFree(VehicleSeat.LeftRear)) tmpL.Add(ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.LeftRear));

//if (!ped.CurrentVehicle.isSeatFree(VehicleSeat.RightFront)) tmpL.Add(ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightFront));

//if (!ped.CurrentVehicle.isSeatFree(VehicleSeat.RightRear)) tmpL.Add(ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightRear));

//foreach (Ped curr_ped in tmpL) if (curr_ped.Exists()) curr_ped.RelationshipGroup = ped.RelationshipGroup;

g_armedPeds.Add(ped);

//ped.Task.CruiseWithVehicle(ped.CurrentVehicle, 40f, true);

Game.DisplayText("DriveBy Ped Spawned, mad ped count: " + g_armedPeds.Count +" unarmed peds: "+ g_unArmedPeds.Count);

GTA.Native.Function.Call("SMASH_CAR_WINDOW", ped.CurrentVehicle, 0);

ped.Task.FightAgainstHatedTargets(45f);

}

else

{

ArmPed(ped);

ped.Task.FightAgainstHatedTargets(45f);

g_armedPeds.Add(ped);

//if (ped.Weapons.Current == GTA.Weapon.Unarmed)

// ped.Weapons.Select(GTA.Weapon.Misc_AnyWeapon);

Game.DisplayText("Mad Pet On foot Spawned, mad ped count: " + g_armedPeds.Count + " unarmed peds: " + g_unArmedPeds.Count);

 

Vehicle stealed_veh = World.GetClosestVehicle(Player.Character.Position, 20);

ped.BecomeMissionCharacter();

TaskSequence ts = new TaskSequence();

ts.AddTask.RunTo(stealed_veh.Position);

ts.AddTask.EnterVehicle(stealed_veh, VehicleSeat.Driver);

ts.AddTask.CruiseWithVehicle(stealed_veh, 100, true);

ped.BlockPermanentEvents = true;

ped.Task.AlwaysKeepTask = true;

ped.Task.PerformSequence(ts);

ped.WantedByPolice = true;

}

break;

 

 

if you remove the RunTo task, he still going running to the car

Link to comment
Share on other sites

straaaaaange

i think that if you add task sequence to any ped, second task will overwrite first, third overwrites second ... so only last remains

run to car < ped receive this task

enter car < but instantly it will overwritten

cruise < and remains this - so ped is not in the car, he will just stand still

to avoid this i wrote little function, class wit 3 constructors and list which stores it

class SpawnedCrap       {           public Ped SpawnedPed;           public Vehicle SpawnedVehicle;           public int PedMissionType;           public Vector3 PlacePedMustGoTo;           public Vehicle VehPedMustEnter;           public int counter;           public bool NoLongerNeeded;           public SpawnedCrap(Ped ex_ped,int ex_pedMisstype,Vector3 ex_place)           {               SpawnedPed = ex_ped;               SpawnedVehicle = null;               PedMissionType = ex_pedMisstype;               PlacePedMustGoTo = ex_place;               counter = 0;               NoLongerNeeded = false;           }           public SpawnedCrap(Ped ex_ped, int ex_pedMisstype, Vehicle ex_veh)           {               SpawnedPed = ex_ped;               SpawnedVehicle = null;               PedMissionType = ex_pedMisstype;               VehPedMustEnter = ex_veh;               counter = 0;               NoLongerNeeded = false;           }           public SpawnedCrap(Vehicle ex_veh)           {               SpawnedVehicle = ex_veh;               SpawnedPed = null;               NoLongerNeeded = false;           }       }private void PedTaskFunc(object sender, EventArgs e)      {          msg("we are inner ped task func", 0);          for (int i = g_spawnedCrap.Count - 1; i > -1; i--)              if (g_spawnedCrap[i].SpawnedPed != null) //if it is a ped                  if (g_spawnedCrap[i].SpawnedPed.Exists() && g_spawnedCrap[i].SpawnedPed.isAliveAndWell && !g_spawnedCrap[i].NoLongerNeeded)                  {                      if (g_spawnedCrap[i].PedMissionType == (int)PedMissionType.CopPedDriver)                      {                          if (g_spawnedCrap[i].SpawnedPed.isInVehicle() && g_spawnedCrap[i].SpawnedPed.CurrentVehicle.isDriveable)                          {                              if (g_spawnedCrap[i].SpawnedPed.Position.DistanceTo(g_spawnedCrap[i].PlacePedMustGoTo) > 10)//if ped doesnt reach his destination                               {                                  if (g_spawnedCrap[i].counter < 60) //and he has time for it                                  {                                      msg("Cop driver is driving to his dest    " + g_spawnedCrap[i].counter, 0);                                      g_spawnedCrap[i].SpawnedPed.Task.DriveTo(g_spawnedCrap[i].PlacePedMustGoTo, 150, true);                                      g_spawnedCrap[i].counter++;                                  }                                  else // if ped tried to reach his dest for too long                                      g_spawnedCrap[i].NoLongerNeeded = true;                              }                              else if (g_spawnedCrap[i].SpawnedPed.isInVehicle())//if ped reached his dest                              {                                  msg("Cop driver reached his dest and will leave his car    " + g_spawnedCrap[i].counter, 0);                                  g_spawnedCrap[i].SpawnedPed.Task.LeaveVehicle(g_spawnedCrap[i].SpawnedPed.CurrentVehicle, false);                                  g_spawnedCrap[i].SpawnedPed.Task.FightAgainstHatedTargets(50);                                  g_spawnedCrap[i].NoLongerNeeded = true;                              }                              else //is on foot                              {                                  g_spawnedCrap[i].SpawnedPed.Task.FightAgainstHatedTargets(50);                                  g_spawnedCrap[i].NoLongerNeeded = true;                              }                          }                          else g_spawnedCrap[i].NoLongerNeeded = true;                      }                      else if (g_spawnedCrap[i].PedMissionType == (int)PedMissionType.CopPedPass)                      {                          if (g_spawnedCrap[i].SpawnedPed.isInVehicle()&&g_spawnedCrap[i].SpawnedPed.CurrentVehicle.isDriveable) // if passanger cop is in car and car is drivable                          {                              if (!g_spawnedCrap[i].SpawnedPed.CurrentVehicle.isSeatFree(VehicleSeat.Driver) && g_spawnedCrap[i].counter < 60) //if there is a driver and cop got time                              {                                  msg("Cop passanger waiting to arrive    " + g_spawnedCrap[i].counter, 0);                                  g_spawnedCrap[i].counter++;                              }                              else //if there is no driver or he got no time                              {                                  msg("Cop passanger arrived or out of time    " + g_spawnedCrap[i].counter, 0);                                  g_spawnedCrap[i].SpawnedPed.Task.LeaveVehicle(g_spawnedCrap[i].SpawnedPed.CurrentVehicle, false);                                  g_spawnedCrap[i].SpawnedPed.Task.FightAgainstHatedTargets(50);                                  g_spawnedCrap[i].NoLongerNeeded = true;                              }                          }                          else //he is on foot or car is not drivable                          {                              if (g_spawnedCrap[i].SpawnedPed.isInVehicle())                                  g_spawnedCrap[i].SpawnedPed.Task.LeaveVehicle(g_spawnedCrap[i].SpawnedPed.CurrentVehicle, false);                              g_spawnedCrap[i].SpawnedPed.Task.FightAgainstHatedTargets(50);                              g_spawnedCrap[i].NoLongerNeeded = true;                          }                      }                      else if (g_spawnedCrap[i].PedMissionType == (int)PedMissionType.CarStealer)                      {                          if (g_spawnedCrap[i].VehPedMustEnter != null && g_spawnedCrap[i].VehPedMustEnter.Exists()) // if car exists                          {                              if (!g_spawnedCrap[i].SpawnedPed.isInVehicle()) // if car stealer is not in a car                              {                                  if (g_spawnedCrap[i].counter < 60) //if he has time for it                                  {                                      msg("Car stealer tries to enter a car    " + g_spawnedCrap[i].counter, 0);                                      g_spawnedCrap[i].SpawnedPed.Task.EnterVehicle(g_spawnedCrap[i].VehPedMustEnter, VehicleSeat.Driver);                                      g_spawnedCrap[i].counter++;                                  }                                  else g_spawnedCrap[i].NoLongerNeeded = true; //if not - ne no longer needed                              }                              else //if he is in car                              {                                  msg("Car stealer entered a car!    " + g_spawnedCrap[i].counter, 0);                                  g_spawnedCrap[i].SpawnedPed.Task.CruiseWithVehicle(g_spawnedCrap[i].SpawnedPed.CurrentVehicle, 150, true);                                  g_spawnedCrap[i].NoLongerNeeded = true;                              }                          }                          else //car drive away or destroyed or some other crap                          {                                                             if (g_spawnedCrap[i].counter < 60)                              {                                  msg("car stealer tries to find another car    " + g_spawnedCrap[i].counter, 0);                                  g_spawnedCrap[i].VehPedMustEnter = World.GetClosestVehicle(g_spawnedCrap[i].SpawnedPed.Position, 30);                                  g_spawnedCrap[i].counter++;                              }                              else g_spawnedCrap[i].NoLongerNeeded = true;                          }                      }                      else if (g_spawnedCrap[i].PedMissionType == (int)PedMissionType.CopOnFoot)                      {                          if (g_spawnedCrap[i].SpawnedPed.Position.DistanceTo(g_spawnedCrap[i].PlacePedMustGoTo) > 10) //if spawned cop far away from his destination                          {                              if (g_spawnedCrap[i].counter < 60) // and he has time to move                              {                                  g_spawnedCrap[i].counter++;                                  g_spawnedCrap[i].SpawnedPed.Task.GoTo(g_spawnedCrap[i].PlacePedMustGoTo.Around(10));                              }                              else g_spawnedCrap[i].NoLongerNeeded = true;                          }                          else //he @ his dest                          {                              g_spawnedCrap[i].SpawnedPed.Task.FightAgainstHatedTargets(50);                              g_spawnedCrap[i].NoLongerNeeded = true;                          }                      }                  }                  else g_spawnedCrap[i].NoLongerNeeded = true;      }

sometimes it loops, i have to debug this... BUT if you say task sequence is really works, i have to test it another time user posted image

Link to comment
Share on other sites

 

sometimes it loops, i have to debug this... BUT if you say task sequence is really works, i have to test it another time

 

well it worked fine, and did all tasks, RunTo, then EnterVehile and finally tryed to cruise wtih vehicle

 

 

obs.: dont pay attenttion to nonsense like the post above...

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.