Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Releases Libraries [Library] samp-server-info-obtainer

 
  • 0 Vote(s) - 0 Average
Library samp-server-info-obtainer
KyroKun
Offline

Burgershot Member
Posts: 9
Threads: 1
Joined: Apr 2019
Reputation: 0
Location: Italy
#1
2021-03-07, 11:32 PM (This post was last modified: 2021-05-05, 01:52 PM by KyroKun.)
https://github.com/kyro95/samp-server-info-obtainer
🗺️ samp-server-obtainer — A simple library made in typescript for obtaining your samp server info

Example:
Code:
import sampServer from "./path";

async function doTest() {
    const test = await sampServer.retriveInfo({
        ip: "",
        port: 7777
    }, "i");
    
    console.log(test);
}

doTest();

// Prints out an object which contains the samp server info submitted.
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#2
2021-03-14, 02:12 AM (This post was last modified: 2021-03-14, 02:15 AM by Y_Less.)
That's a nice idea. However, why are you passing an async callback, which isn't used in an async context, and passed to `then`? Why not just return the Promise directly and make `connect` `async`?

Edit: In fact the whole code is a strange mix of async, promises, and callbacks. Just stick with one model.
KyroKun
Offline

Burgershot Member
Posts: 9
Threads: 1
Joined: Apr 2019
Reputation: 0
Location: Italy
#3
2021-03-27, 09:30 PM (This post was last modified: 2021-03-27, 09:40 PM by KyroKun.)
I made this library in just one day, thanks for the suggestions they will be fixed on the next update.

EDIT: sampServer.getInfo has to be await because sometimes 
Code:
this.socket.on('message')
response gets called before the query reaches the samp server, since sockets events aren't async i had to make a promise,
regarding sampServer.connect you're totally right 
KyroKun
Offline

Burgershot Member
Posts: 9
Threads: 1
Joined: Apr 2019
Reputation: 0
Location: Italy
#4
2021-05-05, 01:51 PM
https://github.com/kyro95/samp-server-info-obtainer/blob/1.1.0/src/samp-server-info-obtainer.ts

connection -> instance update has been released
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode