Jump to content

Backup spawns every second


John D.

Recommended Posts

Here is the code:

myPed -is suspect 

spawnpoint- suspect's spawn point 

        public override void Process()
        {

            if (Vector3.Distance(Game.LocalPlayer.Character.Position, myPed.Position) < 900.0f)
            {



                Functions.RequestBackup(SpawnPoint, EBackupResponseType.Code3, EBackupUnitType.LocalUnit);
            }
            base.Process();
        }

Is process starts my code every second?

it should call backup (as i think ) 1 time, but it calls it every second.

Link to comment
Share on other sites

  • Management Team

The code behavior is correct. Process is called every tick/frame. You then check if the distance is lower than 900 and if so, request backup. So for every tick/frame where this is true, a new backup request is made.

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

Oh, I thought that only happens if you call base.Process(); at the end, but apparently not. Then what's the reason you usually do that?

18 hours ago, LMS said:

The code behavior is correct. Process is called every tick/frame. You then check if the distance is lower than 900 and if so, request backup. So for every tick/frame where this is true, a new backup request is made.

 

Logging in...

Launching game...

Error launching game: Cannot load while loading. Please log out and retry.

Logging out...

Error logging out. You are not logged in. You need to be logged in to log out. Please log in to log out.

Link to comment
Share on other sites

  • Management Team
2 hours ago, TheUniT said:

Oh, I thought that only happens if you call base.Process(); at the end, but apparently not. Then what's the reason you usually do that?

 

 

Since you are overriding Process the dispatcher will always call your implementation, unless as you said you specify it should call the base's implementation of it. Hence your Process implementation is called every tick and called before the base one. When overriding, you can decide if you want to call the base implementation or not depending on whether you want the functionality the base provides to still work. For a callout, the base call with invoke the state callbacks, if you have any, so you should call it. I try to annotate functions where you want to call base in 9 out of 10 cases with "Call base when overriding" to make that clear.

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

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