Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Copyright (C) 2017 VerHext <support@allesverhext.de>
- This work is licensed under the Creative Commons
- Attribution-NonCommercial-ShareAlike 4.0
- International License. To view a copy of this license,
- visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
- */
- registerPlugin({
- name: 'PUBGstats (HazeProduktion)',
- version: '0.1',
- description: 'PUBGstats - Description and Information',
- author: 'VerHext <support@allesverhext.de>',
- engines: '>= 0.9.16',
- vars: [{
- name: 'puURL',
- title: 'The URL to the API on your Server with the port.',
- placeholder: 'https://allesverhext:9999',
- type: 'string'
- },{
- name: 'puSetCommand',
- title: 'Define the Command to set the Stats via Description.',
- placeholder: '!set <nickname>',
- indent: 2,
- type: 'string'
- },{
- },{
- name: 'puPokeMessage',
- title: 'Define the Poke message for Invalid TeamSpeak nickname [Variable &u - Username]',
- placeholder: 'Hey [b]&u[/b], i can´t locate your ingame name on teamspeak. :( Please use [b]<playername> | <real name>[/b] as teamspeak name format and reconnect.',
- indent: 2,
- type: 'string'
- },{
- name: "infoVasSolo",
- title: 'You can use lots of Varable for your Client Description [SOLO]',
- indent: 2,
- type: 'array',
- vars: [{
- title: "&sRating = Rating (int)",
- },{
- title: "&sWinPoints = WinPoints (int)",
- },{
- title: "&sKillPoints = KillPoints(int)",
- }],
- },{
- name: 'puDescription',
- title: 'Define the Command to set the Stats via Description.',
- placeholder: '!set <nickname>',
- indent: 2,
- type: 'string'
- }],
- }, function(sinusbot, config, info) {
- // NOTE: Require module variables
- var event = require('event');
- var engine = require('engine');
- var backend = require('backend');
- var url = config.puURL;
- event.on('clientMove', function(ev) {
- if (ev.fromChannel == null && ev.toChannel.isDefault() ) {
- setTimeout(function(){
- getAccountIdByNickname(ev.client.name());
- ev.client.setDescription('OK');
- },500);
- }
- });
- event.on('chat', function(ev) {
- ev.client.setDescription("Text: " + ev.text)
- });
- function getAccountIdByNickname(nickname){
- engine.log("Nickname: " + nickname)
- sinusbot.http({
- 'method': 'POST',
- 'url': url + '/getAccountIdByNickname',
- 'timeout': 6000,
- 'maxSize': 1024 * 1024 * 5,
- 'body': '{"nickname": "'+nickname+'"}',
- 'headers': {
- 'Content-Type': 'application/json'
- }
- }, function(error, response) {
- var res = JSON.parse(response.data);
- if (response.statusCode != 200) {
- engine.log(error);
- return;
- }
- try {
- } catch (err) {
- engine.log(err.message);
- }
- if (res === undefined) {
- engine.log("Error in JSON!");
- return;
- }
- if (res.success){
- setDescription(res.userData.AccountId, nickname);
- engien.log('PUBG: Stats are setting to ' + nickname + ' description!')
- }else{
- backend.getClientByNick(nickname).poke(config.puPokeMessage).replace('&u', nickname)
- engine.log('PUBG: User ' + nickname + " has not an Gameaccount or User unkomw." )
- }
- });
- }
- function setDescription( accountId, nickname){
- //Failed to set the Description...
- backend.getClientByNick(nickname).setDescription("Test you are welcome");
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement