Giter Site home page Giter Site logo

node-samp-query's Introduction

node-samp-query

Simplified Query API for SAMP

npm install samp-query

Usage

Available options

  • host
  • port - default: 7777
  • timeout - default: 1000
var query = require('samp-query')

var options = {
	host: '94.23.166.205'
}

query(options, function (error, response) {
	if(error)
		console.log(error)
	else 
		console.log(response)
})

Sample output

{ 
	address: '94.23.166.205',
	hostname: '• German Extreme Freeroam • Stunt/Derby/Race/DM/Free',
	gamemode: 'Stunt Race Derby DM Fun',
	mapname: 'San Andreas',
	passworded: false,
	maxplayers: 500,
	online: 12,
	rules: { 
		lagcomp: true,
		mapname: 'San Andreas',
		version: '0.3z',
		weather: 18,
		weburl: 'www.gef.io',
		worldtime: '12:00'
	},
	players: [
		{ id: 0, name: 'hallihallomine', score: 14735, ping: 51 },
		{ id: 1, name: 'xGreenDayx', score: 26193, ping: 81 },
		{ id: 2, name: '[Black]Rider', score: 87211, ping: 41 },
		{ id: 3, name: 'Kohl', score: 439313, ping: 45 },
		{ id: 5, name: 'TheSituation', score: 14775, ping: 41 },
		{ id: 6, name: 'EziT', score: 38914, ping: 66 },
		{ id: 7, name: 'Josiee', score: 2104, ping: 56 },
		{ id: 8, name: 'Derbystar', score: 29, ping: 56 },
		{ id: 9, name: 'xXProPlayXx', score: 20354, ping: 45 },
		{ id: 10, name: 'hakco30', score: 0, ping: 81 },
		{ id: 11, name: 'xXDarkBolleXx', score: 38886, ping: 56 },
		{ id: 12, name: 'SDMPro', score: 0, ping: 51 }
	]
}

node-samp-query's People

Contributors

christianrank avatar derekmartinez18 avatar jjj4n avatar kaperstone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

node-samp-query's Issues

Please update its format

It is very hard to use asynchronous methods on it
and to use it in an external module
please make it to return all the server data instead of defining a function inside it

Host unavailable

When I run the samp-query code, "Host unavailable" throws me in console on the bot host
Specs:
Host: ClankyHosting
Panel: Pterodactyl
OS: Ubuntu

But when I do it on my (local) console, It works well
OS: Windows
Panel: PowerShell Console

Please help me

Server ping

How about adding server ping to server info array? All we need to do is keep tack of time since we sent request until server responded with data...

Please update

I found a bug that the online player was not detected by the bot alias the result was 0 even though when I checked in the game there were quite a few online players but why did the bot only detect 0 players even though the code, host and port were correct?

Invalid Host

Its showing invalid host for every IP address.

Some bugfixes

Bug 1 - Deprecated query parameter

Query return language as mapname.
Now SAMP don't supports mapname parameter.
I fixed this by replacing mapname to language in your script (wow, incredible).

Bug 2 - Wrong encoding

You can see this problem if server name or other query parameter have cyrillic symbols.
My solution:

const iconv = require('iconv-lite');
var decode = function(buffer) {
    return iconv.decode(buffer, 'win1251');
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.