Location Main > Metamod-P Extension Notes > Send HUD Colors


Login

Send HUD Colors


Below is an example of yellow text with blue fading effects.

If using fading in or other effects (effects=2), you want to devise a way so that it doesn't spam send the message to the user so that it can actually complete the effect. Otherwise it can appear broken, invisible, or not even show correctly. One way to do this is add a 'last message sent' value to each player and check if the user has already received a message in a certain time (if so, skip them).



void UTIL_SendHudMessage(edict_t *pEntity, int msg_dest, char *pMessage)
{
    MESSAGE_BEGIN(MSG_ONE, SVC_TEMPENTITY, NULL, pEntity);
    WRITE_BYTE(TE_TEXTMESSAGE);
    WRITE_BYTE(msg_dest & 0xFF); // channel
    WRITE_SHORT(MyFixedSigned16(1, (-1 << 13))); // screen position x
    WRITE_SHORT(MyFixedSigned16(-0.6, (-1 << 13))); // screen position y
    WRITE_BYTE(2); // effects
    WRITE_BYTE(25); //r1
    WRITE_BYTE(204); //g1
    WRITE_BYTE(245); //b1
    WRITE_BYTE(150); //a1
    WRITE_BYTE(225); //r2
    WRITE_BYTE(210); //g2
    WRITE_BYTE(25); //b2
    WRITE_BYTE(180); //a2
    WRITE_SHORT(MyFixedUnsigned16(0.003, (1 << 8))); // fadeinTime
    WRITE_SHORT(MyFixedUnsigned16(5.0, (1 << 8))); // fadeoutTime
    WRITE_SHORT(MyFixedUnsigned16(10.0, (1 << 8))); // holdTime
    WRITE_SHORT(MyFixedUnsigned16(1.1, (1 << 8))); //fxtime, only if effects = 2
    WRITE_STRING(pMessage);
    MESSAGE_END();

}