[SourceMod] TextMsg 이벤트 이용하여 메세지 삭제

Posted by subkarsei2
2015. 1. 22. 12:48 Info/Tips/Programming

TextMsg 를 통해서 이벤트를 훅을 걸 수 있습니다.

서버 파일 안 resources 폴더 안에 있는 '게임이름_english.txt'를 통해서 알아볼 수 있습니다.

(※사실, 저 폴더 안에 있는 파일을 가지고 내용을 변경할 수도 있습니다. 그리고 메세지 코드도 확인할 수 있구요.)


아래 목록은 '카운터 스트라이크: 소스'를 기준으로한 TextMsg 목록입니다.



mp_friendlyfire 을 1로 맞추고 같은 팀원을 공격하면 채팅창에 "~~~ attacked a teammate" 가 뜨는데 이 메세지를 삭제해보는 코드를 작성하면 이렇게 됩니다.


public OnPluginStart()

{

     HookUserMessage(GetUserMessageId("TextMsg"), Command_TextMsg, true);

}


public Action:Command_TextMsg(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)

{

     decl String:buffer[256];

     

     buffer[0] = '\0';

     BfReadString(bf, buffer, sizeof(buffer), false);

     

     if (StrContains(buffer, "Game_teammate_attack") != -1)

          return Plugin_Handled;

     

     return Plugin_Continue;

}