void UTIL_HostSay( edict_t *pEntity, char *message ) { int j; char text[128]; char *pc; edict_t *client; // make sure the text has content for ( pc = message; pc != NULL && *pc != 0; pc++ ) { if ( isprint( *pc ) && !isspace( *pc ) ) { pc = NULL; // we've found an alphanumeric character, so text is valid break; } } if ( pc != NULL ) return; // no character found, so say nothing // turn on color set 2 (color on, no sound) sprintf( text, "%c%s: ", 2, STRING( pEntity->v.netname ) ); j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator if ( (int)strlen(message) > j ) message[j] = 0; strcat( text, message ); strcat( text, "\n" ); // loop through all players // Start with the first player. // This may return the world in single player if the client types something between levels or during spawn // so check it, or it will infinite loop if (gmsgSayText == 0) gmsgSayText = REG_USER_MSG( "SayText", -1 ); client = NULL; while ( ((client = UTIL_FindEntityByClassname( client, "player" )) != NULL) && (!FNullEnt(client)) ) { if ( client == pEntity ) // skip sender of message continue; MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, gmsgSayText, NULL, client ); WRITE_BYTE( ENTINDEX(pEntity) ); WRITE_STRING( text ); MESSAGE_END(); } // print to the sending client MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, gmsgSayText, NULL, pEntity ); WRITE_BYTE( ENTINDEX(pEntity) ); WRITE_STRING( text ); MESSAGE_END(); }
/* <2d3d0b> ../game_shared/voice_gamemgr.cpp:101 */ bool CVoiceGameMgr::Init(IVoiceGameMgrHelper *pHelper, int maxClients) { m_pHelper = pHelper; m_nMaxPlayers = (maxClients > VOICE_MAX_PLAYERS) ? VOICE_MAX_PLAYERS : maxClients; PRECACHE_MODEL("sprites/voiceicon.spr"); m_msgPlayerVoiceMask = REG_USER_MSG("VoiceMask", VOICE_MAX_PLAYERS_DW * 4 * 2); m_msgRequestState = REG_USER_MSG("ReqState", 0); // register voice_serverdebug if it hasn't been registered already if (!CVAR_GET_POINTER("voice_serverdebug")) CVAR_REGISTER(&voice_serverdebug); if (!CVAR_GET_POINTER("sv_alltalk")) CVAR_REGISTER(&sv_alltalk); return true; }
void UTIL_SayText( const char *pText, edict_t *pEdict ) { if (gmsgSayText == 0) gmsgSayText = REG_USER_MSG( "SayText", -1 ); MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, gmsgSayText, NULL, pEdict ); WRITE_BYTE( ENTINDEX(pEdict) ); WRITE_STRING( pText ); MESSAGE_END(); }
void ClientPrint( edict_t *pEntity, int msg_dest, const char *msg_name) { if (gmsgTextMsg == 0) gmsgTextMsg = REG_USER_MSG( "TextMsg", -1 ); MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, gmsgTextMsg, NULL, pEntity ); WRITE_BYTE( msg_dest ); WRITE_STRING( msg_name ); MESSAGE_END(); }
void RadioShowMenu( edict_t *pEntity, edict_t *pRadio, int n ) { // Cant use radio in spec mode if (pEntity->v.iuser1 > 0) return; // dont use if radio is tuning if (pRadio->v.iuser1 == 1) return; char menutext[1024]; int bitsel = 0; if (n < 3) { sprintf(menutext, "Switch to song:\n\n"); if (n == 1) { strcat(menutext, "1. Take my Breath Away\n"); strcat(menutext, "2. Dreamgate - Now we are free\n"); strcat(menutext, "3. Hamsterdance\n"); strcat(menutext, "4. Muse - Plug In Baby\n"); strcat(menutext, "5. Scooter - Ramp [Supertramp - Logical Song]\n\n"); strcat(menutext, "6. Show Page 2\n\n"); } else { strcat(menutext, "1. Boomtang Boys - Popcorn [Micro Mix]\n"); strcat(menutext, "2. Mr. Roboto\n"); strcat(menutext, "3. Chicane - Salt Water\n"); strcat(menutext, "4. John Jeski - Sailing Accordion Polka\n"); strcat(menutext, "5. Warrior - Voodoo\n\n"); strcat(menutext, "6. Show Page 1\n\n"); } strcat(menutext, "7. Switch to next song\n"); strcat(menutext, "8. Switch to previous song\n\n"); strcat(menutext, "9. Show pitch menu\n"); } else { sprintf(menutext, "Change the pitch and speed:\n\n"); strcat(menutext, "1. Change to normal pitch\n\n"); strcat(menutext, "2. 0.5x speed/pitch\n"); strcat(menutext, "3. 0.8x speed/pitch\n"); strcat(menutext, "4. 1.2x speed/pitch\n"); strcat(menutext, "5. 1.4x speed/pitch\n"); strcat(menutext, "6. 1.5x speed/pitch\n"); strcat(menutext, "7. 1.8x speed/pitch\n"); strcat(menutext, "8. 2.0x speed/pitch\n\n"); strcat(menutext, "9. Back to song menu\n"); } strcat(menutext, "\n\n0. Cancel\n"); bitsel |= 1<<0; // activate this choice in the menu 1 bitsel |= 1<<1; // activate this choice in the menu 2 bitsel |= 1<<2; // activate this choice in the menu 3 bitsel |= 1<<3; // activate this choice in the menu 4 bitsel |= 1<<4; // activate this choice in the menu 5 bitsel |= 1<<5; // activate this choice in the menu 6 bitsel |= 1<<6; // activate this choice in the menu 7 bitsel |= 1<<7; // activate this choice in the menu 8 bitsel |= 1<<8; // activate this choice in the menu 9 bitsel |= 1<<9; // activate this choice in the menu 9 // Now, show the menu to everyone! int gmsgShowMenu = 0; gmsgShowMenu = REG_USER_MSG( "ShowMenu", -1 ); int char_count = 0; char *pFileList = menutext; char *aFileList = menutext; while ( pFileList && *pFileList && char_count < 1024 ) { char chunk[MAX_MENU_CHUNK+1]; if ( strlen( pFileList ) < MAX_MENU_CHUNK ) { strcpy( chunk, pFileList ); } else { strncpy( chunk, pFileList, MAX_MENU_CHUNK ); chunk[MAX_MENU_CHUNK] = 0; // strncpy doesn't always append the null terminator } char_count += strlen( chunk ); if ( char_count < 1024 ) pFileList = aFileList + char_count; else *pFileList = 0; ALERT(at_console, "SENDING %i!!!\n", char_count); MESSAGE_BEGIN( MSG_ONE, gmsgShowMenu, NULL, pEntity ); WRITE_SHORT( bitsel ); WRITE_CHAR( 60 ); WRITE_BYTE( *pFileList ? TRUE : FALSE ); // TRUE means there is still more message to come WRITE_STRING( chunk ); MESSAGE_END(); } lastMenuPage[ENTINDEX(pEntity)] = n; lastMenuEnt[ENTINDEX(pEntity)] = ENTINDEX(pRadio); // Set the values that determine how long we accept input... menushow2[ENTINDEX(pEntity)] = gpGlobals->time + 60; }
/* ============ ImpulseCommands ============ */ void CBasePlayer::ImpulseCommands() { TraceResult tr;// UNDONE: kill me! This is temporary for PreAlpha CDs // Handle use events PlayerUse(); int iImpulse = GetImpulse(); switch( iImpulse ) { case 99: { bool bOn; if( !gmsgLogo ) { bOn = true; //TODO: figure out why this is done here. - Solokiller gmsgLogo = REG_USER_MSG( "Logo", 1 ); } else { bOn = false; } ASSERT( gmsgLogo > 0 ); // send "health" update message MESSAGE_BEGIN( MSG_ONE, gmsgLogo, NULL, this ); WRITE_BYTE( bOn ); MESSAGE_END(); if( !bOn ) gmsgLogo = 0; break; } case 100: // temporary flashlight for level designers if( FlashlightIsOn() ) { FlashlightTurnOff(); } else { FlashlightTurnOn(); } break; case 201:// paint decal if( gpGlobals->time < m_flNextDecalTime ) { // too early! break; } UTIL_MakeVectors( GetViewAngle() ); UTIL_TraceLine( GetAbsOrigin() + GetViewOffset(), GetAbsOrigin() + GetViewOffset() + gpGlobals->v_forward * 128, ignore_monsters, ENT( pev ), &tr ); if( tr.flFraction != 1.0 ) {// line hit something, so paint a decal m_flNextDecalTime = gpGlobals->time + decalfrequency.value; auto pCan = static_cast<CSprayCan*>( UTIL_CreateNamedEntity( "spray_can" ) ); pCan->CreateSprayCan( this ); } break; default: // check all of the cheat impulse commands now CheatImpulseCommands( iImpulse ); break; } SetImpulse( 0 ); }