2022-06-22 14:18:20 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using RageCoop.Core.Scripting;
|
|
|
|
|
|
|
|
|
|
namespace RageCoop.Server.Scripting
|
|
|
|
|
{
|
|
|
|
|
internal class BaseScript:ServerScript
|
|
|
|
|
{
|
|
|
|
|
public override void OnStart()
|
|
|
|
|
{
|
2022-06-23 09:46:38 +08:00
|
|
|
|
API.RegisterCustomEventHandler(CustomEvents.NativeResponse, NativeResponse);
|
2022-06-22 14:18:20 +08:00
|
|
|
|
}
|
|
|
|
|
public override void OnStop()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
public void SetAutoRespawn(Client c,bool toggle)
|
|
|
|
|
{
|
|
|
|
|
c.SendCustomEvent(CustomEvents.SetAutoRespawn, new() { toggle });
|
|
|
|
|
}
|
2022-06-23 09:46:38 +08:00
|
|
|
|
void NativeResponse(CustomEventReceivedArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int id = (int)e.Args[0];
|
|
|
|
|
Action<object> callback;
|
|
|
|
|
lock (e.Sender.Callbacks)
|
|
|
|
|
{
|
|
|
|
|
if (e.Sender.Callbacks.TryGetValue(id, out callback))
|
|
|
|
|
{
|
|
|
|
|
callback(e.Args[1]);
|
|
|
|
|
e.Sender.Callbacks.Remove(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2022-07-01 13:54:18 +08:00
|
|
|
|
API.Logger.Error("Failed to parse NativeResponse");
|
|
|
|
|
API.Logger.Error(ex);
|
2022-06-23 09:46:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-22 14:18:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|