Jump to content

Best way to implement a distance check before spawning a callout?


Recommended Posts

Hey all, I'm new to all this but thanks to some awesome tutorials I've been picking up the API pretty quickly. That said I still have a lot of questions, my primary one as of right now is, how can I determine whether or not to offer a callout based on the players distance to the spawn point? As of right now I basically just have a group of Vector 3 coordinates labeled location1, location 2, 3 etc... and a quick block of a code that chooses a random location to set as the spawnpoint. Does LSPDFR handle this itself based on the callout distance in the lspdfr.ini? Or is this something I need to do in my plugin on my end? If it is, what's the most efficient/best way to do this? I'm not asking someone to write the code for me line to line, but maybe explain how it works and offer a potential solution. 

 

Essentially I want it to:

Get the distance from the player to the spawnpoint before the callout is offered, then offer the callout if the distance is < x , or clean itself up if the distance > x and never get offered at all.

 

Again really new to this so apologies if this is a nooby question and I explained it poorly. I'll be monitoring this thread but please feel free to add me on discord ILLICIT#8307, I would love to have someone I could bounce random questions off of. I'm not a total beginner, but I am still learning the API. Thanks in advanced, this is my first plugin and it's going way smoother than I expected! Let me know if you need any more info from me and I'll definitely provide. 

Edited by ILLICITnoise
grammar & spelling
Link to comment
Share on other sites

As an update I no longer need help, I figured it out. I'm sure this is not the best or most efficient way to do this, as I'm new to this, but if someone else wants to know here's how I personally did it. 

Quote

 

// seting vars
SpawnPoint = new Vector3(x, y, z);

 

// inside OnBeforeCalloutDisplayed()

// checking players distance to SpawnPoint, and if its less than 200 or more than 1000 aborting
if (SpawnPoint.DistanceTo(Game.LocalPlayer.Character) <= 200f || SpawnPoint.DistanceTo(Game.LocalPlayer.Character) >= 1000f)
{
    // sets a variable in End() that says not to display the code 4 notification/dispatch audio
    silentCleanup = true;
    
    // tells lspdfr to abort the callout
    return false;
}

 

 

 

Edited by ILLICITnoise
Link to comment
Share on other sites

  • 1 year later...

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