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.

AddMember not working


Noox
 Share

Recommended Posts

Hello,

 

I've got this piece of code

public void mainTick(object sender, EventArgs e)        {            if(inRampage)            {                seconds -= 2;                if (seconds <= 0)                {                    minutes--;                    seconds = 58;                }                Player.Character.Weapons.FromType(weapon).Ammo = 500;                if (Player.Character.Weapons.Current != weapon)                     Player.Character.Weapons.Select(weapon);                if (Player.Character.Health <= 50 && !healthIsBeingAdded)                    Player.Character.Health += 10;                if (Player.WantedLevel > 0)                    Player.WantedLevel = 0;                Random rnd = new Random();                Vector3 playerPos = World.GetNextPositionOnStreet(Player.Character.Position.Around(100.0F));                canSpawn = rnd.Next(0, 100) % 2 == 0;                if(canSpawn)                {                    enemy = World.CreatePed("M_M_ENFORCER", playerPos, RelationshipGroup.Criminal);                    enBlip = enemy.AttachBlip();                    enemy.SetPathfinding(true, true, true);                    enemy.ChangeRelationship(RelationshipGroup.Player, Relationship.Hate);                    enemy.AlwaysDiesOnLowHealth = true;                    enemy.RandomizeOutfit();                    enemy.CowerInsteadOfFleeing = true;                    enemy.Task.FightAgainst(Player.Character);                    Weapon weaponz = Weapon.SMG_MP5;                    enemy.Weapons.FromType(weaponz).Ammo = 500;                    enemy.Weapons.Select(weaponz);                    enemy.Task.GoTo(Player.Character);                    enemyGroup.AddMember(enemy);                }                Game.DisplayText(Convert.ToString(enemyGroup.MemberCount), 4000);                if (seconds == 31 && canGiveMoneys)                {                    Player.Money += 2000;                    canGiveMoneys = false;                }                canGiveMoneys = true;            }        }

And MemberCount always returns 0, it always worked before, why did it stop? :(

Edited by Noox
Link to comment
Share on other sites

Hello,

 

I've got this piece of code

public void mainTick(object sender, EventArgs e)        {            if(inRampage)            {                seconds -= 2;                if (seconds <= 0)                {                    minutes--;                    seconds = 58;                }                Player.Character.Weapons.FromType(weapon).Ammo = 500;                if (Player.Character.Weapons.Current != weapon)                     Player.Character.Weapons.Select(weapon);                if (Player.Character.Health <= 50 && !healthIsBeingAdded)                    Player.Character.Health += 10;                if (Player.WantedLevel > 0)                    Player.WantedLevel = 0;                Random rnd = new Random();                Vector3 playerPos = World.GetNextPositionOnStreet(Player.Character.Position.Around(100.0F));                canSpawn = rnd.Next(0, 100) % 2 == 0;                if(canSpawn)                {                    enemy = World.CreatePed("M_M_ENFORCER", playerPos, RelationshipGroup.Criminal);                    enBlip = enemy.AttachBlip();                    enemy.SetPathfinding(true, true, true);                    enemy.ChangeRelationship(RelationshipGroup.Player, Relationship.Hate);                    enemy.AlwaysDiesOnLowHealth = true;                    enemy.RandomizeOutfit();                    enemy.CowerInsteadOfFleeing = true;                    enemy.Task.FightAgainst(Player.Character);                    Weapon weaponz = Weapon.SMG_MP5;                    enemy.Weapons.FromType(weaponz).Ammo = 500;                    enemy.Weapons.Select(weaponz);                    enemy.Task.GoTo(Player.Character);                    enemyGroup.AddMember(enemy);                }                Game.DisplayText(Convert.ToString(enemyGroup.MemberCount), 4000);                if (seconds == 31 && canGiveMoneys)                {                    Player.Money += 2000;                    canGiveMoneys = false;                }                canGiveMoneys = true;            }        }

And MemberCount always returns 0, it always worked before, why did it stop? :(

Is the ped(s) spawning?

Link to comment
Share on other sites

Maybe change your enemyGroup.AddMember(enemy); to this:

int memberCountBeforeNewPed = enemyGroup.MemberCount;while (enemyGroup.MemberCount == memberCountBeforeNewPed){   enemyGroup.AddMember(enemy);}

This will check if the ped was added to the group yet, and if not, then add him. Though this could result in an infinite loop if the enemy is never added, so you may want it more like this:

int memberCountBeforeNewPed = enemyGroup.MemberCount, numTries = 0;while (enemyGroup.MemberCount == memberCountBeforeNewPed && numTries < 20){   enemyGroup.AddMember(enemy);   numTries++;}
Link to comment
Share on other sites

It doesn't work, anyway I tried adding the player to this group and it gives me an error, something like "non existing object" so maybe the group doesn't exist?

If it doesn't that's weird though as I've already used enemyGroup = new Group(leader)

Link to comment
Share on other sites

Write something that checks if they exist. Like this

if (ped.Exists()){   if (group.Exists())   {      //Add ped to group   }   else   {      Game.DisplayText("Group doesn't exist");   }}else{   Game.DisplayText("Ped doesn't exist");}
Link to comment
Share on other sites

They both exist :panic:

I'd skip the group section but they keep shooting each other, is there a way to avoid this without adding them to a group?

Link to comment
Share on other sites

Maybe change the relationship between the enemy peds. Other then that, I don't know.

Link to comment
Share on other sites

That worked! Also got a kill counter :)

I finished my first mod thanks to you guys, I love you(no homo eheh) :inlove:

Here's a screenshot, I'm happy :D

http://i.imgur.com/uBO1mq7.jpg

Edited by Noox
Link to comment
Share on other sites

Looks nice. Glad I could help :)

You have done so much more than I did in 4 days. My first mod was a check engine light :D

Link to comment
Share on other sites

Thanks!

Well, as long as we're satisfied when our job is done everything is fine :p

Link to comment
Share on other sites

Thanks!

SInce when the mission starts all the peds disappear is there a way to let them appear again when it's over?

 

EDIT: I forgot to change the ped and vehicle density, fixed now ^_^

Edited by Noox
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.