Variable server
is global well you doesn't need to require it.
All scripts need follow syntax.
The makers of Node OWOP shall not be liable for damages caused by scripts of unknown origin, i.e. not from them.
If you create a nice script I can check it and then approve and add it to trusted scripts.
module.exports = (()=>{
const name = "example" //script name
const version = "1.0.0" //version
const permissions = require("../modules/connection/player/permissions.js")
function install() {
let config = new server.ConfigManager(name, {
hello: "hai"
}).config
server.events.on("join", function(client) {
client.send(config.hello) //this will send to every player which will connect to world
if(client.world == "troll") { //if player is on this world
client.send("troll") //this sends to player message troll
client.setRank(permissions.none) //It will set client rank to none-0
}
if(client.world == "infinite") {
client.setPixelBucket([10000, 0])
}
})
}
return {
install: install,
name: name,
version: version
}
})()
server is global variable so you dont need to require it
It's array with worlds To get one world you need do
let world = server worlds.find(function(world) {
return world.name == "wordName"
})
if you need know more about world go to file worldTemplate.js
It's class which allows you to create config for your script config saves every 1 second
let config = new server.ConfigManager(name, {
hello: "hai"
}).config
console.log(config) //{hello: "hai"}
is server config it will be removed from public
This is server events
- join It emits when an client connects it returns client
- leave It emits when an client leaves returns client
- newWorld It emits when there is no world with an name well it creates new one returns world
- requestChunk It emits when an client requests chunk returns client chunkX chunkY
- protectChunk It emits when an client protects chunk returns client chunkX chunkY newState
- setPixel It emits when an client sets pixel returns client x y color color is array [r, g, b]
- playerUpdate It emits when an client changes tool, changes color or moves returns client x y color tool color is array [r, g, b]
- clearChunk It emits when an client uses eraser tool returns client x y color color is array [r, g, b]
- paste
It emits when an client uses paste tool
returns client x y newData
newData is Uint8Array with
16*16*3
size so to get pixels do
pixels = [];
for(let i = 0; i<16*16*3;) {
pixels.push(newData.slice(i, i+3))
i+=3
}
Client is class of client
server.events.on("join", function(client) {
if(client.world == "none") {
client.setRank(0) //Pixel Bucket and Chat Bukcet is set automatically
}
})
server.events.on("join", function(client) {
if(client.world == "infinity") {
Client.setPixelBucket(1000, 0) //Not recommended
}
})
It teleports client to x and y
server.events.on("command", function(client, command, args) {
if(command == "troll") {
if(client.rank >= 2) { //mod or admin
if(args[0] == "ouf") { //if first arg equals to "ouf"
client.teleport(666666,666666)
}
}
}
})
It returns rank of client
It returns id of client
It returns nick of client
returns x or y position of client
returns client ip
returns client worldName
returns r, g or b color of client
To get more info about Client go to Client.js