Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Cayo Perico Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

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

    1. Red Dead Redemption 2

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

    1. Grand Theft Auto Series

      1. 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. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. 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. 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

      1. GTANet 20th Anniversary
    2. Support

    3. Suggestions

How do i make my script detect when i kill my spawned peds?


MH7

Recommended Posts

I was trying to make a script that involves you having to kill 5 certain peds that i earlier coded to spawn.
The problem is that i have no idea how to make the game detect when you kill them so that the script can continue. If anyone can help me please do so.
World.CreatePed(fe, (spawn1));
World.CreatePed(fe, (spawn2));

World.CreatePed(fe, (spawn3));
World.CreatePed(ma, (spawn4));

World.CreatePed(ma, (spawn5));

Link to post
Share on other sites

Im not quite sure where im to put this or how this works. I get an error saying IsPedDeadOrDying(int, bool)' must declare a body because it is not marked 'static extern'

Edited by MH7
btw im in c#
Link to post
Share on other sites
if(ped.IsDead)
   ped.Delete()
Or try this, don't understand what you're doing without seeing your code.

 

 

Edited by DuncanMac
Link to post
Share on other sites
10 hours ago, DuncanMac said:
if(ped.IsDead)
   ped.Delete()
Or try this, don't understand what you're doing without seeing your code.

 

Ok here is my code so far.
 

    public class Main : Script
    {
        bool MissionActive = true;
        int MissionIndex = 0;
        Blip missionblip;
        Vector3 createposition = new Vector3(-1858f, -348f, 50f);
        Vehicle plane;
        bool Subtitle1Active = false;
        bool teleport1 = false;
        Vector3 toli = new Vector3(2525f, -269f, -59f);
        Prop myProp = null;
        bool cashtrolly1 = false;
        Prop DuffelBag;
        int SceneID;
        bool SceneActive = false;
        int SceneIndex = -1;
        bool anim1 = false;
        bool loadanim1 = false;
        bool waypoint1 = false;
        bool loadanim2 = false;
        bool waypoint2 = false;
        Vector3 createposition2 = new Vector3(-1619f, 180f, 61);
        bool shootingstuff1 = false;
        Model male1 = "a_m_m_bevhills_02";
        Model female1 = "a_f_y_genhot_01";
        Vector3 spawn1 = new Vector3(-1635f, 180f, 61);
        Vector3 spawn2 = new Vector3(-1633f, 180f, 61);
        Vector3 spawn3 = new Vector3(-1630f, 180f, 61);
        Vector3 spawn4 = new Vector3(-1625f, 180f, 61);
        Vector3 spawn5 = new Vector3(-1619f, 180f, 61);
        bool part2 = false;
        bool MissionActive2 = false;
        int MissionIndex2 = 0;
        Blip missionblip2;
        bool IsPedDead;
        bool IsPedDeadOrDying;
        
        

        public Main()
        {
            Tick += onTick;
            KeyDown += onKeyDown;
        }

        private void onTick(object sender, EventArgs e)
        {
            if (MissionActive)
            {
                switch (MissionIndex)
                {
                    case 0:
                        {
                            
                            waypoint1 = true;
                            if (waypoint1)
                            {
                                missionblip = World.CreateBlip(createposition);
                                if (missionblip.Exists()) ;

                                // Waypoint
                                if (waypoint1) missionblip.Sprite = (BlipSprite)378;
                                missionblip.Color = BlipColor.Red;
                                missionblip.Name = "Test";
                                missionblip.ShowRoute = false;
                            }
                            MissionIndex = 10;
                        }
                        break;
                    case 10:
                        {
                            Subtitle1Active = false;
                            if (Game.Player.Character.Position.DistanceTo(createposition) < 10f)
                            {
                                if (missionblip.Exists())
                                {
                                    missionblip.ShowRoute = false;
                                }
                                MissionIndex = 20;
                            }
                        }
                        break;
                    case 20:
                        {
                            // On ground marker
                            World.DrawMarker(MarkerType.VerticalCylinder, createposition, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(1.5f, 1.5f, 0.5f), Color.FromArgb(204, 204, 0));
                            if (Game.Player.Character.Position.DistanceTo(createposition) < 1.5f)
                            {
                                //test
                                DisplayHelpTextThisFrame("Press E to start the mission");
                                if (Game.IsControlJustPressed(2, GTA.Control.Context))
                                {
                                    MissionIndex = 30;
                                }
                            }
                        }
                        break;
                    case 30:
                        {
                            waypoint2 = true;
                            if (waypoint2)
                            {

                                waypoint1 = false;
                                missionblip = World.CreateBlip(createposition2);
                                if (missionblip.Exists()) ;
                                if (waypoint2) missionblip.Sprite = (BlipSprite)1;
                                missionblip.Color = BlipColor.Yellow;
                                missionblip.Name = "Test";
                                missionblip.ShowRoute = true;

                                Vehicle v = World.CreateVehicle("gburrito", new Vector3(-1663.496F, 77.4890F, -63.2900F));

                                {

                                }
                            }
                            
                            {
                                MissionIndex = 40;
                            }
                            teleport1 = false;
                        }
                        break;
                    case 40:
                        {
                            
                            {

                                {
                                    

                                        Ped ped = World.CreatePed(female1, (spawn1));
                                    World.CreatePed(female1, (spawn2));
                                    World.CreatePed(female1, (spawn3));
                                    World.CreatePed(male1, (spawn4));
                                    World.CreatePed(male1, (spawn5));
                                    if (Ped.IsDead) doSomething();
                                }
                                

                            }
                            
                            
                            {
                                
                            }
                            {
                                // Scrapped

                                {
                                    MissionIndex = 50;
                                }
                            }
                        }
                        break;
                    case 50:
                        {
                            // Subtitile to loot the area
                            {
                                
                            }

                            {

                                
                                {
                                    
                                    {
                                        
                                    }

                                }
                            }

                            {
                                MissionIndex = 60;
                            }
                        }
                        break;

BTW i started coding two days ago so excuse me for any stupid mistakes i made

Link to post
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
  • 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.