ShadowCoderKing Posted May 6, 2017 Share Posted May 6, 2017 (edited) hi im very new at this and im only used to making cleo mods for sa so please bear with me how do i stop spawned peds from dying in one hit from a head shot ? i'd like to get subtitle text to appear in game when i want but dont know the codes i'd like to start making mission type script mods and im open to any help and advice thanks : ) Edited May 6, 2017 by SpiderMight Link to comment Share on other sites More sharing options...
WolfGum Posted May 6, 2017 Share Posted May 6, 2017 SpiderMight. I'm new to C# too. I have managed to script a mod that allows me to spawn in peds. So, I'm going to give you a part of my code. if(e.KeyCode == Keys.H) ((Remove these messages that have double brackets. You can change 'H' to any key you'd like to.)) { Ped player = Game.Player.Character; GTA.Math.Vector3 SpawnLoc = player.Position + (player.ForwardVector * 5); ((If you know how to change the direction that the ped spawns in, you may do so.)) string model_name = "a_c_husky"; ((You don't need to spawn in a Husky. You can change that. I chose a Husky, because it was what I used when I made this script.)) Ped companion = GTA.World.CreatePed(model_name, SpawnLoc); } } } I hope my code is simple enough and tidy enough for you to understand and implement into your script. I do not need credit, or gratitude. I only want you to thrive in scripting. Link to comment Share on other sites More sharing options...
ShadowCoderKing Posted May 6, 2017 Author Share Posted May 6, 2017 (edited) thanks wolfgum. how do i remove a blip from a ped, when i try it always stays on the radar Blip OneMarker = EnemyOne.AddBlip(); if (Entity.Exists(EnemyOne) && EnemyOne.IsDead) { EnemyOne.Delete(); OneMarker.Remove(); } Edited May 6, 2017 by SpiderMight Link to comment Share on other sites More sharing options...
sollaholla Posted May 6, 2017 Share Posted May 6, 2017 (edited) thanks wolfgum. how do i remove a blip from a ped, when i try it always stays on the radar Make sure you're not doing: EnemyOne.AddBlip(); -- in the OnTick method. You should only be adding the blip to the Ped when you create him/her. (In your case at-least) And remove the blip like this: if (Entity.Exists(EnemyOne) && EnemyOne.IsDead){ // Yep, that's right, that's it. Since the blip is attached to EnemyOne, once you delete // the ped, the blip will also be removed. EnemyOne.Delete();} Edited May 6, 2017 by sollaholla Link to comment Share on other sites More sharing options...
ShadowCoderKing Posted May 6, 2017 Author Share Posted May 6, 2017 (edited) that is simple thank you, do you know how to add subtitle text on the screen ? Edited May 6, 2017 by SpiderMight Link to comment Share on other sites More sharing options...
sollaholla Posted May 6, 2017 Share Posted May 6, 2017 that is simple thank you, do you know how to add subtitle text on the screen ? Absolutely! All you need to do is make a static call to the GTA.UI class. // This is the first override.GTA.UI.ShowSubtitle ("My Text Goes Here");// This is the second override.GTA.UI.ShowSubtitle ("My Text Goes Here", /*duration in milliseconds.*/ 7000);// There are other methods of notification as well.GTA.UI.Notify ("This is a notification!"); Link to comment Share on other sites More sharing options...
ShadowCoderKing Posted May 6, 2017 Author Share Posted May 6, 2017 (edited) thanks so much !! also how do i make multiple IFs if (Entity.Exists(Enemy1) && Enemy1.IsDead && Entity.Exists(Enemy2) && Enemy2.IsDead)//does it work like this to have multiple IFs in the one code, just keep adding && ? Edited May 6, 2017 by SpiderMight Link to comment Share on other sites More sharing options...
sollaholla Posted May 6, 2017 Share Posted May 6, 2017 (edited) if (Entity.Exists(Enemy1) && Enemy1.IsDead && Entity.Exists(Enemy2) && Enemy2.IsDead)//does it work like this to have multiple IFs in the one code, just keep adding && ? Woahhh, you definitely don't want to do that. You're going to need to create a list. Which is WAY more suited to what you want to do. public MyConstructor (){ MyPeds = new List<Ped>(); KeyUp += OnKeyUp; Tick += OnTick;}// At the top of your program make sure to add "using System.Collections.Generic;"public List<Ped> MyPeds { get; }private void OnKeyUp (object sender, KeyEventArgs e){ // This goes down to after you create your ped MyPeds.Add (thePedICreated); // Do other stuff}private void OnTick (object sender, EventArgs e){ // Make sure at the top of your program to add "using System.Linq;" // This is what's called a for loop, you can read more about it here: https://docs.microsoft.com/en-us/dotnet/articles/csharp/language-reference/keywords/for for (int i = 0; i < MyPeds.Count; i++) { // Now we're inside the loop (iterating over each ped in the list. // Let's make sure to grab a ped from the stack. Ped p = MyPeds[i]; if (Entity.Exists (p) && p.IsDead) { p.Delete(); } } // This is a difficult one to explain but we're basically removing any dead peds from the list, // this way our list isn't filled with empty references. // Read more here: https://msdn.microsoft.com/en-us/library/bb549418(v=vs.110).aspx MyPeds = MyPeds.Where (x => Entity.Exists(x) && !x.IsDead).ToList();} Edited May 6, 2017 by sollaholla Link to comment Share on other sites More sharing options...
ShadowCoderKing Posted May 6, 2017 Author Share Posted May 6, 2017 public MyConstructor (){ MyPeds = new List<Ped>(); // MyPeds comes up with an error on this line, its read only KeyUp += OnKeyUp; Tick += OnTick;} Thanks but how to fix MyPeds part ? its got a read only error Link to comment Share on other sites More sharing options...
sollaholla Posted May 6, 2017 Share Posted May 6, 2017 public MyConstructor (){ MyPeds = new List<Ped>(); // MyPeds comes up with an error on this line, its read only KeyUp += OnKeyUp; Tick += OnTick;} Thanks but how to fix MyPeds part ? its got a read only error Ensure that the name of your constructor is the same name as your class. Link to comment Share on other sites More sharing options...
ShadowCoderKing Posted May 7, 2017 Author Share Posted May 7, 2017 (edited) i cant get it to work, it still come up with read only error and whats the code to spawn peds using this list method, can you please fix it up for me thanks using GTA;using GTA.Math;using GTA.Native;using System;using System.Windows.Forms;using System.Collections.Generic;using System.Linq;public class Mission1 : Script{ int EnemyRelationShipGroup = Function.Call<int>(Hash.GET_HASH_KEY, "HATES_PLAYER"); public Mission1() { MyPeds = new List<Ped>(); Tick += OnTick; KeyDown += OnKeyDown; KeyUp += OnKeyUp; } private void OnTick(object sender, EventArgs e) { for (int i = 0; i < MyPeds.Count; i++) { // Now we're inside the loop (iterating over each ped in the list. // Let's make sure to grab a ped from the stack. Ped p = MyPeds[i]; if (Entity.Exists(p) && p.IsDead) { p.Delete(); } } MyPeds = MyPeds.Where(x => Entity.Exists(x) && !x.IsDead).ToList(); } void OnKeyDown(object sender, KeyEventArgs e) { } public List<Ped> MyPeds { get; } void OnKeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.U) { // how do i spawn peds using this list method } }} Edited May 10, 2017 by SpiderMight Link to comment Share on other sites More sharing options...
ShadowCoderKing Posted May 10, 2017 Author Share Posted May 10, 2017 (edited) bump sorry for double post but i need help Edited May 10, 2017 by SpiderMight Link to comment Share on other sites More sharing options...
sollaholla Posted May 10, 2017 Share Posted May 10, 2017 Do it the same way you did it previously, except after you create the ped, just write: MyPeds.Add(thePedYouJustCreated); Link to comment Share on other sites More sharing options...
Lancerator Posted May 10, 2017 Share Posted May 10, 2017 I only have to say that your videos are so f*cking sh*tty. GameHacker666 1 Link to comment Share on other sites More sharing options...
ShadowCoderKing Posted May 10, 2017 Author Share Posted May 10, 2017 (edited) Do it the same way you did it previously, except after you create the ped, just write: MyPeds.Add(thePedYouJustCreated); thanks how do i make the script wait an infinite amount of time ? Script.Wait(infinite); // not working for me Edited May 11, 2017 by SpiderMight Link to comment Share on other sites More sharing options...