I tried to use this method but to try and develop my own "gag" command but I failed as you did, I ended up sticking with the next best thing - AdminModX's Gag command.
When that Gag command is executed on someone they cannot use their mics anywhere nor can they hear mics anywhere. Unfortunately if you know the code for AdminModX's Gag command you can very easily "un-gag" yourself

.