←  Pytania

AMXX.pl: Support AMX Mod X i SourceMod

»

CS:GO
[ROZWIĄZANE] Messagemode w SM


Najlepsza odpowiedź MAGNET 07.09.2018 23:00

Nie ma messagemode. Musisz po prostu łapać say i na końcu zwracać Plugin_Stop lub Handled:
 
 
RegConsoleCmd("say", ProcessChat);

RegConsoleCmd("say_team", ProcessChat);
 
public Action ProcessChatIf(int client, int args)
{
    char ArgsBuffer[1024];
    char BufferForOneArg[128];

    

    // retrieving all the arguments and concatenating them as one

    for (int i = 1; i < args+1;i++)

    {

            GetCmdArg(i, BufferForOneArg, 127);

            

            StrCat(ArgsBuffer, 1023, BufferForOneArg);

            if(!isTheLastArgument(i, args))    StrCat(ArgsBuffer, 1023, " ");

    }

    

    PrintToChat(client, "Entered value: %s", ArgsBuffer);
    
    return Plugin_Stop;
}
public int isTheLastArgument(int i, int args)
{
	return i == args;
}
Przejdź do postu
Zablokowany

  • +
  • -
Ogen Dogen - zdjęcie Ogen Dogen 07.09.2018

Jak w temacie, czy istnieje (odpowiednik) messagemode w SourceMod ? Jeśli tak, to jak go obsłużyć ? Jeśli nie to jaka jest alternatywa ? Obsługa przez nasłuchiwanie chatu ?

Chce uzyskać efekt gdzie otworzę graczowi specjalne okno z chatem, którego wiadomość odbiorę w konkretnej funkcji, a sama wiadomość nie pokaże się reszcie graczy.

Odpowiedz

  • +
  • -
Najlepsza odpowiedź MAGNET - zdjęcie MAGNET 07.09.2018

Nie ma messagemode. Musisz po prostu łapać say i na końcu zwracać Plugin_Stop lub Handled:
 
 
RegConsoleCmd("say", ProcessChat);

RegConsoleCmd("say_team", ProcessChat);
 
public Action ProcessChatIf(int client, int args)
{
    char ArgsBuffer[1024];
    char BufferForOneArg[128];

    

    // retrieving all the arguments and concatenating them as one

    for (int i = 1; i < args+1;i++)

    {

            GetCmdArg(i, BufferForOneArg, 127);

            

            StrCat(ArgsBuffer, 1023, BufferForOneArg);

            if(!isTheLastArgument(i, args))    StrCat(ArgsBuffer, 1023, " ");

    }

    

    PrintToChat(client, "Entered value: %s", ArgsBuffer);
    
    return Plugin_Stop;
}
public int isTheLastArgument(int i, int args)
{
	return i == args;
}
Odpowiedz

  • +
  • -
Ogen Dogen - zdjęcie Ogen Dogen 07.09.2018

Nie ma messagemode. Musisz po prostu łapać say i na końcu zwracać Plugin_Stop lub Handled:
 
 

RegConsoleCmd("say", ProcessChat);

RegConsoleCmd("say_team", ProcessChat);
 
public Action ProcessChatIf(int client, int args)
{
    char ArgsBuffer[1024];
    char BufferForOneArg[128];

    

    // retrieving all the arguments and concatenating them as one

    for (int i = 1; i < args+1;i++)

    {

            GetCmdArg(i, BufferForOneArg, 127);

            

            StrCat(ArgsBuffer, 1023, BufferForOneArg);

            if(!isTheLastArgument(i, args))    StrCat(ArgsBuffer, 1023, " ");

    }

    

    PrintToChat(client, "Entered value: %s", ArgsBuffer);
    
    return Plugin_Stop;
}
public int isTheLastArgument(int i, int args)
{
	return i == args;
}

 

Tak czułem, że na tym się skończy. A co jeśli chce obsłużyć kilka komend ? Muszę w jednej funkcji rozpisać if'y czy można to zrobić w bardziej elegancki sposób ? (w amxx bym zrobił X registerów w plugin_init)

Odpowiedz

  • +
  • -
MAGNET - zdjęcie MAGNET 08.09.2018

możesz spokojnie robić X registerów

Odpowiedz

  • +
  • -
MAGNET - zdjęcie MAGNET 13.09.2018

Wiadomość wygenerowana automatycznie


Ten temat został zamknięty przez moderatora.

Powód: Pomoc udzielona

Jeśli się z tym nie zgadzasz, report.png raportuj ten post, a moderator lub administrator rozpatrzy go ponownie.


Z pozdrowieniami,
Zespół AMXX.PL
Odpowiedz
Zablokowany