Jump to content

GetPersonaForPed doesn't return true for IsCop on dead peds


PNWParksFan

Recommended Posts

It appears that Functions.GetPersonaForPed doesn't return True when a cop ped is dead. Is there any way to tell if a ped was a cop before they died?

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Link to comment
Share on other sites

  • Management Team

Can you confirm it reports true for the cop while he is alive and reports false the second he dies?

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

Link to comment
Share on other sites

16 minutes ago, LMS said:

Can you confirm it reports true for the cop while he is alive and reports false the second he dies?

I'll build a little test case for it to double-check that when I get home tonight to confirm. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Link to comment
Share on other sites

13 hours ago, LMS said:

Can you confirm it reports true for the cop while he is alive and reports false the second he dies?

Alright I've confirmed that it does not report true even when the cop is alive! Perhaps I'm using SetPedAsCop incorrectly? 

Ped cop_ped = new Ped(new Model("s_m_y_cop_01"), Game.LocalPlayer.Character.Position.Around(2f), );
GameFiber.Sleep(1000);
bool is_cop = Functions.GetPersonaForPed(cop_ped).IsCop;
Game.LogTrivial("Ped is cop (before SetPedAsCop): " + is_cop);
Functions.SetPedAsCop(cop_ped);
Game.LogTrivial("Did set ped as cop");
is_cop = Functions.GetPersonaForPed(cop_ped).IsCop;
Game.LogTrivial("Ped is cop (after SetPedAsCop): " + is_cop);

while (cop_ped.IsValid() && cop_ped.IsAlive)
{
GameFiber.Sleep(200);
}

is_cop = Functions.GetPersonaForPed(cop_ped).IsCop;
Game.LogTrivial("Ped is cop (after death): " + is_cop);

This returns FALSE in call cases for IsCop, even after specifically using SetPedAsCop and the LSPDFR cop manager logging that it detected a new cop. Is this a bug with the get persona, or am I doing something wrong? 

Edited by PNWParksFan

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Link to comment
Share on other sites

On a side note, if you need to check if a ped is a cop, just check their relationshipgroup.

if (ped.RelationshipGroup == "COP") //ped is cop

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

  • Management Team

If I'm correct, only when the Persona is created will the IsCop value be set. The Persona is only created once; then stored with each Ped. Assuming nothing else has created the Persona, the Persona will be created on the first GetPersonaForPed call.

Ped cop_ped = new Ped(new Model("s_m_y_cop_01"), Game.LocalPlayer.Character.Position.Around(2f), );
GameFiber.Sleep(1000);
Functions.SetPedAsCop(cop_ped);
Game.LogTrivial("Did set ped as cop");
is_cop = Functions.GetPersonaForPed(cop_ped).IsCop;
Game.LogTrivial("Ped is cop (after SetPedAsCop): " + is_cop);

Would return true, in my thinking. It doesn't look like the setting up of the cop will actually change the IsCop value for an existing persona, perhaps this is something that can be changed in the future. I may be wrong as my experience with the LSPDFR codebase is a bit rusty.

Imitation is the sincerest form of flattery.

Link to comment
Share on other sites

  • Management Team

Yep, Cyan is correct on this one. Note that internally, we mainly use this flag to allow peds that are not cops per relationship group or model to be recognized as cops by LSPDFR. We don't really use it to generally determine if a ped is a cop.

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

Link to comment
Share on other sites

On 4/26/2016 at 4:09 AM, Albo1125 said:

On a side note, if you need to check if a ped is a cop, just check their relationshipgroup.

if (ped.RelationshipGroup == "COP") //ped is cop

Thanks Albo. I've got it working now with this test. 

Is there a way using RPH to figure out the relationship between two peds? I know it can be done circuitously using natives, but I only see an RPH method to create a relationship, and none to figure out what relationship already exists.

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Link to comment
Share on other sites

2 hours ago, ainesophaur said:

Can you elaborate more on what you're looking to accomplish? A simple compare between two peds would just be an equality check

if(pedA.RelationGroup == pedBRelationGroup)

That just tells you if they're in the same relationship group, not what the relationship is between their groups. I'm basically asking if there's a built-in method in RPH to do the equivalent of the native GET_RELATIONSHIP_BETWEEN_PEDS. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Link to comment
Share on other sites

I understand now. There isn't any within Rage, however the native function itself takes the same Peds that you have in Rage and the return type is an int that's described in the native. Is there a reason for not wanting to use the native or were you just hoping the equivalent static method existed in Rage?

Edit: The result of the native can be cast to the relationship enum in Rage

http://docs.ragepluginhook.net/html/FBC57062.htm

Edited by ainesophaur
Link to comment
Share on other sites

2 hours ago, ainesophaur said:

I understand now. There isn't any within Rage, however the native function itself takes the same Peds that you have in Rage and the return type is an int that's described in the native. Is there a reason for not wanting to use the native or were you just hoping the equivalent static method existed in Rage?

Edit: The result of the native can be cast to the relationship enum in Rage

http://docs.ragepluginhook.net/html/FBC57062.htm

Yeah that is what I ended up doing. Just easier to do things in RPH when possible. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

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...