Chatbox

inZ

Well-known member
Joined
Apr 6, 2013
Messages
270
Reaction score
1
Hi , since it's help section does anybody know how to link the website's chatbox with an application that works even while you're ingame
Like old ugbase chat
 

T3KTONIT

Well-known member
Joined
Sep 2, 2013
Messages
308
Reaction score
5
do you know what socket programming is...?
make a socket wrapper and use it to connect to ugbase.eu:80

step 1:send http POST packets(to /NChat/index.php) with the proper information to login and get the cookie
step 2:send http POST packets(to /NChat/index.php) with the cookie and with correct data to send chat messages.
step 3:send http POST packet(to /NChat/index.php) (data: nchat=read)
step 4: parse the results into your application(console, windows app, directx app,java.whatever). done.


translate this javascript code to the programming language you're using:

PHP:
function nchat_sender() // javascript code for building packet for chat messages.
 {
  var d=new Date();
  if(nchatInput.value.length > 0)
  {
   if((d.getTime() - last_chat) >= limit_time*1000){
    var formatString = "";
    if(format_bold) formatString += "&&bold=true";
    if(format_underline) formatString += "&&underline=true";
    if(format_italic) formatString += "&&italic=true";
    formatString += "&&color=" + document.getElementById("nchat_color").value;
    sender = nchat_ajax("nchat=write&&nchat_mess=" + nchat_replace(nchatInput.value) + formatString, true);
    clearTimeout(reload);
    nchat_reload();
    nchatInput.value = "";
    last_chat = d.getTime();
   }else{
    alert("Slow down! You type so fast!!");
   }
  }else{
   alert("Empty message!");
  }
 }
PHP:
function nchat_parser(nchat) // use these functions for parsing chat messages.
 {
  var nchat_content = "";
  var nchat_regex;
  if(typeof nchat[0] !== "undefined" && nchat[0] !== null)
  {
   for(i=0;i<nchat.length;i++){
    nchat_small_mess = nchat[i].split("|!|");
    nchat_content += "<span style=\"font-size:70%;\">[" + nchat_small_mess[4] + "]</span>";
    
    
    
    if(nchat_small_mess[1] != "-")
    {
  nchat_content +=  " <a href=\"http://ugbase.eu/index.php?action=profile;u=" + nchat_small_mess[2] + "\" style=\"color:" + nchat_small_mess[1] + ";\">" + nchat_small_mess[3] + "</a>:";
    }else{
     nchat_content +=  " <a href=\"http://ugbase.eu/index.php?action=profile;u=" + nchat_small_mess[2] + "\">" + nchat_small_mess[3] + "</a>:";
    }
    
  nchat_small_mess[5] = nchat_small_mess[5]
    
    for(j=0;j<nchat_smiles_list.length;j++)
    {
     nchat_regex = new RegExp(nchat_smiles_list[j][0], "gi");
     nchat_small_mess[5] = nchat_small_mess[5].replace(nchat_regex, "<img src='" + nchat_smiles_list[j][1] + "' />");
    }
    nchat_content +=  "<span style=\"color:" + nchat_small_mess[0] + ";\">" + nchat_small_mess[5] + "</span>
";
   }
  }
  nchatOutput.innerHTML = nchat_content;
 }
 function nchat_replace(str)
 {
  str = str.replace(/\+/g, "%2B").replace(/\&/g, "%26").replace(/\#/g, "%23");
  
  return str;
 }
 function nchat_format(what)
 {
  if(document.getElementById(what).innerHTML.length > 1) {
   document.getElementById(what).innerHTML = document.getElementById(what).innerHTML[0];
   if(what == "bold"){
    nchatInput.style.fontWeight = "normal";
    format_bold = false;
   }
   if(what == "italic"){
    nchatInput.style.fontStyle = "normal";
    format_italic = false;
   }
   if(what == "underline"){
    nchatInput.style.textDecoration = "none";
    format_underline = false;
   }
  }else{
   document.getElementById(what).innerHTML += "*";
   if(what == "bold"){
    nchatInput.style.fontWeight = "bold";
    format_bold = true;
   }
   if(what == "italic"){
    nchatInput.style.fontStyle = "italic";
    format_italic = true;
   }
   if(what == "underline"){
    nchatInput.style.textDecoration = "underline";
    format_underline = true;
  }
 }
  nchatInput.focus();
 }

you can hook this with s0beit, use d3d functions to display text and stuff..
 

inZ

Well-known member
Joined
Apr 6, 2013
Messages
270
Reaction score
1
Thanks dude you're resourceful check your PMs
 

0x_

Wtf I'm not new....
Administrator
Joined
Feb 18, 2013
Messages
1,120
Reaction score
170
[member=5679]T3K[/member]:
That hacky way is not needed and will probably get banned since we have a "light" version of the Readers and writers exactly for this purpose.

He even got a PM Response with the informations...

Code:
http://ugbase.eu/NChat/read.php - HTML
http://ugbase.eu/NChat/readop.php - Gametext

http://ugbase.eu/NChat/write.php
GET Request (Params:)
n(string) = username
p(string) = hashed password
m(string) = message

/E: Also you only need to use one POST on the main page /index /login since it uses a unified system for authentication.
 

T3KTONIT

Well-known member
Joined
Sep 2, 2013
Messages
308
Reaction score
5
0x688 link said:
[member=5679]T3K[/member]:
That hacky way is not needed and will probably get banned since we have a "light" version of the Readers and writers exactly for this purpose.

He even got a PM Response with the informations...

Code:
http://ugbase.eu/NChat/read.php - HTML
http://ugbase.eu/NChat/readop.php - Gametext

http://ugbase.eu/NChat/write.php
GET Request (Params:)
n(string) = username
p(string) = hashed password
m(string) = message

/E: Also you only need to use one POST on the main page /index /login since it uses a unified system for authentication.

lol thanks, i didn't know that this existed, cuz, i'm just reading headers (using LIVE HTTP Header addon for firefox) and implementing them  :urtheman:
 
Top