![]() |
#1 |
Huge Clucker
![]() ![]() ![]() Join Date: Aug 2017
Posts: 221
Reputation: 6
|
![]()
Como enviar um JSON
Code:
{ "houseid": 10 } Code:
async robhouse(req, res) { const { houseid } = req.body; console.log("house robbing id: " + houseid); return res.json(houseid); } Code:
HTTP(playerid, HTTP_POST, "localhost:3333/robhouse", "", "HttpResponse"); |
![]() |
![]() |
![]() |
#2 |
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Feb 2013
Location: Ilhéus, BA
Posts: 4,394
Reputation: 325
|
![]()
Você quer getar as informações da página?
|
![]() |
![]() |
![]() |
#3 | |
Big Clucker
![]() ![]() Join Date: Feb 2016
Posts: 104
Reputation: 38
|
![]() Quote:
Code:
HTTP(playerid, HTTP_POST, "localhost:3333/robhouse", "{\"houseid\": 123}", "HttpResponse"); print os dados recebidos, veja como é recebido e iniciae o parse.. seguindo o raciocinio, postear |
|
![]() |
![]() |
![]() |
#4 |
Little Clucker
![]() Join Date: Jul 2019
Location: /bin/
Posts: 5
Reputation: 4
|
![]()
Melhor alternativa é usar o plugin do Southclaws.
O uso do mesmo é bem simples. https://github.com/Southclaws/pawn-requests |
![]() |
![]() |
![]() |
#5 | |
Huge Clucker
![]() ![]() ![]() Join Date: Aug 2017
Posts: 221
Reputation: 6
|
![]() Quote:
Code:
async robbizz(req, res) { const { bizzid } = req.body; console.log("bizz robbing id: " + bizzid); return res.json(bizzid); } Code:
// api format(string, sizeof(string), "{\"bizzid\": %i}", bizzid); HTTP(i, HTTP_POST, "localhost:3333/robbizz", string, "HttpResponse"); Code:
public HttpResponse(index, response_code, data[]) { // In this callback "index" would normally be called "playerid" ( if you didn't get it already :) ) new buffer[128]; if(response_code == 200) //Did the request succeed? { //Yes! format(buffer, sizeof(buffer), "The URL replied: %s", data); SendClientMessage(index, 0xFFFFFFFF, buffer); } else { //No! format(buffer, sizeof(buffer), "The request failed! The response code was: %d", response_code); SendClientMessage(index, 0xFFFFFFFF, buffer); } } The request failed! The response code was: 6 |
|
![]() |
![]() |
![]() |
#6 | |
Huge Clucker
![]() ![]() ![]() Join Date: Aug 2017
Posts: 221
Reputation: 6
|
![]() Quote:
sampctl package install Southclaws/pawn-requests samp não tem um limite de plugins? já to usando 6... não tem suporte oficial pra json? |
|
![]() |
![]() |
![]() |
#7 | |
Big Clucker
![]() ![]() Join Date: Feb 2016
Posts: 104
Reputation: 38
|
![]() Quote:
de uma olhada sobre requisicoes do tipo post: https://developer.mozilla.org/pt-BR/...P/Methods/POST veja sobre http codes: https://developer.mozilla.org/pt-BR/...eb/HTTP/Status (este é o codigo que voce ira receber em response_code, na callback HttpResponse) |
|
![]() |
![]() |
![]() |
#8 | |
Huge Clucker
![]() ![]() ![]() Join Date: Aug 2017
Posts: 221
Reputation: 6
|
![]() Quote:
https://ibb.co/ygSQWP0 Mandando o JSON pelo insomnia Só da erro (The request failed! The response code was: 6) quando eu tento mandar pelo pawn Code:
// api format(string, sizeof(string), "{\"bizzid\": %i}", bizzid); HTTP(i, HTTP_POST, "localhost:3333/robbizz", string, "HttpResponse"); |
|
![]() |
![]() |
![]() |
#9 | |
Little Clucker
![]() Join Date: Jul 2019
Location: /bin/
Posts: 5
Reputation: 4
|
![]() Quote:
Seu script e a requisição aparenta está certo. Tenta verificar as configurações do seu firewall, proxy, anti-vírus, etc. Se você for usuário de Windows e usar esses anti-vius ai da vida, verifica as permissões da web. Abrss... |
|
![]() |
![]() |
![]() |
#10 | |
Banned
![]() Join Date: Mar 2013
Location: Rio de Janeiro
Posts: 4,054
Reputation: 784
|
![]() Quote:
Sampctl é um gerenciador de pacotes (plugins) feito para o SAMP, como se fosse um npm/yarn. O HTTP padrão do SAMP não usa content type json em seus headers internos. SAMP não tem suporte oficial a JSON, então já que na sua API você trafega JSON recomendo que instale o sampctl e se aprofunde no plug-in do southclaw, é a melhor opção. |
|
![]() |
![]() |
![]() |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Node/Pathfinding Calculator | jeffery30162 | Scripting Help | 4 | 04/04/2016 03:16 PM |
Help FCNPC NODE POINT | DarkZeroX | Scripting Help | 2 | 28/06/2014 07:04 PM |
FCNPC Node Help | Weponz | Scripting Help | 0 | 11/06/2014 01:50 PM |
GTA SA Pedestrian Node Help | reiss82 | Scripting Help | 1 | 06/09/2012 07:20 PM |
Destroy Object Node GPS? | Admigo | Scripting Help | 0 | 09/05/2012 07:49 PM |