-
Notifications
You must be signed in to change notification settings - Fork 380
/
example-3-hello-ops-only.js
42 lines (33 loc) · 1.23 KB
/
example-3-hello-ops-only.js
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
/*************************************************************************
## Example Plugin #3 - Limiting use of commands to operators only.
A simple minecraft plugin. Commands for operators only.
### Usage:
At the in-game prompt type ...
/jsp op-hello
... and a message `Hello {player-name}` will appear (where {player-name} is
replaced by your own name).
This example demonstrates the basics of adding new functionality
which is usable all players or those with the scriptcraft.proxy
permission. By default, all players are granted this permission. In
this command though, the function checks to see if the player is an
operator and if they aren't will return immediately.
This differs from example 2 in that the function will only print a
message for operators.
command('op-hello', function (parameters, player) {
if ( !isOp(player) ){
echo( player, 'Only operators can do this.');
return;
}
echo( player, 'Hello ' + player.name);
});
***/
command('op-hello', function(parameters, player) {
/*
this is how you limit based on player privileges
*/
if (!isOp(player)) {
echo(player, 'Only operators can do this.');
return;
}
echo(player, 'Hello ' + player.name);
});