This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.ts
86 lines (79 loc) · 4.1 KB
/
command.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { int32_t } from "bdsx/nativetype";
import { ActorWildcardCommandSelector, CommandPermissionLevel } from "bdsx/bds/command";
import { events } from "bdsx/event";
import { command } from "bdsx/command";
import { addMoney, getMoney, reduceMoney, sendMessage, setMoney } from "./economy";
events.serverOpen.on(() => {
command.register('atm', 'Check balance.').overload((p, o) => {
var p2 = o.getEntity()
for (var actor of p.plr.newResults(o)) {
if (p2?.isPlayer()) {
if (actor?.isPlayer())
if (actor.getName() == p2.getName()) sendMessage(p2, `Your balance is ${getMoney(p2)}`);
else sendMessage(p2, `${actor.getName()}'s balance is ${getMoney(actor)}`);
}
}
},{
plr: ActorWildcardCommandSelector
});
// I added these because people are requesting it.
command.register('atmadd', 'Add balance.', CommandPermissionLevel.Operator).overload((p, o) => {
var a = o.getEntity();
if (a?.isPlayer()) {
for (var actor of p.plr.newResults(o)) {
if (actor?.isPlayer()) {
addMoney(actor, p.amount);
sendMessage(a, `Sucessfully added ${p.amount} to ${actor.getName()}'s balance.'`);
sendMessage(actor, `You have been added ${p.amount} to your balance.'`);
}
}
}
},{
plr: ActorWildcardCommandSelector,
amount: int32_t
});
command.register('atmset', 'Set balance.', CommandPermissionLevel.Operator).overload((p, o) => {
var a = o.getEntity();
if (a?.isPlayer()) {
for (var actor of p.plr.newResults(o)) {
if (actor?.isPlayer()) {
setMoney(actor, p.amount);
sendMessage(a, `Sucessfully set ${p.amount} to ${actor.getName()}'s balance.'`);
sendMessage(actor, `You have been set ${p.amount} to your balance.'`);
}
}
}
},{
plr: ActorWildcardCommandSelector,
amount: int32_t
});
command.register('atmrm', 'Remove balance.', CommandPermissionLevel.Operator).overload((p, o) => {
var a = o.getEntity();
if (a?.isPlayer()) {
for (var actor of p.plr.newResults(o)) {
if (actor?.isPlayer()) {
reduceMoney(actor, p.amount);
sendMessage(a, `Sucessfully removed ${p.amount} to ${actor.getName()}'s balance.'`);
sendMessage(actor, `You have been removed ${p.amount} in your balance.'`);
}
}
}
},{
plr: ActorWildcardCommandSelector,
amount: int32_t
});
command.register('atmreset', 'Resey balance.', CommandPermissionLevel.Operator).overload((p, o) => {
var a = o.getEntity();
if (a?.isPlayer()) {
for (var actor of p.plr.newResults(o)) {
if (actor?.isPlayer()) {
reduceMoney(actor, 0);
sendMessage(a, `Sucessfully resetted ${actor.getName()}'s balance.'`);
sendMessage(actor, `You have been reset balance.'`);
}
}
}
},{
plr: ActorWildcardCommandSelector
});
});