[C#.NET] HOW CAN I SPAWN ADDON PEDS?
-
so i have this code ped = World.CreatePed(hashi, playerPed.GetOffsetInWorldCoords(new Vector3(0, 5, 0))); to spawn a ped as a bodyguard, the variable hashi, is later introduced into the fucntion as a PedHash.xxxxxx but i want to spawn a addonped by its name hashi = "superman" for example, as a string. but World.CreatePed doesnt accepts string variables to spawn addonpeds, how can i do this?
-
should i call native functions?
-
@preto89 simple trainer v5.6 or whatever its called right now allows you to spawn peds by name. Maybe you can look at that trainer to see how the code is executed. Or you could ask sjaak327 for the proper code/strings.
-
@Willief23 already fix it, i was easy after all, just created a bool into my function parameters void spawnPed(PedHash hashi, bool isAddon, string AddonName)
then just create an if statement inside saying that if isAddon==true create a ped with the string AddonName else it would create a ped with PedHash hashi.Actual code for those who want to learn how to spawn Addon and Non-Addon peds EZ in updated code
void spawnPed(PedHash hashi,bool isAddon,string addonName) { if (isAddon == true) { Ped ped = World.CreatePed(addonName, playerPed.GetOffsetInWorldCoords(new Vector3(0, 5, 0))); } else { Ped ped = World.CreatePed(hashi, playerPed.GetOffsetInWorldCoords(new Vector3(0, 5, 0))); } }
//# in OnTickEvent for Controller# //
Tick += (o, e) => { if ((Game.IsControlPressed(2, GTA.Control.Aim))) { */spawning Addon peds/* spawnPed("",true,"superman"); } if ((Game.IsControlPressed(2, GTA.Control.FrontendRb))) { */spawning Non-Addon peds/* spawnPed(PedHash.Marine01SMY, false, "" ); } {
//# in KeyDownEvent for Keyboard# //
KeyDown += (o, e) => { if (e.KeyCode == Keys.Z) { */spawning Addon peds/* spawnPed("",true,"superman"); } if (e.KeyCode == Keys.X) { */spawning Non-Addon peds/* spawnPed(PedHash.Marine01SMY, false, "" ); } {