SA-MP Forums

Go Back   SA-MP Forums > SA-MP Server > Server Support

Reply
 
Thread Tools Display Modes
Old 23/09/2019, 04:27 PM   #1
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 221
Reputation: 6
Default GM communicate with a NodeJS API

Is that possible to make a function on my gamemode to communicate with NodeJS API?

I start to study NodeJS and think would be amazing to make a web app to have a notification every time a player try to rob your house.
binnyl is offline   Reply With Quote
Old 24/09/2019, 12:30 PM   #2
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 221
Reputation: 6
Default Re: GM communicate with a NodeJS API

bump
binnyl is offline   Reply With Quote
Old 24/09/2019, 03:07 PM   #3
Private200
High-roller
 
Private200's Avatar
 
Join Date: May 2012
Posts: 1,179
Reputation: 211
Default Re: GM communicate with a NodeJS API

Try sending a HTTP post request. From NodeJS, handle the POST request and notify (update) the user.

From NodeJS side, check: https://stackoverflow.com/questions/...-post-requests

From SA:MP side, check HTTP_POST request: https://forum.sa-mp.com/showthread.php?t=169532 (a simple example)
__________________
just a signature
Private200 is offline   Reply With Quote
Old 25/09/2019, 02:39 PM   #4
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 221
Reputation: 6
Default Re: GM communicate with a NodeJS API

is it possible to send a json?

i mean
Code:
  async robhouse(req, res) {
    const { houseid } = req.body;
    console.log("house robbing id: " + houseid);
    return res.json(houseid);
  }
how to send a json with:
{
"houseid": 10
}

here?
Code:
HTTP(playerid, HTTP_POST, "localhost:3333/robhouse", "", "HttpResponse");
binnyl is offline   Reply With Quote
Old 25/09/2019, 03:42 PM   #5
DRIFT_HUNTER
High-roller
 
Join Date: Oct 2009
Posts: 2,071
Reputation: 188
Default Re: GM communicate with a NodeJS API

Well samp has HTTP functions so yes, but there are also json and sockets plugins that you could use for that purpose.
__________________
Looking for someone to start drifting server, drop me a pm if you are interested.


Any PM's that include question about any kind of help will be ignored.
Use appropriate boards for that

Last edited by DRIFT_HUNTER; 26/09/2019 at 03:36 PM.
DRIFT_HUNTER is offline   Reply With Quote
Old 26/09/2019, 11:03 PM   #6
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 221
Reputation: 6
Default Re: GM communicate with a NodeJS API

Quote:
Originally Posted by binnyl View Post
is it possible to send a json?

i mean
Code:
  async robhouse(req, res) {
    const { houseid } = req.body;
    console.log("house robbing id: " + houseid);
    return res.json(houseid);
  }
how to send a json with:
{
"houseid": 10
}

here?
Code:
HTTP(playerid, HTTP_POST, "localhost:3333/robhouse", "", "HttpResponse");
I found nothing about JSON on this forum...
Is anyone know hot to put it to work?
binnyl is offline   Reply With Quote
Old 26/09/2019, 11:55 PM   #7
Eoussama
High-roller
 
Eoussama's Avatar
 
Join Date: Jul 2016
Location: Kingdom of Morocco // Tangier
Posts: 1,071
Reputation: 281
Default Re: GM communicate with a NodeJS API

Quote:
Originally Posted by binnyl View Post
I found nothing about JSON on this forum...
Is anyone know hot to put it to work?
I literally ******d “SAMP JSON
https://forum.sa-mp.com/showthread.php?t=543919
__________________

|===[Web taxi]===|
List of my work
Github
Pastebin

|===[Interesting topics]===|
Semantic Versioning
Eoussama is offline   Reply With Quote
Old 27/09/2019, 01:45 PM   #8
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 221
Reputation: 6
Default Re: GM communicate with a NodeJS API

So there is no official support do json, right?

Plugins got a limit to use, right? I'm already using 6


Anyways i +rep
@Private200 and @Eoussama
ty
binnyl is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] SAMPMailJS [NodeJS] bruxo00 Lançamentos/Releases 62 13/10/2019 12:11 AM
[Include] SAMPMailJS | Send Emails Easily | HTML |Templates | NodeJS bruxo00 Includes 57 09/09/2019 03:57 AM
[Tool/Web/Other] node.ucp - A full-fledged isomorphic UCP [nodejs + reactjs] BroZeus Tools and Files 17 07/04/2018 07:24 PM
communicate from npcmodes? beckzy Help Archive 3 03/05/2010 10:16 PM
Communicate with NPC? Zezombia Help Archive 1 03/09/2009 04:58 AM


All times are GMT. The time now is 08:22 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.