AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   old "SayText" in CSGO (https://forums.alliedmods.net/showthread.php?t=317462)

Old and Slow 07-14-2019 19:31

old "SayText" in CSGO
 
I have a plugin that, once upon a time, worked in both CSS and CSGO with minor logic to handle both. I think that CSGO now uses a newer engine and SDK, so there must be something equivalent for it. I have not had any luck finding it.

Could anybody enlighten me as to what it is?

Thanks!

asherkin 07-15-2019 09:01

Re: old "SayText" in CSGO
 
CS:GO uses protobuf for usermessages, if your current code is from before that switch (Jan 2013) it is going to be a lot of work to migrate.

https://mxr.alliedmods.net/sourcemod...fLife2.cpp#502

Old and Slow 07-15-2019 12:02

Re: old "SayText" in CSGO
 
I can't remember the last time it ran but it was probably before then.
Any links to some example code, similar to the Sample and Stub code?

Thanks for the sourcemod link - that may be good to look at.

TheDS1337 07-25-2019 13:58

Re: old "SayText" in CSGO
 
If you're doing it for an SM extension then you can take advantage of the Usermessages interface. if it's for mms, then I'm afraid you'll have to go all around it yourself (you can always see how it's done in SM ofcourse), here's an example code:
HTML Code:

void UM_SayText(int *clients, int clientsCount, int author, bool addTag, const char *input)
{
        if( !input  )
        {
                return;
        }

        static int msgId = -1;

        if( msgId == -1 )
        {
                msgId = usermsgs->GetMessageIndex("SayText2");
        }

        CCSUsrMsg_SayText2 *msg = (CCSUsrMsg_SayText2 *) usermsgs->StartProtobufMessage(msgId, clients, 1, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);

        if( msg )
        {
                // Colors
                //        x01                ->                default (white)
                //        x03                ->                team (blue or orange)
                //        x04                ->                green
                //        x05                ->                olive
                //        x07%s        ->                RRGGBB
                //        x08%s        ->                RRGGBBAA

                static char buffer[1024];

                if( addTag )
                {
                        ke::SafeSprintf(buffer, sizeof(buffer), "\x01 \x04[\x03%s\x04] \x01%s", g_pGameMod->GetTag(), input);
                }
                else
                {
                        ke::SafeSprintf(buffer, sizeof(buffer), "\x01 \x01%s", input);
                }

                msg->set_ent_idx(author);
                msg->set_chat(true);
                msg->set_msg_name(buffer);

                const google::protobuf::FieldDescriptor *field = msg->GetDescriptor()->FindFieldByName("params");

                if( field )
                {
                        msg->GetReflection()->AddString(msg, field, "");
                        msg->GetReflection()->AddString(msg, field, "");
                        msg->GetReflection()->AddString(msg, field, "");
                        msg->GetReflection()->AddString(msg, field, "");
                }
       
                usermsgs->EndMessage();               
        }
}


NOTE: you'll have to link the libprotobuf.lib/a file, and you'll also need to include some additional source and header files for the linking to work, all of this can be found on the HL2SDK for CSGO, provided by the AlliedModders team. for the source files you can just need these:
Code:

public/engine/protobuf/netmessages.pb.cc
public/game/shared/csgo/protobuf/cstrike15_usermessages.pb.cc
public/game/shared/csgo/protobuf/cstrike15_usermessage_helpers.cpp

Also, for winows you'll have to compile libprotobuf yourself.

For useful info on the matter, check this out: https://wiki.alliedmods.net/Compiling_libprotobuf

Old and Slow 08-01-2019 16:38

Re: old "SayText" in CSGO
 
Thanks - sorry for the late reply (got sidetracked on something else)
I had peeked at the sourcemod implementation - I just need to dig into it deeper.


All times are GMT -4. The time now is 15:26.

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