mirror of
https://github.com/maierfelix/POGOserver.git
synced 2026-03-21 17:34:27 -05:00
Update
- Added commands.js to commands like save & spawn. - Added save command (Still need candies, items, avatar & tutorial) - Enabled auto-save (Only save when there is players on). - Changed SAVE_INTERVAL from 6e4 to 1e4 (Saves about every 12-13 second.) - Updated to v 0.5.9
This commit is contained in:
parent
79d0e284ff
commit
45ae047dd2
|
|
@ -20,7 +20,7 @@ export default {
|
|||
// otherwise leave it blank
|
||||
LOCAL_IP: "",
|
||||
GAME_MODE: 0,
|
||||
SAVE_INTERVAL: 6e4,
|
||||
SAVE_INTERVAL: 1e4,
|
||||
// Better dont touch these
|
||||
TICK_INTERVAL: 1,
|
||||
// Timeouts
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "POGOServer",
|
||||
"version": "0.5.8",
|
||||
"version": "0.5.9",
|
||||
"description": "",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
|||
65
src/commands.js
Normal file
65
src/commands.js
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
import print from "./print";
|
||||
import CFG from "../cfg";
|
||||
|
||||
export function saveAllPlayers() {
|
||||
if (this.world.players.length > 0) {
|
||||
for (let player of this.world.players) {
|
||||
this.savePlayer(player);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Player} player
|
||||
*/
|
||||
export function savePlayer(player) {
|
||||
return new Promise((resolve) => {
|
||||
if (player.authenticated) {
|
||||
this.updateUser(player).then(resolve);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Player} player
|
||||
*/
|
||||
export function updateUser(player) {
|
||||
let query = this.getUserQuery("UPDATE", "WHERE email=? LIMIT 1");
|
||||
let data = this.getUserQueryData(player);
|
||||
|
||||
return new Promise((resolve) => {
|
||||
this.world.instance.db.query(query, data, (e, res) => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} obj
|
||||
* @return {Array}
|
||||
*/
|
||||
export function getUserQueryData(obj) {
|
||||
return ([
|
||||
obj.username,
|
||||
obj.email,
|
||||
obj.info._exp,
|
||||
obj.info._level,
|
||||
obj.info.stardust,
|
||||
obj.info.pokecoins,
|
||||
obj.info._team,
|
||||
// position
|
||||
obj.latitude,
|
||||
obj.longitude,
|
||||
obj.altitude,
|
||||
// contact settings
|
||||
0, //obj.contact.sendMarketingEmails,
|
||||
0, //obj.contact.sendPushNotifications,
|
||||
// inventory
|
||||
'{}', //obj.candyBag,
|
||||
'{}', //obj.bag,
|
||||
'{}', //obj.avatar,
|
||||
'{"0":1,"1":1,"3":1,"4":1,"7":1}', //obj.tutorial,
|
||||
// WHERE
|
||||
obj.email
|
||||
]);
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ export function resetTimers() {
|
|||
this.saveTick++;
|
||||
// Save interval
|
||||
if (this.saveTick >= CFG.SAVE_INTERVAL) {
|
||||
//this.saveAllPlayers();
|
||||
this.saveAllPlayers();
|
||||
this.saveTick = 0;
|
||||
}
|
||||
this.spawnTick++;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import CFG from "../cfg";
|
|||
import World from "./models/World";
|
||||
|
||||
import * as _api from "./api";
|
||||
import * as _commands from "./commands";
|
||||
import * as _dump from "./dump";
|
||||
import * as _http from "./http";
|
||||
import * as _setup from "./setup";
|
||||
|
|
@ -192,6 +193,7 @@ export default class GameServer {
|
|||
}
|
||||
|
||||
inherit(GameServer, _api);
|
||||
inherit(GameServer, _commands);
|
||||
inherit(GameServer, _dump);
|
||||
inherit(GameServer, _http);
|
||||
inherit(GameServer, _setup);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user