Xonotic Forums
How to output (rainbow) colored text? - Printable Version

+- Xonotic Forums (https://forums.xonotic.org)
+-- Forum: Support (https://forums.xonotic.org/forumdisplay.php?fid=3)
+--- Forum: Xonotic - Configuration Tips (https://forums.xonotic.org/forumdisplay.php?fid=19)
+--- Thread: How to output (rainbow) colored text? (/showthread.php?tid=2438)

Pages: 1 2


RE: How to output (rainbow) colored text? - Soelen - 01-12-2012

Ok guys thanks to qbit it was possible to sent request after all so I start scripting today. Guys listen. Rainbow text was yesterday! Xonotic does UTF-8! The possibilites to fuck up character codes, are endless. Here 3 of 4 functions:

[Image: funnyscripting.jpg]

Coloring vertical =D But its limitation is you cant write a long sentence with the last function.

The 4th idea didn't worked. I wanted to connect google translator. Unfortunately turns out since google translator api v2, it aint possible anymore. Google demands money for using it now.

I'm going to release source code as soon as it's cleaned up and secure for using it. Speaking of secure, how do I find out what player ID I have? And how exactly it that work? This needs to be done. As I already mentioned to pink, security has priority.

Also thanks to divVerent for providing example code and senor bougo for showing the right direction, forgot to mention that again.


RE: How to output (rainbow) colored text? - Mr. Bougo - 01-13-2012

The --key 0 probably takes care of sending the key, try to dump the whole $_POST array to a file and see what's in there. But then you probably need some crypto functions to check signatures and whatnot. Maybe div can provide you with this because it's likely non-trivial.


RE: How to output (rainbow) colored text? - Soelen - 01-13-2012

It's an idea to dump all post variables into one file indeed : ) Sadly, it just dumped one array with a string.

I wrote this into the autoexec.cfg:

Code:
alias dobeautifulthings "menu_cmd curl --exec --key 0 http://example.org/misterbeautiful.php dobeautifulthings \"$1\""

I wrote that in my php file:

PHP Code:
ob_start();
var_dump($_REQUEST);
$data ob_get_clean();
$fp fopen("dumpfile.txt""w");
fwrite($fp$data);
fclose($fp); 

I wrote thit in xonotic console:

Code:
dobeautifulthings "testchipmunk"

and I got thut in my dumpfile.txt:

Code:
array(1) {
    ["dobeautifulthings"]=>
    string(8) "testchipmunk"
}

Did I made something wrong? Maybe dumping $_REQUEST wasnt the right thing


RE: How to output (rainbow) colored text? - Mr. Bougo - 01-13-2012

Aw well, better wait for div's answer then. Or read darkplaces' source code.


RE: How to output (rainbow) colored text? - Lento - 01-19-2012

hey!

I have not seen well yet but I found a file written about the key.

qcsrc/menu/gamecommand.qc

Code:
if(argv(0) == "curl")
    {
        float do_exec;
        string do_cvar;
        float key;
        float i, j;
        string url;
        float buf;
        float r;

        do_exec = FALSE;
        do_cvar = string_null;
        key = -1;

        for(i = 1; i+1 < argc; ++i)
        {
            if(argv(i) == "--cvar" && i+2 < argc)
            {
                ++i;
                do_cvar = strzone(argv(i));
                continue;
            }
            if(argv(i) == "--exec")
            {
                do_exec = TRUE;
                continue;
            }
            if(argv(i) == "--key" && i+2 < argc)
            {
                ++i;
                key = stof(argv(i));
                continue;
            }
            break;
        }

※atof() is function that parse a string into a float type.

But idk how to send key ID yet.

Later Smile


RE: How to output (rainbow) colored text? - Spaceman - 01-19-2012

(01-19-2012, 08:48 AM)Lento Wrote: But idk how to send key ID yet.

I assume there is cvar containing your key. If there is a cvar then add it to the alias, replace 0 with the cvar, thus
PHP Code:
alias dobeautifulthings "menu_cmd curl --exec --key cvar_key_name http://example.org/misterbeautiful.php dobeautifulthings \"$1\"" 



RE: How to output (rainbow) colored text? - Mr. Bougo - 01-19-2012

Actually it expects a number. And it might be a key id. 0 should be good for this since it's what div uses on his own script apparently? Better check darkplaces.

EDIT: should have thought of this! It's actually in the headers
Code:
// POST: we sign postdata \0 query string
  ...
strlcpy(handle->sigdata, "X-D0-Blind-ID-Detached-Signature: ", 8192);
  ...
And the signature follows in the header.


RE: How to output (rainbow) colored text? - Soelen - 02-09-2012

Oh Mr.Bougo, I was like thinking weeks long what you ment with your last post. After all I checked my post data.

Yesterday I met Lento once again on his japanese server and I was asking how he actually gets the player ID from div0's script. It appears he did not know either.

So I was going to write a post again asking what you ment Mr.Bougo, but as I was writing, I realized POST data != HEADER data. And... I made some tests today, I think I've got it...

So I var dumped the whole header into a textfile with the apache_request_headers method, I think this method wont on every server

PHP Code:
ob_start();
var_dump(apache_request_headers());
$data ob_get_clean();
$fp fopen("textfile.txt""w");
fwrite($fp$data);
fclose($fp); 


and this is what I got

PHP Code:
array(7) {
  [
"User-Agent"]=>
  
string(46"Xonotic Windows 01:01:16 Sep  6 2011 - release"
  
["Host"]=>
  
string(17"awesome.dyndns.org"
  
["Accept"]=>
  
string(3"*/*"
  
["Referer"]=>
  
string(13"dp://local:1/"
  
["Content-Type"]=>
  
string(33"application/x-www-form-urlencoded"
  
["X-D0-Blind-ID-Detached-Signature"]=>
  
string(700"gQEBAXBKwkXj4V9Umg0R14UxZfD3BwJY/cSGfUVyrueOQveXwBJPGBpWJDxzeqbaUTp90+2PJ6uVN2SvDI5YpYzir/mFsqk3jlzw9ENlsWaNovi4/SJY5IekvzYUteVtsTJBjzzq8v8YfcJQd1gKsLFZbFeAMT/+HWAo48T4blJUIwiBAQGPqnGoD6GhuHLYN+Sf73ROColneBdJ7ttuVwm32FvI8LuD5aLDll7bpqfksuidSkdhGD2CYvkTAYtoz2RZmIGK5ZHHaM/V6vcSXnq2ab/7mFRiag7D5OUsmIFY9E3IqcqtP7+wXSVgiNFY3DBPy27bXjk8ZJ9nUD5dQBL9sG8TzWd4EBAURLGQkwb7Msd7juAc0gDdlEQp2erfNG/dYndu1I+9kl2fuPEzH15FOjze51GHx14kBQ1ZH13ZmdHSr6K+it4onRLbza/cSAIB1ZzeaXorS4WKkpsNj6b+FkXErQWfMRMDbyzlJ7AVEWEArGwTrVrtpttNxofG9i47AudWnx8Wn4gQEBSr4VOr+cdsFIE3aCJ7U0f2E2QNr4V0fnYj4W6W9nT/gGwkBvFqBTwuuaSaTCv0M5eXhLdRJ7onShVA/NLqMLljrjUTaDhnFM9mgVSsHiaFTilXljboxt+4eDoPOt3k8xHDh6vHLcvYrP3vkZlAmn4tXdIS0nAWefGy5Cqc4FnLQ="
  
["Content-Length"]=>
  
string(2"26"


My question is now, is "X-D0-Blind-ID-Detached-Signature" the player ID? =D

ps, I changed some informations, I dont want to post the real player id ^^;


RE: How to output (rainbow) colored text? - Mr. Bougo - 02-09-2012

So, apparently there's an include file for php to check this. You'll find it in xonotic.git/misc/infrastructure/php/ along with an example php file to check sigs. You'll need to test that out and watch your php server log because the server needs to be configured right for it to work. For example the keygen binary which does the checking should be callable by php.

Read the first few lines of the .inc at least, it shows you what variables you need to set to point to the dp0 public key and the keygen binary. The function defined in the .inc does all the checking, no need to pass it headers or anything. It returns a key fingerprint and some information on the key's signature.

I'm not a php wiz so I can't provide help more detailed than that :<


RE: How to output (rainbow) colored text? - Mario - 02-24-2012

[Image: xonotic20120225014647-00.jpg]


RE: How to output (rainbow) colored text? - Mr. Bougo - 02-24-2012

That's not dynamic. Also, you might as well use aliases, that cuts the "execing" messages.


RE: How to output (rainbow) colored text? - Mario - 02-24-2012

Every character/color is set as a cvar, so I can change them easily in-game.
I find it easier to have them separated into configs, rather than a huge autoexec.cfg.

[Image: chat.jpg]


RE: How to output (rainbow) colored text? - Mr. Bougo - 02-24-2012

You can make them aliases and make autoexec.cfg exec the files containing the aliases! That's what I do: I got tons of cfgs doing different special things, I store them in ~/.xonotic/data/cfg/ and exec them from autoexec.cfg.


RE: How to output (rainbow) colored text? - Mario - 02-25-2012

Here's an example of my colour configs:

Code:
set tcolors_0 "^3"
set tcolors_1 "^3"
set tcolors_2 "^4"
set tcolors_3 "^4"
set tcolors_4 ""
set tcolors_5 ""
set tcolors_6 ""
set tcolors_7 ""

Which my code uses to colourise text:

Code:
tcolors[x] = cvar_string(strcat("tcolors_", ftos(x)));



RE: How to output (rainbow) colored text? - Mr. Bougo - 02-25-2012

Oh okay, I misunderstood this. You actually made a menu mod. Alright! If you're looking to shorten it, I guess you could store the colors in a single cvar and tokenize that then. set tcolors "3,3,4,4,,,,"