AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   Solved [Module] How do I recreate Director HUD Message as a module? (https://forums.alliedmods.net/showthread.php?t=328329)

redivcram 11-04-2020 19:06

[Module] How do I recreate Director HUD Message as a module?
 
Title is pretty self-explanatory. I would like to recreate Arkshine's dhudmessage.inc in CPP and tried doing like in the presented code. I've tried both MSG_ONE and MSG_ONE_UNRELIABLE.


Code:

void DHudMessage(CBasePlayer* pPlayer, hudtextparms_t textparms, std::string text) {

    MESSAGE_BEGIN(MSG_ONE_UNRELIABLE, SVC_DIRECTOR, nullptr, pPlayer->pev);
    WRITE_BYTE(strlen(text.c_str()) + 31);
    WRITE_BYTE(DRC_CMD_MESSAGE);
    WRITE_BYTE(textparms.effect);
    WRITE_LONG(textparms.b1 + (textparms.g1 << 8) + (textparms.r1 << 16));
    WRITE_LONG(textparms.x);
    WRITE_LONG(textparms.y);
    WRITE_LONG(textparms.fadeinTime);
    WRITE_LONG(textparms.fadeoutTime);
    WRITE_LONG(textparms.holdTime);
    WRITE_LONG(textparms.fxTime);
    WRITE_STRING(text.c_str());
    MESSAGE_END();
}

This is supposed to print a dhudmessage, without success.

redivcram 11-06-2020 09:12

Re: [Module] How do I recreate Director HUD Message as a module?
 
The solution was basically converting (not directly casting) all float values to long. Hence WRITE_LONG.


All times are GMT -4. The time now is 03:44.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.