[Server Scripting] Current Pokémon Online Server Scripts

Discussion in 'Server and Client Scripting' started by coyotte508, Apr 21, 2010.

  1. zeroality

    zeroality Artificial Insanity

    Joined:
    Apr 22, 2010
    Messages:
    1,378
    Likes Received:
    1
    Seems there's a script error somewhere concerning /ranking.

    [​IMG]
     
  2. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Nice zeroality, that is a bug in tier.cpp!

    When you ask ranking via GUI, it works like this:
    Code (text):
    1.  
    2. void Tier::processQuery(QSqlQuery *q, const QVariant &name, int type, WaitingObject *w)
    3. {
    4. ...
    5. q->prepare(QString("select name, displayed_rating from %1 order by displayed_rating desc, name asc offset ? limit ?").arg(sql_table));
    6. ...
    7. }
    8.  
    But when you fetch ranking via script:
    Code (text):
    1.  
    2. int Tier::ranking(const QString &name)
    3. {
    4. ...
    5. q.prepare(QString("select count(*) from %1 where (displayed_rating>:r1 or (displayed_rating=:r2 and name<=:name))").arg(sql_table));
    6. ...
    7. return q.value(0).toInt() +1;
    8. }
    9.  
    That definitely won't return 1 ever, since count(*) will have at least one name (you), and it add 1 to it on return. Easy fix: remove +1 from return.

    // Seems like ranking have even more error if you share the ranking with many people. Maybe name<=:name and order name asc don't follow the same order?
     
    Last edited: Mar 14, 2011
  3. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    But when you remove the +1 there's also errors, sometimes it shows your ranking is 0 or whatever.
     
  4. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Figured out. Names are saved in lower case, name may still be using capitalized letters.
     
  5. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    So you fixed it?
     
  6. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Nope, but I'll test and fix it after I do dishes and put children to sleep.
     
  7. DarkneShadow

    DarkneShadow New Member

    Joined:
    Apr 11, 2011
    Messages:
    6
    Likes Received:
    0
    I'm getting:

    Script Warning in sys.getFileContent(filename): error when opening mutes.txt: No such file or directory
    Script Warning in sys.getFileContent(filename): error when opening mbans.txt: No such file or directory
    Script Warning in sys.getFileContent(filename): error when opening smutes.txt: No such file or directory
    Script Warning in sys.getFileContent(filename): error when opening rangebans.txt: No such file or directory
    Script Warning in sys.getFileContent(filename): error when opening tourstats.json: No such file or directory
    Could not read tourstats, initing to null stats.
    Error: SyntaxError: Unable to parse JSON string
    Script Warning in sys.getFileContent(filename): error when opening battlestats.json: No such file or directory
    Could not read battlestats, initing to null stats.
    Error: SyntaxError: Unable to parse JSON string

    I need help please D:
     
  8. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    No problem, those are files automatically generated by scripts.. you don't have to worry about them missing.
     
  9. DarkneShadow

    DarkneShadow New Member

    Joined:
    Apr 11, 2011
    Messages:
    6
    Likes Received:
    0
    That is really weird then :/ Because my server doesnt work and I thought it was because of those scripts
     
  10. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    What is the problem then? We can continue this discussion on Help section.
     
  11. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Lamperi, did you manage to fix that? Need help? :lazy guy:
     
  12. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Code a function sys.isFile() so that Javascript can avoid those messages ^^
     
  13. Umbreon

    Umbreon Member

    Joined:
    Apr 22, 2011
    Messages:
    68
    Likes Received:
    0
    The New Scripts crashed me. I came up with a host of errors and missing elements the old script already had. So I don't know what was going on but it majorly screwed me over right now.....I don't even have the other scripts to reset it back to now. Right now idk what to do besides try to rebuild them from scratch instead of using the scripts that crashed my comp with a bunch of random errors.
     
  14. Eco

    Eco New Member

    Joined:
    Apr 22, 2011
    Messages:
    20
    Likes Received:
    0
    The scripts updated yet?

    (Too lazy to script the ST Shandy ban myself) :B
     
  15. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    No.. PO server scripts haven't had any ban for Chandelure with Shadow Tag and won't have. Instead you can take a look of shanaiAbilityCheck which is the last function in the scripts if you want to ban some abilities on some pokes.
     
  16. supertrunks8

    supertrunks8 Pwnage

    Joined:
    Jun 20, 2011
    Messages:
    350
    Likes Received:
    0
    Well when I use the Current PO Scripts, the one coyotte508 posted, it doesn't work, like it says "ScriptBot: Scripts have been updated" or whatever, but when I type /Commands nothing happens. When I go to http://www.pastebin.com and use it from there, it works perfectly fine. Would anyone happen to know the reason to this?
     
  17. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
  18. twofivefive

    twofivefive don't call it a comeback

    Joined:
    Dec 28, 2010
    Messages:
    1,395
    Likes Received:
    2
    I have a question:
    Fatal Script Error line 5614: SyntaxError: Parse error
    Comes up when I paste all that crap into my "Scripts" window thingy.
     
  19. Kalashnikov

    Kalashnikov Despite the code quality

    Joined:
    Apr 4, 2011
    Messages:
    434
    Likes Received:
    0
    There is an unmatched bracket at that line.
    Change it from:
    if (this.isMCaps(message) && sys.auth(src) < 2 && ignoreChans.indexOf(channel) == -1 && ignoreUsers.indexOf(sys.name(src) == -1)
    To:
    if (this.isMCaps(message) && sys.auth(src) < 2 && ignoreChans.indexOf(channel) == -1 && ignoreUsers.indexOf(sys.name(src) == -1))

    And you shouldn't use these scripts unless you compiled the latest version of the server.
     
  20. twofivefive

    twofivefive don't call it a comeback

    Joined:
    Dec 28, 2010
    Messages:
    1,395
    Likes Received:
    2
    And where is that line? :/ line 5614 surely won't take a long time to reach...
     
  21. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    I advice you to use normal language.
     
  22. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    It's fixed now.

    Also use some other editor than PO Server Script Window to edit scripts Iceydude, it's awful.
     
  23. {HQ}Eternity

    {HQ}Eternity New Member

    Joined:
    Aug 5, 2011
    Messages:
    1
    Likes Received:
    0
    Hey Lamperi, what do you use to edit scripts? Also, did you update the scripts yesterday? I got error messages when I tried it saying something didn't exist, or whatever. Thanks
     
  24. Xehanorto

    Xehanorto New Member

    Joined:
    Aug 23, 2011
    Messages:
    2
    Likes Received:
    0
    So I need to set a script for my newly made server can someone help me out
     
  25. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Sometimes Vim when making bigger updates, for smaller updates browser's textedit suffices.

    I'll update scripts pretty often, it's unfortunate that sometimes there are some minor bigs, or big breakers left, but asking on the forum will help you in problems.

    Download http://pokemon-online.eu/scripts.js and place them into your server folder. There are also other scripts, like Mystra's, Lutra's, TUO's. You could even write the scripts from scratch but unless you know programming I don't recommend that.
     
  26. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Some people wanted a /stats command to see your wins/loses/ties for your current playing session, they asked me to request it too ._.
    Anyway its not hard to do.
     
  27. Marche Radiuju

    Marche Radiuju crush it casually

    Joined:
    Jun 29, 2010
    Messages:
    407
    Likes Received:
    0
    PO Trainer Name:
    Juggler
    I remember that on NB it showed your wins/loss/ties, and those were how I determined whether I could actually be a match for someone. If it's Fog with 1000 wins I doubt it, but if it's namelessfacelessguyjoe with 30/9/1 then I'll chall him.

    If it's possible I think the best spot to put it would be challenge window. A command would probably be easier, though.
     
  28. Cosmic Ranger

    Cosmic Ranger Always @ Your Service

    Joined:
    Sep 5, 2011
    Messages:
    31
    Likes Received:
    7
    PO Trainer Name:
    RoboMan
    IT is nice.
    thnx
     
  29. eric the espeon

    eric the espeon is an espeon.

    Joined:
    Apr 21, 2010
    Messages:
    854
    Likes Received:
    1
    Lameri, could we have an error message when people post a message that's too long (and maybe relax the restrictions on message length)? Something like:
    "Message too long to send. Press the up key to retrieve it."
    or even give the character length allowed/character length of message you attempted to send to give an idea of how much the user needs to cut down by?
     
  30. Pokemonexperte-Martin

    Pokemonexperte-Martin Member

    Joined:
    May 15, 2010
    Messages:
    76
    Likes Received:
    0
    I strongly appeal that this script finds it's way back to a git repository, not neccessary the main project.
     
  31. eric the espeon

    eric the espeon is an espeon.

    Joined:
    Apr 21, 2010
    Messages:
    854
    Likes Received:
    1
    Suggestion for the way reasons for mute/bans are handled. Currently they require a reason which slows down the mod, and is annoying. Forcing reasons is good because it helps keep track, but delaying the punishment is not. I suggest either allowing mutes/bans to be made and applied without reason, but having the server prompt the mod every ~20 seconds to provide one until they do, or adding alternate versions of the mute command:

    /mr5 user:time
    Would give a mute reason related to rule 5, like "Unacceptable conduct towards users.". /mr2 would be "Flooding", and so on. /br5 would be the same form, except banning. I can write a full list of reasons if wanted, though some of the rules could do with condensing/grammar fixing/clarification too which may as well be done at the same time.
     
  32. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    This was done.

    I agree. Current way is easy to modify to the staff of Pokemon Online server, but it sometimes harms maintaining to be without revision infromation.
    If you notice any spelling errors in the scripts feel free to post here / discuss on the server. As the muting goes, I think that having a documentation about punishments is a lot better than not to have it. Those commands would be easy to script, even given default time per reason, but I'm not sure if it's easier to use them :\
     
  33. eric the espeon

    eric the espeon is an espeon.

    Joined:
    Apr 21, 2010
    Messages:
    854
    Likes Received:
    1
    Will go over everything altogether and post stuff at some point (or maybe best to just fix everything and pass you back the script), not spelling mostly, just awkward grammar/strange things. Like "Rule #6 - Be Respectable of Each Others Cultures:" has strange capitalization and respectable which should be respectful, or "/me [message]: to speak with *** before its name" which should have its -> your and could be rewritten to flow more smoothly overall.

    And, I was not suggesting remove the reason entirely, the first idea would have it go like:

    troll: TROLLLING
    mod: /mute troll:30
    Dratini: troll was muted for 30 mins
    Dratini (just to mod): Please send a reason for troll's mute
    mod: /reason <reason>

    Just lets the first mute get out quicker. I'm kind of going off it in favor of the second idea though, having a fast mute/ban is nice and once you've memorized the most commonly wanted reasons you'd only have to type a few characters. The standard mute would stay and be available for more personalized mute reasons, but having shortcuts would be cool. The reasons would still be stored, and if the mute reasons are chosen carefully it'd cut down on mods seeing something something obviously mutable, and not knowing quite what to put so just throwing an insult (I've seen "stop being retarded", "idiot", and "stupid troll" used before) into the mute/ban reason which is less than ideal for obvious reasons.
     
  34. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Use separate git repo for script instead.
     
  35. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Should the scripts in the repo be changed into very basic scripts then, "skeleton", which only has events and comments on them?
     
  36. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Well, you can make them separate functions that are defined in the code above ({ }) like I do it :P Although you'd probably want to wrap them (and maybe helpers) into some kind of pseudo namespaces.
     
  37. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Maybe do something like put po.js in scripts,

    then do:

    Code (text):
    1. return sys.import("po.js");
    ?

    And so scripts.js wouldn't periodically change, making it easy for people who have their own script to not have to manage conflicts on scripts.
     
  38. kupo

    kupo Member

    Joined:
    Feb 10, 2011
    Messages:
    63
    Likes Received:
    0
    1) Someone tried to create a channel and instead of the new channel being made, they became owner of the main channel and it got ugly.. *edit* they said they did /register
    2) There's a constant error about something like sys.stopevent() cannot be stopped because it is an unstoppable event everytime someone joins.
    3) Is there a way to take out the unreleased DW block in the script? can you make a version without the unreleased dw block or is there an easier way I can do myself?

    Any response from anyone will be greatly appreciated, I really like these scripts and am interested in using, or at least trying them out.
    Edit: how do you change the color of the words, for say the commands list?
     
    Last edited: Sep 21, 2011
  39. Chinchillarmy

    Chinchillarmy Indonesian Translator

    Joined:
    Sep 16, 2011
    Messages:
    24
    Likes Received:
    0
    I'm using 1.0.30. The script works fine but, the mute command doesn't work. The script was downloaded today.

    This is what I got before deleting all mute function.

    "Script Error line 6115: TypeError: Result of expression 'SESSION.users(src).expired' [undefined] is not a function."

    PHP:
    1.     if (SESSION.users(src).expired("mute")) {
    2.         SESSION.users(src).un("mute");
    3.         normalbot.sendChanMessage(src, "your mute has expired.");
    4.         normalbot.sendAll("" + sys.name(src) + "'s mute has expired.", trollchannel);
    Edit: How about 1.0.30 PL1? Is the mute command works properly?
     
    Last edited: Sep 25, 2011
  40. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    That person's SESSION properties were most likely not registered, try kicking everyone or restarting.