CR_Jayhawk11 Posted December 22, 2015 Share Posted December 22, 2015 (edited) I am currently new to coding (especially for Grand Theft Auto V) and was searching for some answers to change the clothing of certain pedestrians. I have come across many tutorials, but most are confusing and tend to be unspecific. I vaguely understand how to start the script and set-up the pedestrian variation thanks to this forum topic, however I am looking to change a pedestrian not the player. Please correct me if I am wrong, but this is how that is normally constructed in C#: Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character, 2, 1, 0, 2) It probably is something very simple, but I can not find the correct way to input a normal pedestrian. The model I am specifically referring to, and would like to change, is the s_m_y_marine_03. I have tried using a pedestrian hash along with a long list of other crazy combinations to replace the player portion of this line, but all have been a complete failure. Am I able to switch with a non-playable character, or can I only change the clothing and props of the active player? The reason that I ask is that I am hoping to add to the Bodyguard Squads mod by Eddlm. My dream is that when I spawn a group of a certain pedestrian model from the mod menu, they all have the exact same features. In this instance, I would like each s_m_y_marine_03 to have a regular helmet, rather than some having gas masks while others have both or nothing at all. Can this be accomplished by scripting? Or is there an easier way to accomplish this, like deleting the gas mask texture and drawable mesh portion from a certain file? If so, please let me know. This is the major part of the script I am attempting to make, so any input on correct ways to build this script would be greatly appreciated. Thanks! Edited December 22, 2015 by CR_Jayhawk11 Link to comment Share on other sites More sharing options...
AHK1221 Posted December 22, 2015 Share Posted December 22, 2015 (edited) First off, you first have to create or get an already created ped to do this. If you don't have a ped created, create him using: Ped myPed = World.CreatePed(); Use the needed parameters to create him. If you want to get the closest ped use: Ped myPed = World.GetClosestPed(Game.Player.Character.Position, 30f); To get the targeted ped use: Ped myPed = Game.Player.GetTargetedEntity as Ped; There many other ways too, just search on ScriptHookVDotNet's github page. After you have the ped use this: Function.Call(Hash.SET_PED_COMPONENT_VARIATION, myPed, 2, 1, 0, 2) its good to use all this in a key bind: if(e.KeyCode == Keys.R){ Ped myPed = (your method); if(myPed == null) return; Function.Call(Hash.SET_PED_COMPONENT_VARIATION, myPed, 2, 1, 0, 2); UI.ShowSubtitle("Component's changed!");} Edited December 22, 2015 by AHK1221 Link to comment Share on other sites More sharing options...
ISOFX Posted December 22, 2015 Share Posted December 22, 2015 If you want help on scripting add me on skype. Skype: isofxyt Thanks Link to comment Share on other sites More sharing options...
CR_Jayhawk11 Posted December 22, 2015 Author Share Posted December 22, 2015 First off, you first have to create or get an already created ped to do this. If you don't have a ped created, create him using: Ped myPed = World.CreatePed(); Use the needed parameters to create him. If you want to get the closest ped use: Ped myPed = World.GetClosestPed(Game.Player.Character.Position, 30f); To get the targeted ped use: Ped myPed = Game.Player.GetTargetedEntity as Ped; There many other ways too, just search on ScriptHookVDotNet's github page. After you have the ped use this: Function.Call(Hash.SET_PED_COMPONENT_VARIATION, myPed, 2, 1, 0, 2) its good to use all this in a key bind: if(e.KeyCode == Keys.R){ Ped myPed = (your method); if(myPed == null) return; Function.Call(Hash.SET_PED_COMPONENT_VARIATION, myPed, 2, 1, 0, 2); UI.ShowSubtitle("Component's changed!");} Thanks so much for your reply! This helps me a lot. However, can you set the pedestrian as one specific model and for the components to change for it throughout the entire world? Or do you absolutely have to create one? Link to comment Share on other sites More sharing options...
AHK1221 Posted December 22, 2015 Share Posted December 22, 2015 (edited) First off, you first have to create or get an already created ped to do this. If you don't have a ped created, create him using: Ped myPed = World.CreatePed(); Use the needed parameters to create him. If you want to get the closest ped use: Ped myPed = World.GetClosestPed(Game.Player.Character.Position, 30f); To get the targeted ped use: Ped myPed = Game.Player.GetTargetedEntity as Ped; There many other ways too, just search on ScriptHookVDotNet's github page. After you have the ped use this: Function.Call(Hash.SET_PED_COMPONENT_VARIATION, myPed, 2, 1, 0, 2) its good to use all this in a key bind: if(e.KeyCode == Keys.R){ Ped myPed = (your method); if(myPed == null) return; Function.Call(Hash.SET_PED_COMPONENT_VARIATION, myPed, 2, 1, 0, 2); UI.ShowSubtitle("Component's changed!");} Thanks so much for your reply! This helps me a lot. However, can you set the pedestrian as one specific model and for the components to change for it throughout the entire world? Or do you absolutely have to create one? It could be done, however I haven't tested it so may not work: Ped[] allPeds;Model yourPedModel = new Model("s_m_y_marine_03");public yourClass(){ this.KeyDown += onKeyDown;}private void onKeyDown(object sender, KeyEventArgs e){ if(e.KeyCode == Keys.B) { allPeds = World.GetAllPeds(yourPedModel); if(allPeds == null) return; for(int i = 0;i < allPeds.Length;i++) { Function.Call(Hash.SET_PED_COMPONENT_VARIATION, allPeds[i], 2, 1, 0, 2); } }} if you want this to happen automatically(MAY NOT WORK!!!): Ped[] allPeds;Model yourPedModel = new Model("s_m_y_marine_03");public yourClass(){ this.Tick += onTick;}private void onTick(object sender, EventArgs e){ allPeds = World.GetAllPeds(yourPedModel); if(allPeds == null) return; for(int i = 0;i < allPeds.Length;i++) { Function.Call(Hash.SET_PED_COMPONENT_VARIATION, allPeds[i], 2, 1, 0, 2); }} Edited December 22, 2015 by AHK1221 Link to comment Share on other sites More sharing options...
AHK1221 Posted December 22, 2015 Share Posted December 22, 2015 Also add me on Skype if you want more help: Skype: ahk1224 Link to comment Share on other sites More sharing options...
CR_Jayhawk11 Posted December 22, 2015 Author Share Posted December 22, 2015 It works! Thank you so much! I will definitely keep you in mind for anything else involving scripting. Link to comment Share on other sites More sharing options...
AHK1221 Posted December 22, 2015 Share Posted December 22, 2015 It works! Thank you so much! I will definitely keep you in mind for anything else involving scripting. Glad to help you out. 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