So I’ve been experimenting with peds recently but I’ve run into a problem that’s got me stumped. I’m trying to spawn a ped, add it to a group, then make that group hostile to the player ped’s group. The ped is spawning correctly and the group is being created, I checked using DoesGroupExist, but when I try to get the spawned ped to join the group, it doesn’t work and IsPedInGroup returns false. Here’s my code:
public class Main : BaseScript
{
public Main()
{
API.RegisterCommand("spawnzombie", new Action(SpawnZombie), false);
}
private async static void SpawnZombie()
{
Ped player = Game.Player.Character;
API.RequestModel((uint)(PedHash)1684083350);
while (!API.HasModelLoaded((uint)(PedHash)1684083350))
{
Debug.WriteLine("Waiting for model to load...");
await BaseScript.Delay(100);
}
Ped zombie = await World.CreatePed((PedHash)1684083350, player.Position + (player.ForwardVector * 2));
int zombieGroup = API.CreateGroup(0);
API.SetPedAsGroupMember(zombie.Handle, zombieGroup);
Am I missing something here? Any help would be appreciated.