Jump to content
×
×
  • Create New...

Make your callout Onesync supported!


Recommended Posts

It isn't pretty but it works. 

Ignore all the locations that is because I made this a county based callout

Important note:
Make sure to leave InitBlip() under Task OnAccept()


The idea behind this, knowing that onesync essentially divides the server into little mini servers based on the location of players I figured that the old method of making callouts by having the PED's spawn OnAccept would just then have OneSync despawn them. Well we have the OnStart as well, so I figured why not have the PED's spawn when the player gets close enough for the callout to start?

I have not tested how far out this works, this is a limit but I'm not sure

Literally had the idea threw it into my callout then tested it and wanted to get the information out there for the more experienced Developers to run with!

 

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CitizenFX.Core;
using FivePD.API;
using FivePD.API.Utils;

namespace FivePD_Callouts
{

    [CalloutProperties(name: "Domestic Disusturbance", author: "Fastlane Studios", version: "1.0")]
    public class domesticdisturbance : Callout
    {
        private readonly Random rnd = new Random();
        private Ped suspect, victim;

        public domesticdisturbance()
        {
            Random random = new Random();
            int x = random.Next(1, 100 + 1);
            if (x <= 9)
            {
                InitInfo(new Vector3(1418.92f, 3675.69f, 33.99f));
            }
            else if (x >= 10 && x <= 19)
            {
                InitInfo(new Vector3(1711.01f, 4678.28f, 42.97f));
            }
            else if (x >= 20 && x <= 29)
            {
                InitInfo(new Vector3(2382.88f, 3308.13f, 47.62f));
            }
            else if (x >= 30 && x <= 39)
            {
                InitInfo(new Vector3(471.07f, 2614.76f, 43.34f));
            }
            else if (x >= 40 && x <= 49)
            {
                InitInfo(new Vector3(1933.02f, 3883.36f, 32.41f));
            }
            else if (x >= 50 && x <= 59)
            {
                InitInfo(new Vector3(-3218.89f, 1102.99f, 10.44f));
            }
            else if (x >= 60 && x <= 69)
            {
                InitInfo(new Vector3(3321.2f, 5173.45f, 18.42f));
            }
            else if (x >= 70 && x <= 79)
            {
                InitInfo(new Vector3(2712.91f, 4147.31f, 43.81f));
            }
            else if (x >= 80 && x <= 89)
            {
                InitInfo(new Vector3(783.81f, 2191.13f, 51.92f));
            }
            else if (x >= 90)
            {
                InitInfo(new Vector3(53.23f, 3707.98f, 39.75f));
            }

            ShortName = "Domestic Disturbance";
            CalloutDescription = "Reports of a domestic disturbance, suspect may be armed";
            ResponseCode = 3;
            StartDistance = 50f;
        }

        public override async Task OnAccept()
        {
            InitBlip();
            UpdateData();
        }

        public async override void OnStart(Ped player)
        {
            base.OnStart(player);
            suspect = await SpawnPed(RandomUtils.GetRandomPed(), Location);
            victim = await SpawnPed(RandomUtils.GetRandomPed(), Location);
            suspect.AlwaysKeepTask = true;
            victim.AlwaysKeepTask = true;
            suspect.BlockPermanentEvents = true;
            victim.BlockPermanentEvents = true;
            suspect.Weapons.Give(getRandomWeapon(), 1, true, true);
            suspect.Task.FightAgainst(victim);
            victim.Task.ReactAndFlee(suspect);
            suspect.AttachBlip();
            victim.AttachBlip();

        }

        private WeaponHash getRandomWeapon()
        {
            List<WeaponHash> weapons = new List<WeaponHash>
            {
                WeaponHash.Bat,
                WeaponHash.Bottle,
                WeaponHash.Crowbar,
                WeaponHash.Hammer,
                WeaponHash.Knife,
                WeaponHash.Unarmed
            };
            return weapons[rnd.Next(weapons.Count)];
        }
    }
}

 

  • Like 5
Link to post
Share on other sites
6 hours ago, Grimace said:

This seems to be generic enough that maybe it could be put directly into the FivePD files instead of each callout as well

That would require an entire rework of how FivePD works. This post was designed for the Callout Developers in the community to update their callouts

Link to post
Share on other sites

Content_moved.png

This content has been moved to the correct section by the Management Team. Next time please post in the correct section.

If you feel this was a mistake, please report this reply with a valid reason.

  • Like 1

NorthCam18

Arguably the best VIP member here

 

GitHub Account

Link to post
Share on other sites
  • 3 months 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.   Restore formatting

  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.

  • Recently Browsing   0 members

    No registered users viewing this page.

Important Information

Please view the site: Terms of Use, Privacy Policy, and Guidelines. // IMPORTANT: We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.