Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (85,344 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

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

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

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

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

    2. Site Suggestions

Sign in to follow this  
Noox

AddMember not working

Recommended Posts

Noox

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

Share this post


Link to post
Share on other sites
Jitnaught

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?

Share this post


Link to post
Share on other sites
Noox

Yes they are.

Share this post


Link to post
Share on other sites
Jitnaught

Did you create the group? Using enemyGroup = new Group(leaderPed); ?

Share this post


Link to post
Share on other sites
Noox

Yes.

Share this post


Link to post
Share on other sites
Jitnaught

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++;}

Share this post


Link to post
Share on other sites
Noox

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)

Share this post


Link to post
Share on other sites
Jitnaught

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");}

Share this post


Link to post
Share on other sites
Noox

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?

Share this post


Link to post
Share on other sites
Jitnaught

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

Share this post


Link to post
Share on other sites
Noox

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

Share this post


Link to post
Share on other sites
Jitnaught

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

Share this post


Link to post
Share on other sites
Noox

Thanks!

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

Share this post


Link to post
Share on other sites
LordOfTheBongs

...

Edited by LordOfTheBongs

Share this post


Link to post
Share on other sites
Noox

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

Share this post


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
Sign in to follow this  

×

Important Information

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