No-Talking Script

Discussion in 'Server and Client Scripting' started by Mister B, Sep 13, 2011.

  1. Mister B

    Mister B New Member

    Joined:
    Sep 13, 2011
    Messages:
    15
    Likes Received:
    0
    It's possible to made a script that prevents the people UNREGISTERED to talk and battle?
    Possibily with a message for advice,and when they register,this "mute" stops.
    Thanks :)
     
  2. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Use sys.dbRegistered(name) in beforeChatMessage event and stop it if name is not registered.
     
  3. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    You can use beforeBattleMatchup and beforeChallengeIssued to prevent battles, using same method with sys.dbRegistered and sys.stopEvent
     
  4. Mister B

    Mister B New Member

    Joined:
    Sep 13, 2011
    Messages:
    15
    Likes Received:
    0
    As I am not very expert in that,how it would be the script?
     
  5. person6445

    person6445 → Find_Battle_Button ←

    Joined:
    Jan 24, 2011
    Messages:
    83
    Likes Received:
    0
    Code (JAVASCRIPT):
    1.  
    2. beforeChatMessage: function(src, message, chan) {
    3. var srcname = sys.name(src);
    4. if (!sys.dbRegistered(srcname)) {
    5. sys.stopEvent();
    6. sys.sendMessage(src, "+Bot: You need to Register before you can talk! Registering is free and does not require an e-mail. You can find the Register Button at the bottom of your Pokemon Online window!");
    7. return;
    8. }
    9. }
    10.  
    Well, that should work.
    Add this function to your scripts.

    If you already have a beforeChatMessage, do NOT add this! Simply remove one '}' after the 'return;' and the 'beforeChatMessage: function(src, message, chan) {' from the snip, and add the rest of the code to your beforeChatMessage.

    I'm not the best scripter, and it could possibly not work. If it doesn't work, then I'm sorry for the inconvenience. If it does, great! :)
     
  6. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Also put it on the top of beforeChatMessage, order of script evaluation matters.
     
    Last edited: Sep 13, 2011
  7. Mister B

    Mister B New Member

    Joined:
    Sep 13, 2011
    Messages:
    15
    Likes Received:
    0
    If i want to change the advice message,how i can do?
     
  8. person6445

    person6445 → Find_Battle_Button ←

    Joined:
    Jan 24, 2011
    Messages:
    83
    Likes Received:
    0
    Code (javascript):
    1.  
    2. sys.sendMessage(src, "+Bot: You need to Register before you can talk! Registering is free and does not require an e-mail. You can find the Register Button at the bottom of your Pokemon Online window!");
    3.  
    Change the words in the "quotes." (The blue stuff: Just make sure you KEEP THE QUOTES!)
    Edit: If you want to HTML the message, change 'sys.sendMessage' to 'sys.sendHtmlMessage'.
    c:
     
  9. supertrunks8

    supertrunks8 Pwnage

    Joined:
    Jun 20, 2011
    Messages:
    350
    Likes Received:
    0
    Wow guys, thats a really cool snip :3
     
  10. [ƦЄ]Blade

    [ƦЄ]Blade Not sure.

    Joined:
    Mar 6, 2011
    Messages:
    75
    Likes Received:
    0
    That is a very nice snip. It's nice for those trolls who try to come in a troll w/o registering :D
     
  11. supertrunks8

    supertrunks8 Pwnage

    Joined:
    Jun 20, 2011
    Messages:
    350
    Likes Received:
    0
    Yeah is it possible to make it the person IS registered but they still can't talk. Or would only be in massmute/muteAll?
     
  12. [ƦЄ]Blade

    [ƦЄ]Blade Not sure.

    Joined:
    Mar 6, 2011
    Messages:
    75
    Likes Received:
    0
    ._. You would have to mute them or make a special snip that mutes the person upon login
     
  13. supertrunks8

    supertrunks8 Pwnage

    Joined:
    Jun 20, 2011
    Messages:
    350
    Likes Received:
    0
    O and muting after long in is easy:

    Code (JAVASCRIPT):
    1.  
    2. afterLogIn : function(src) {
    3. sys.sendMessage(src, "Flareon: Your IP  " + sys.name(src) + " is " + sys.ip(src));
    4. sys.sendMessage(src, "Umbreon: Use !commands or /commands to see the commands!");
    5. sys.mute(src)
    6. muted[src] = true;
    7.  
    and

    Code (JAVASCRIPT):
    1.  
    2. beforeLogOut : function (src) {
    3.     if (muted[src] == false) {
    4.         sys.saveVal("muted*" + sys.ip(src), "true");
    5.     } else {
    6.         sys.removeVal("muted*" + sys.ip(src));
    7.     }
    8. }
    9.  
    10. })
    11.  
    So yeah :)
     
    Last edited: Sep 14, 2011
  14. supertrunks8

    supertrunks8 Pwnage

    Joined:
    Jun 20, 2011
    Messages:
    350
    Likes Received:
    0
    No Chat Snip

    Add

    Code (JAVASCRIPT):
    1.  
    2. afterLogIn : function(src) {
    3. sys.mute(src)
    4. muted[src] == true;
    5.  
    After afterLongIn.

    Code (JAVASCRIPT):
    1.  
    2. beforeChatMessage: function(src, message) {
    3. if (sys.auth(src) < 0 && muted[src] == true) {
    4. sys.stopEvent();
    5. sys.sendMessage(src, "~~Server~~: Sorry, this is not a chatting Server!");
    6. return;
    7.  
    After beforeChatMessage

    Code (JAVASCRIPT):
    1.  
    2. beforeLogOut : function (src) {
    3. if (muted[src] == true) {
    4. sys.saveVal("muted*" + sys.ip(src), "true");
    5. } else {
    6. sys.removeVal("muted*" + sys.ip(src));
    7. }
    8. }
    9.  
    10. })
    11.  
    After beforeLogOut

    Then no one would be able to talk. I might make a No Chat Script, im not sure yet ._.

    :)
     
    Last edited: Sep 14, 2011
  15. Mister B

    Mister B New Member

    Joined:
    Sep 13, 2011
    Messages:
    15
    Likes Received:
    0
    Strange,when i try to edit the message it says Parse Error...maybe that's why my edited text is not blue? D:
     
  16. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    Copy and paste what you were trying here
     
  17. Kalashnikov

    Kalashnikov Despite the code quality

    Joined:
    Apr 4, 2011
    Messages:
    434
    Likes Received:
    0
    You can only edit text inside the quotes ("), but do not remove the quotes itself.
    Also you shouldn't put another double quotes there. If you need to, prepend them with backslashes (\)
     
  18. Mister B

    Mister B New Member

    Joined:
    Sep 13, 2011
    Messages:
    15
    Likes Received:
    0
    It's an italian translation of that message...
    "Devi registrarti prima di poter parlare!Registrarsi è gratuito e non richiede e-mail.Puoi trovare il tasto "Registrati" in basso!"
     
  19. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    Yeah, I see then, as Kalashnikov said replace one set of double quotes with single quotes (') or put a \ before the quote marks around the word Registrati

    Like so
    "Devi registrarti prima di poter parlare!Registrarsi è gratuito e non richiede e-mail.Puoi trovare il tasto \"Registrati\" in basso!"
    Or
    "Devi registrarti prima di poter parlare!Registrarsi è gratuito e non richiede e-mail.Puoi trovare il tasto 'Registrati' in basso!"
     
  20. Mister B

    Mister B New Member

    Joined:
    Sep 13, 2011
    Messages:
    15
    Likes Received:
    0
    It works.
    Thank you all!
     
  21. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Code (javascript):
    1.  
    2. if(sys.auth(src) < 1) {
    3. sys.stopEvent();
    4. sys.sendMessage(src,"Can't talk right now!");
    5. return; }
    6.  
     
  22. person6445

    person6445 → Find_Battle_Button ←

    Joined:
    Jan 24, 2011
    Messages:
    83
    Likes Received:
    0
    I'm glad it worked.
    You're welcome~
     
  23. supertrunks8

    supertrunks8 Pwnage

    Joined:
    Jun 20, 2011
    Messages:
    350
    Likes Received:
    0
    Yeah i'm going to in a few days maybe make a No-Chatting-Script. Where only "127.0.0.1." or "localhost" may talk in Main Chat or any Channels. Give me a few days and I can make on with basic commands like:
    /authlist
    /players
    /rules

    *
    /kick [player]

    **
    /ban [player]
    /unban [player]

    ***
    /changeauth

    So yeah with just some lil commands :)
     
  24. Seiki

    Seiki :derp:

    Joined:
    Aug 20, 2011
    Messages:
    117
    Likes Received:
    0
    localhost isnt an IP, but counts as "127.0.0.1" :/
     
  25. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako