AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with gag/mute player plugin (https://forums.alliedmods.net/showthread.php?t=101430)

Baafen 08-23-2009 19:49

Help with gag/mute player plugin
 
Im new to scripting for amxx but not totaly new to programming/scripting.
I want to try to make a plugin that gags the player so he or she canīt use the chat or team chat.

I have found plugins that already does this so I tried to learn from them. But there is a part I donīt really understand.

Code:

public block_gagged(id){  // This function is what check the say / team_say messages & block them if the client is blocked.
   
if(!g_GagPlayers[id]) return PLUGIN_CONTINUE // Is true if the client is NOT blocked.
   
new cmd[5]
   
read_argv(0,cmd,4)
    if (
cmd[3] == '_' )
        {
        if (
g_GagPlayers[id] & 2){
#if GagReason == 1
           
client_print(id,print_chat,"* You are Gagged For The Following Reason: %s",gs_GagReason[id])
#else
           
client_print(id,print_chat,"* You Have Been Gagged")
#endif

#if PlaySound == 1
           
client_cmd(id,"spk barney/youtalkmuch")
#endif
           
return PLUGIN_HANDLED
           
}
        }
    else if (
g_GagPlayers[id] & 1)  {
#if GagReason == 1
           
client_print(id,print_chat,"* You Are Gagged For The Following Reason: %s",gs_GagReason[id])
#else
           
client_print(id,print_chat,"* You Have Been Gagged")
#endif
#if PlaySound == 1
           
client_cmd(id,"spk barney/youtalkmuch")
#endif
       
return PLUGIN_HANDLED
       
}
    return
PLUGIN_CONTINUE
   
}

(Taken from : http://forums.alliedmods.net/showpos...&postcount=271 )

This part is suposed to block the player when the player says something. But I donīt really get how this part actully blocks the player. Only that it tells the player that heīs gaged. Can someone please tell me if Im looking at the wrong part or if Im missing to se something.



Question two is that I also wounder which way is the best to save the gaged players. I have found nVault which seems to be able to do this. But how will it effect the server if it has to do lots of writing?

The way I want my plugin to work is that when a admin gags a player the plugin remeber the player by heīs steam id so he canīt change name to get away. And that it also saves the gag until an admin removes it. So the plugin has to remember the steam id after map changes and etc until its removed.

If there is any questions with what I mean please ask and I will try to explain it better.

And the reason why Im asking is becasue I want to learn. So please donīt tell me to use someone eles plugin. I want to learn by making my own.

fysiks 08-23-2009 22:57

Re: Help with gag/mute player plugin
 
Code:

return PLUGIN_HANDLED
This says that we are finished with the command ("say" or "say_team" in your case) so don't send it further (to the server to be processed as normal).

Code:

return PLUGIN_CONTINUE
This says that we are finished with the command but send it through so it will be processed normally.

You should use the former when the player is gagged.

Baafen 08-24-2009 11:51

Re: Help with gag/mute player plugin
 
Thanks. Now I know how to block the chat.

But Im still unsure of which way is the best to actully store the blocked steamids. Should I hold the steamids in a array or should I use nVault and compared to that data everytime someone type something? Because that sounds like it would be a ineffective way compared to saving it in a 2d array and use nVault before map change.

fysiks 08-24-2009 18:27

Re: Help with gag/mute player plugin
 
Well, when you store the SteamID you would check on every client connect if they are in the list. Then if they are in the list set a variable (isGagged[id] = true) and then in your gagging condintion you would check if that variable is true. This way you are not accessing nVault more often than necessary.

Baafen 08-28-2009 10:53

Re: Help with gag/mute player plugin
 
Thanks, I got it to work now and it works great!.

Now I also want to remove the change name message. Because players can chat by changeing name. Im able to change back the name itself but you still see the change name message. So they can still chat by using that. How do I prevent this message from appering?

In my plugin I used client_infochanged and in there I check if the player is gagged and use set_user_info to change the name back. But this still shows a change name message with the name the player tried to change to.

So its the message telling that someone changed his name is what I want to remove.

Im still doing some researching but I havenīt been able to really find what Im looking for.

fysiks 08-28-2009 19:06

Re: Help with gag/mute player plugin
 
Them changing their name should have no affect on this plugin. They shouldn't be referenced by name in the plugin, only entity number.

Baafen 08-29-2009 05:25

Re: Help with gag/mute player plugin
 
I think I didnīt make myself understood. Theyīre blocked even if they change name. But they can use the name change message itself to chat. For example change name to "I use amxx on my server" and then change name to "and it works awesome". So they use that name change message to chat. Even after being gagged. Because it shows up that they changed name to that.

fysiks 08-29-2009 11:16

Re: Help with gag/mute player plugin
 
Oh, I see. You could probably find some code like that here somewhere.


All times are GMT -4. The time now is 14:58.

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