Unreliable Posted September 7, 2009 Share Posted September 7, 2009 I was wondering how you could make an announcement pop up on the screen, such as /bigtext i am bigtext hear me roar arbitraryprint does that, but it's predefined print and you can't edit it (without editing the cmd itself). Thanks! Link to comment Share on other sites More sharing options...
-=*Raz0r*=- Posted September 7, 2009 Share Posted September 7, 2009 What do you mean you can't edit it? There's no basejka way, unless someone's built it under debug mode. Replicate that command is the easiest thing you can do. Not sure what you're asking, seeing as you're afraid of editing anything.. =\ Link to comment Share on other sites More sharing options...
Unreliable Posted September 7, 2009 Author Share Posted September 7, 2009 Nono, i mean. You can't do /arbitraryprint i will display on the screen because it will still pop up with "Blah blah blah" I wanted to make a command that does that but displays what you type on the screen, and not the same thing whenever you use a command, like this. /bigtext I will be displayed on the big screen "I will be displayed on the big screen" Link to comment Share on other sites More sharing options...
-=*Raz0r*=- Posted September 8, 2009 Share Posted September 8, 2009 First, here's your function you'll want to call void Cmd_announce_f( gentity_t *ent ) { char p[1024];//This buffer will fit ~1024 characters if ( trap_Argc () < 2 ) {//if there are less than 2 args print help (the actual command counts as an arg) trap_SendServerCommand( ent-g_entities, va( "print \"^5Command Usage: ^7announce <message> ^3Prints a message to every client\n\"" ) ); return; //if there are less than 2 args print help (the actual command counts as an arg) } strcpy(p, ConcatArgs(1)); //Grab the second arg and put it in our buffer (the actual command counts as an arg) //TODO: insert line-feed handling stuff here G_LogPrintf( "announce: %s: %s\n", ent->client->pers.netname, p ); //log the action in the server console trap_SendServerCommand( -1, va("cp \"%s\"", p) ); //print it on-screen return; } Then chuck in this code in the ClientCommand function appropriately else if (!Q_stricmp(cmd, "announce")) { Cmd_announce_f(ent); return; } I haven't implemented handling line feeds into that yet, so if you want that you'll have to do it yourself I'm afraid. (A line feed goes to the next line by using '\n') Sorry for not understanding earlier, I hadn't poked around 'arbitraryprint' in a while and thought it automatically did this =P Feel free to use this code. I'm not gonna ask for money Link to comment Share on other sites More sharing options...
Unreliable Posted September 8, 2009 Author Share Posted September 8, 2009 Thank you! And it's ok :3 I could have used a better example than arbitraryprint Link to comment Share on other sites More sharing options...
-=*Raz0r*=- Posted September 13, 2009 Share Posted September 13, 2009 Well okay, I found a way to get line-feeds working =P p = G_NewString(p); //insert line-breaks and stuff G_LogPrintf( "announce: %s: %s\n", ent->client->pers.netname, p ); //log the action in the server console trap_SendServerCommand( -1, va("cp \"%s\"", p) ); //print it on-screen free(p); return; Mind you, I use a custom version of G_NewString which uses 'newb = (char*)malloc(l);' rather than 'newb = (char *) G_Alloc( l );' You must free your memory! otherwise the server will crash after the function is called too many times. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.