Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

84
Views
Se llama a la función externa antes de que se realice xmlhttprequest

room.onPlayerChat es un evento externo que no tengo control sobre él. Cuando trato de usarlo, necesito procesar algo en el mensaje y verificar el rol del jugador a través de xmlhttprequest y esperar la respuesta, luego enviar el mensaje al chat de la sala, pero no espera. it(xmlhttprequest) para devolver el rol del jugador y enviar el mensaje normal (rol del jugador normal), cómo colgar ese evento externo (room.onPlayerChat) y es necesario para manejar cualquier fuente de chat de la sala.

 const makeRequest = (method, url, data = {}) => { const xhr = new XMLHttpRequest(); return new Promise(resolve => { xhr.open(method, url, true); xhr.onload = () => resolve({ status: xhr.status, response: xhr.responseText }); xhr.onerror = () => resolve({ status: xhr.status, response: xhr.responseText }); if (method != 'GET') xhr.setRequestHeader('Content-Type', 'application/json'); data != {} ? xhr.send(JSON.stringify(data)) : xhr.send(); }) } room.onPlayerChat = async function (player,message) { let request = await makeRequest("GET", 'URL/TO/CHECK/PLAYER/ADMIN/ROLE' + player.name); if (request.response == "YES") { room.sendmessage("ADMIN" + player.name + message); return false; } }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!