Jump to content

API

Work in Progress 1.5.7

IIIaKa
IIIaKa

Posted (edited)

@Razor
 

Hello,

I want to add compatibility with your plugin. However, I encountered the absence of an API and hooks. You only have two hooks: OnRandomRaidStart(string waveType, Vector3 pos) and RandomRaidEventEnd(Vector3 pos). Additionally, there is no information about NPCs, helis, or airdrops.
I kindly ask you to add the following hooks for better convenience for plugins that will be compatible with your plugin:

Interface.Oxide.CallHook("OnRandomRaidRaiderSpawned", location, theNewGuy, true);//line ~1406, true means npc is juggernaut
Interface.Oxide.CallHook("OnRandomRaidRaiderSpawned", location, theNewGuy, false);//line ~1474
Interface.Oxide.CallHook("OnRandomRaidHeliSpawned", location, heli);//line ~4522


It would also be super convenient if you assigned skinID for your NPCs, helis, and airdrops, similar to how nivex does it in Raidable Bases using skinID = 14922524.

theNewGuy.skinID = 123;
heli.skinID = 123;


Also, please add the hook OnRandomRaidOwnersUpdated, which will be called when the list of authorized users changes (OnCupboardAuthorize, OnCupboardDeauthorize, OnCupboardClearList), passing the parameter BuildingPrivlidge or HashSet<PlayerNameID>.

Thank you in advance for your cooperation.

Edited by IIIaKa
IIIaKa

Posted

@Razor
Is it possible to add another object hook, when attempting select players for a raid, to be able to prevent player to be raided?

IIIaKa

Posted (edited)

@Razor 
I suggest replacing the current OnCupboardAuthorize, OnCupboardDeauthorize, OnCupboardClearList hooks with this:

private void OnCupboardAuthorize(BuildingPrivlidge privilege, BasePlayer player)
{
  if (Convert.ToBoolean(RaidableBases?.CallHook("EventTerritory", privilege.transform.position)))
    return;
  
  NextTick(() =>
  {
    if (privilege != null && player != null && privilege.IsAuthed(player))
    {
      if (!pcdData.tcData.ContainsKey(player.userID))
        pcdData.tcData.Add(player.userID, new List<ulong>());
      if (!pcdData.tcData[player.userID].Contains(privilege.net.ID.Value))
      {
        pcdData.tcData[player.userID].Add(privilege.net.ID.Value);
        Interface.Oxide.CallHook("OnRandomRaidCupboardAuthorized", privilege.transform.position, player);
      }
      SaveData();
    }
  });
}

private void OnCupboardDeauthorize(BuildingPrivlidge privilege, BasePlayer player)
{
  var pos = privilege.transform.position;
  var privID = privilege.net.ID.Value;
  NextTick(() =>
  {
    if (player != null && pcdData.tcData.ContainsKey(player.userID) && (privilege == null || !privilege.IsAuthed(player)))
    {
      if (pcdData.tcData[player.userID].Contains(privID))
      {
        pcdData.tcData[player.userID].Remove(privID);
        Interface.Oxide.CallHook("OnRandomRaidCupboardDeauthorized", pos, player);
        SaveData();
      }
    }
  });
}

private void OnCupboardClearList(BuildingPrivlidge privilege, BasePlayer player)
{
  var pos = privilege.transform.position;
  var privID = privilege.net.ID.Value;
  NextTick(() =>
  {
    foreach (var kvp in pcdData.tcData)
    {
      if (kvp.Value.Contains(privID) && !privilege.IsAuthed(kvp.Key))
      {
        kvp.Value.Remove(privID);
        Interface.Oxide.CallHook("OnRandomRaidCupboardCleared", pos, kvp.Key);
      }
    }
    SaveData();
  });
}

 

Edited by IIIaKa
IIIaKa

Posted (edited)

On 6/12/2024 at 1:31 PM, Razor said:

ok

@Razor
Hello, unfortunately, with the update, new hooks were not added.
Also, there is no assignment of a unique skinID for NPCs, helis, and airdrops, which would help easily filter them in the hooks.🙄

Edited by IIIaKa
Razor

Posted

5 hours ago, IIIaKa said:

@Razor
Hello, unfortunately, with the update, new hooks were not added.
Also, there is no assignment of a unique skinID for NPCs, helis, and airdrops, which would help easily filter them in the hooks.🙄

I have not had mutch time but if you would like to make the changes ill upload it.

IIIaKa

Posted

I apologize, I just noticed that the update was only to fix issues following the Rust update.

Razor

Posted

On 7/9/2024 at 2:45 AM, IIIaKa said:

I apologize, I just noticed that the update was only to fix issues following the Rust update.

Added api and skin

IIIaKa

Posted

@Razor 
I wanted to ask if the OnRandomRaidCupboardAuthorized, OnRandomRaidCupboardDeauthorized, and OnRandomRaidCupboardCleared hooks will be added?
Thank you.

Razor

Posted

1 hour ago, IIIaKa said:

@Razor 
I wanted to ask if the OnRandomRaidCupboardAuthorized, OnRandomRaidCupboardDeauthorized, and OnRandomRaidCupboardCleared hooks will be added?
Thank you.

You can use the umod hooks to see when player auths and deauths cant ya?

IIIaKa

Posted (edited)

24 minutes ago, Razor said:

You can use the umod hooks to see when player auths and deauths cant ya?

@Razor
As you wish. However, in your current hooks, there are no checks.
For example, with OnCupboardDeauthorize, any other plugin(for example mine) can cancel this action and the player will remain in the cupboard, but you still remove them from tcData.
The methods I proposed check if the player has been removed from the cupboard before removing them.
The hook call is needed so that other plugins do not perform the same checks, thus reducing operations.

Edited by IIIaKa
Razor

Posted

3 hours ago, IIIaKa said:

@Razor
As you wish. However, in your current hooks, there are no checks.
For example, with OnCupboardDeauthorize, any other plugin(for example mine) can cancel this action and the player will remain in the cupboard, but you still remove them from tcData.
The methods I proposed check if the player has been removed from the cupboard before removing them.
The hook call is needed so that other plugins do not perform the same checks, thus reducing operations.

I see ill add it to next update.

  • Love 1
Razor

Posted

On 7/19/2024 at 6:29 AM, IIIaKa said:

@Razor
As you wish. However, in your current hooks, there are no checks.
For example, with OnCupboardDeauthorize, any other plugin(for example mine) can cancel this action and the player will remain in the cupboard, but you still remove them from tcData.
The methods I proposed check if the player has been removed from the cupboard before removing them.
The hook call is needed so that other plugins do not perform the same checks, thus reducing operations.

With hooks were still needed and where?

IIIaKa

Posted

5 minutes ago, Razor said:

With hooks were still needed and where?

@Razor
Hello! If possible, it would be great to have OnRandomRaidCupboardAuthorized, OnRandomRaidCupboardDeauthorized and OnRandomRaidCupboardCleared hooks.
The names are not crucial, so feel free to change them as you see fit.

Razor

Posted

Changed Status from Pending to Work in Progress

1.4m

Downloads

Total number of downloads.

6.9k

Customers

Total customers served.

102.4k

Files Sold

Total number of files sold.

2m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

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.