Noox Posted June 24, 2014 Share Posted June 24, 2014 (edited) 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 June 24, 2014 by Noox Link to comment Share on other sites More sharing options...
Jitnaught Posted June 24, 2014 Share Posted June 24, 2014 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 More sharing options...
Noox Posted June 24, 2014 Author Share Posted June 24, 2014 Yes they are. Link to comment Share on other sites More sharing options...
Jitnaught Posted June 24, 2014 Share Posted June 24, 2014 Did you create the group? Using enemyGroup = new Group(leaderPed); ? Link to comment Share on other sites More sharing options...
Noox Posted June 24, 2014 Author Share Posted June 24, 2014 Yes. Link to comment Share on other sites More sharing options...
Jitnaught Posted June 24, 2014 Share Posted June 24, 2014 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 More sharing options...
Noox Posted June 24, 2014 Author Share Posted June 24, 2014 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 More sharing options...
Jitnaught Posted June 24, 2014 Share Posted June 24, 2014 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 More sharing options...
Noox Posted June 24, 2014 Author Share Posted June 24, 2014 They both exist 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 More sharing options...
Jitnaught Posted June 24, 2014 Share Posted June 24, 2014 Maybe change the relationship between the enemy peds. Other then that, I don't know. Link to comment Share on other sites More sharing options...
Noox Posted June 24, 2014 Author Share Posted June 24, 2014 (edited) That worked! Also got a kill counter I finished my first mod thanks to you guys, I love you(no homo eheh) Here's a screenshot, I'm happy http://i.imgur.com/uBO1mq7.jpg Edited June 24, 2014 by Noox Link to comment Share on other sites More sharing options...
Jitnaught Posted June 24, 2014 Share Posted June 24, 2014 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 Link to comment Share on other sites More sharing options...
Noox Posted June 24, 2014 Author Share Posted June 24, 2014 Thanks! Well, as long as we're satisfied when our job is done everything is fine Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted June 24, 2014 Share Posted June 24, 2014 (edited) ... Edited July 2, 2014 by LordOfTheBongs Link to comment Share on other sites More sharing options...
Noox Posted June 24, 2014 Author Share Posted June 24, 2014 (edited) 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 June 24, 2014 by Noox Wiebrendh 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now