2020-05-11 17:10:43 -04:00
|
|
|
let commands = [{
|
|
|
|
// required
|
|
|
|
name: "pingpong",
|
|
|
|
// required
|
|
|
|
description: "pongs a ping",
|
|
|
|
// required
|
|
|
|
alias: "pp",
|
|
|
|
// required
|
|
|
|
permission: "User",
|
2020-09-28 21:32:53 -04:00
|
|
|
// optional (defaults to false)
|
|
|
|
targetRequired: false,
|
2020-05-11 17:10:43 -04:00
|
|
|
// optional
|
|
|
|
arguments: [{
|
|
|
|
name: "times to ping",
|
|
|
|
required: true
|
|
|
|
}],
|
|
|
|
// required
|
|
|
|
execute: (gameEvent) => {
|
|
|
|
// parse the first argument (number of times)
|
|
|
|
let times = parseInt(gameEvent.Data);
|
|
|
|
|
|
|
|
// we only want to allow ping pong up to 5 times
|
|
|
|
if (times > 5 || times <= 0) {
|
|
|
|
gameEvent.Origin.Tell("You can only ping pong between 1 and 5 times");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we want to print out a pong message for the number of times they requested
|
|
|
|
for (var i = 0; i < times; i++) {
|
|
|
|
gameEvent.Origin.Tell(`^${i}pong #${i + 1}^7`);
|
|
|
|
|
|
|
|
// don't want to wait if it's the last pong
|
|
|
|
if (i < times - 1) {
|
|
|
|
System.Threading.Tasks.Task.Delay(1000).Wait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
|
|
|
|
let plugin = {
|
|
|
|
author: 'RaidMax',
|
2021-05-14 22:52:55 -04:00
|
|
|
version: 1.1,
|
2020-05-11 17:10:43 -04:00
|
|
|
name: 'Ping Pong Sample Command Plugin',
|
|
|
|
|
|
|
|
onEventAsync: function (gameEvent, server) {
|
|
|
|
},
|
|
|
|
|
|
|
|
onLoadAsync: function (manager) {
|
2020-09-26 19:13:56 -04:00
|
|
|
this.logger = _serviceResolver.ResolveService("ILogger");
|
|
|
|
this.logger.WriteDebug("sample plugin loaded");
|
2021-05-14 22:52:55 -04:00
|
|
|
|
|
|
|
const intArray = [
|
|
|
|
1337,
|
|
|
|
1505,
|
|
|
|
999
|
|
|
|
];
|
|
|
|
|
|
|
|
const stringArray = [
|
|
|
|
"ping",
|
|
|
|
"pong",
|
|
|
|
"hello"
|
|
|
|
];
|
2021-05-15 10:20:49 -04:00
|
|
|
|
|
|
|
this.configHandler = _configHandler;
|
2021-05-14 22:52:55 -04:00
|
|
|
|
2021-05-15 10:20:49 -04:00
|
|
|
this.configHandler.SetValue("SampleIntegerValue", 123);
|
|
|
|
this.configHandler.SetValue("SampleStringValue", this.author);
|
|
|
|
this.configHandler.SetValue("SampleFloatValue", this.version);
|
|
|
|
this.configHandler.SetValue("SampleNumericalArray", intArray);
|
|
|
|
this.configHandler.SetValue("SampleStringArray", stringArray);
|
2021-05-14 22:52:55 -04:00
|
|
|
|
2021-05-15 10:20:49 -04:00
|
|
|
this.logger.WriteDebug(this.configHandler.GetValue("SampleIntegerValue"));
|
|
|
|
this.logger.WriteDebug(this.configHandler.GetValue("SampleStringValue"));
|
|
|
|
this.logger.WriteDebug(this.configHandler.GetValue("SampleFloatValue"));
|
2021-05-14 22:52:55 -04:00
|
|
|
|
2021-05-15 10:20:49 -04:00
|
|
|
this.configHandler.GetValue("SampleNumericalArray").forEach((element) => {
|
2021-05-14 22:52:55 -04:00
|
|
|
this.logger.WriteDebug(element);
|
|
|
|
});
|
|
|
|
|
2021-05-15 10:20:49 -04:00
|
|
|
this.configHandler.GetValue("SampleStringArray").forEach((element) => {
|
2021-05-14 22:52:55 -04:00
|
|
|
this.logger.WriteDebug(element);
|
|
|
|
});
|
2020-05-11 17:10:43 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
onUnloadAsync: function () {
|
|
|
|
},
|
|
|
|
|
|
|
|
onTickAsync: function (server) {
|
|
|
|
}
|
|
|
|
};
|