Jump to content

Stopping Cops from targeting a Ped


Darkmyre

Recommended Posts

So I'm trying to work on a Partner plugin, however no matter what I try, I cannot get around one fatal flaw: As soon as the partner ped starts shooting near other cops, they all turn on him en-masse and slaughter him. I've set him to his own RelationshipGroup and obtained the hash for that, and am then trying to set his relations with both the player (to stop him slaughtering the player) and other police - the player relations seem to be working fine, however the cops still hate the poor guy. I've included the relevant code below, in case anyone can shed some light on wtf is going on:

Partner.partner = new Ped("mp_m_freemode_01", Game.LocalPlayer.Character.Position.Around(3f), );
Partner.partner.RelationshipGroup = "PARTNER";
Game.DisplayHelp(Partner.partner.RelationshipGroup.Hash.ToString()); // returns 169451935
NativeFunction.CallByName<uint>("SET_RELATIONSHIP_BETWEEN_GROUPS", 1, 1862763509, 169451935); //player->partner
NativeFunction.CallByName<uint>("SET_RELATIONSHIP_BETWEEN_GROUPS", 1, 169451935, 1862763509); // partner->player
NativeFunction.CallByName<uint>("SET_RELATIONSHIP_BETWEEN_GROUPS", 1, 4208871491, 169451935); //cop->partner
NativeFunction.CallByName<uint>("SET_RELATIONSHIP_BETWEEN_GROUPS", 1, 169451935, 4208871491); // partner->cop
                        
Partner.partner.CanAttackFriendlies = false;
Partner.partner.CanBeTargetted = false;

 

My YouTube Channel: Darkmyre Gaming (Australian LSPDFR patrols, plugins in development, and other games)

My Discord Server | AusGamer Network

 

Please do not PM me for technical support or bug reports, use the appropriate forum or plugin's comments instead.

Link to comment
Share on other sites

Functions.SetPedAsCop(Partner); should do the trick.

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

Link to comment
Share on other sites

There's any reason to why you're using the natives? You can use Game.SetRelationshipBetweenRelationshipGroups(), with this you don't need to know the hash of each group or the index of the relationships types.
Some time ago I also have this relationships problem wth preventing cops from shooting some normal peds, I solved it by using Relationship.Companion, or index 0 if you continue to use the native.

Example:
Game.SetRelationshipBetweenRelationshipGroups("COP", "MYGROUP", Relationship.Companion);

 

You can try what Albo said too, that should work.

Edited by alexguirre
Link to comment
Share on other sites

52 minutes ago, Albo1125 said:

Functions.SetPedAsCop(Partner); should do the trick.

I should've mentioned I did try this, but then LSPDFR likes to take over the Ped (part of the reason I'm using the freemode model instead of a cop model)

42 minutes ago, alexguirre said:

There's any reason to why you're using the natives? You can use Game.SetRelationshipBetweenRelationshipGroups(), with this you don't need to know the hash of each group or the index of the relationships types.
Some time ago I also have this relationships problem wth preventing cops from shooting some normal peds, I solved it by using Relationship.Companion, or index 0 if you continue to use the native.

Example:
Game.SetRelationshipBetweenRelationshipGroups("COP", "MYGROUP", Relationship.Companion);

 

You can try what Albo said too, that should work.

Only reason I used natives was I didn't know there was another way lol For some reason I seem to default to checking natives rather than poking about the Object Browser.

Will give Companion a try and see if that helps, thanks guys :D

Edit: Changing the relation to Companion worked perfectly, thanks again Alex!

Edited by Darkmyre

My YouTube Channel: Darkmyre Gaming (Australian LSPDFR patrols, plugins in development, and other games)

My Discord Server | AusGamer Network

 

Please do not PM me for technical support or bug reports, use the appropriate forum or plugin's comments instead.

Link to comment
Share on other sites

25 minutes ago, Darkmyre said:

I should've mentioned I did try this, but then LSPDFR likes to take over the Ped (part of the reason I'm using the freemode model instead of a cop model)

Only reason I used natives was I didn't know there was another way lol For some reason I seem to default to checking natives rather than poking about the Object Browser.

Will give Companion a try and see if that helps, thanks guys :D

Edit: Changing the relation to Companion worked perfectly, thanks again Alex!

Great!

On a side note, there's a Functions.SetCopAsBusy() that should prevent LSPDFR from taking it over.

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...