Centerprint all


 

Posted by Defcon-X on January 19, 1999 at 06:33:32:

This is some really kinda kewl tute :) If you've always wondered how you can do it here's
the answer:

Add this Function somewhere into your code (I've putted it in g_newutils.c):

/****************************************
Center print all, by Defcon-X (aka Manne)
****************************************/
void bcenterprintf(edict_t *ent, char *text, int shout) //b stands for broad cast (i hope that's the word i mean:)
{
        int i;
        edict_t *e;

        if (shout == true) // should convert text to green :)
        {
           
           while (*text) {
           if ((*text >= 0x1b && *text <= 0x79) || (*text >= 0x0a && *text <= 0x11))
               *text += (char) 0x80;
               text++;
               }
        }

        for (i=0 ; i<maxclients->value ; i++) // add 1 to i until maxcl. value reached
        {
               e = g_edicts + 1 + i; //selects next player
               if(e->inuse && e->client) { // you can add : '!e->bot_client' if you're
                                            //  using this in a bot code

                    if(shout == true)
                       gi.centerprintf(e, "%s:%s", ent->client->pers.netname, text);
                    else
                       gi.centerprintf(e, text); // prints text to the players
               }
        }
}


< Usage : bcenterprintf(ent, "Hey all, what do you think of this?", false); >

but don't forget to add the line:


void bcenterprintf(char *text, int shout);


to '

g_local.h

'

wanna make a say function for this??? ok here we go, open up
g_cmds.c and add the line to the commands:

else if (Q_stricmp (cmd, "shout") == 0)
bcenterprintf(ent, gi.argv(1), true);

<--- --->

now compile it , run it, and let the console down and type :

shout "*grin*"

it should be able to see at all screen like:


[LS]Defcon-X: *grin*

yeah,

I'll update it to messagemode3 so that you can press u in the game and type something in
just like messagemode1 & 2:)
or maybe YOU can do that :) if not i'll do that until tonight :) but i'm at the work right now and my boss.... hua :) cya , ohhh i will have to stop making soooo much smileys