1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Guest, PO has ceased our separate tiering and adopted Smogon tiers for SM. More information and updates here.

    Dismiss Notice

[Client Scripting] Client scripts

Discussion in 'Server and Client Scripting' started by coyotte508, Jul 7, 2012.

  1. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    Client scripting were introduced (see plugin manager > add plugins > client scripting)

    events:
    Code (javascript):
    1.     /* Events */
    2.     void stepEvent();
    3.  
    4.     void clientStartUp();
    5.     void clientShutDown();
    6.  
    7.     int beforeSendMessage(const QString &message, int channel);
    8.     int beforeChannelMessage(const QString &message, int channel, bool html);
    9.     int afterChannelMessage(const QString &message, int channel, bool html);
    10.     int beforePMReceived(int id, const QString &message);
    11.     int afterPMReceived(int id, const QString &message);
    12.     int onPlayerReceived(int id);
    13.     int onPlayerRemoved(int id);
    sys functions:
    Code (javascript):
    1.  
    2.     /* Prevents the event from happening.
    3.        For exemple, if called in 'beforeChatMessage', the message won't appear.
    4.        If called in 'beforeChallengeIssued', the challenge won't be issued.
    5.        */
    6.     void stopEvent();
    7.  
    8.     /* Print on the client. Useful for debug purposes */
    9.     void print(QScriptContext *context, QScriptEngine *engine);
    10.     void clearChat();
    11.  
    12.     bool validColor(const QString &color);
    13.     QString hexColor(const QString &colorname);
    14.  
    15.     /* Accepts string as 1st parameter. */
    16.     int callLater(const QString &s, int delay);
    17.     int callQuickly(const QString &s, int delay);
    18.  
    19.     /* Accepts function as 1st parameter. */
    20.     int quickCall(const QScriptValue &func, int delay);
    21.     int delayedCall(const QScriptValue &func, int delay);
    22.  
    23.     /* Interval timers. */
    24.     int intervalTimer(const QString &expr, int delay);
    25.     int intervalCall(const QScriptValue &func, int delay);
    26.  
    27.     /* Stops a timer. */
    28.     bool stopTimer(int timerId);
    29.  
    30.     /* Evaluates the script given in parameter */
    31.     QScriptValue eval(const QString &script);
    32.  
    33.     int rand(int min, int max);
    34.     long time();
    35.  
    36.     QScriptValue getScript();
    37.  
    38.     int pokeType1(int id, int gen = GenInfo::GenMax());
    39.     int pokeType2(int id, int gen = GenInfo::GenMax());
    40.  
    41.     QScriptValue pokemon(int num);
    42.     QScriptValue pokeNum(const QString &name);
    43.     QScriptValue move(int num);
    44.     QScriptValue moveNum(const QString &name);
    45.     int moveType(int moveNum, int gen = GenInfo::GenMax());
    46.     QScriptValue item(int num);
    47.     QScriptValue itemNum(const QString &item);
    48.     QScriptValue nature(int num);
    49.     QScriptValue natureNum(const QString &nature);
    50.     QScriptValue ability(int num);
    51.     QScriptValue abilityNum(const QString &nature);
    52.     QScriptValue genderNum(QString genderName);
    53.     QString gender(int genderNum);
    54.  
    55.     QString sha1(const QString &text);
    56.     QString md4(const QString &text);
    57.     QString md5(const QString &text);
    58.  
    59.     bool isSafeScripts();
    60.     bool showingWarnings();
    61.  
    62.     void hostName(const QString &ip, const QScriptValue &function);
    63.  
    64.     /* Save vals using the QSettings (persistent vals, that stay after the shutdown of the server */
    65.     void saveVal(const QString &key, const QVariant &val);
    66.     void removeVal(const QString &key);
    67.     QScriptValue getVal(const QString &key);
    68.     QScriptValue getValKeys();
    69.  
    70.     /* Save vals in the system registry. */
    71.     void saveRegVal(const QString &key, const QVariant &val);
    72.     void removeRegVal(const QString &key);
    73.     QScriptValue getRegVal(const QString &key);
    74.     QScriptValue getRegKeys();
    75.  
    76.     QScriptValue filesForDirectory (const QString &dir_);
    77.     QScriptValue dirsForDirectory (const QString &dir_);
    78.  
    79.     // Direct file access.
    80.     void appendToFile(const QString &fileName, const QString &content);
    81.     void writeToFile(const QString &fileName, const QString &content);
    82.     void deleteFile(const QString &fileName);
    83.     QScriptValue getFileContent(const QString &path);
    84.  
    85.     /* GET call */
    86.     void webCall(const QString &urlstring, const QScriptValue &callback);
    87.  
    88.     /* POST call */
    89.     void webCall(const QString &urlstring, const QScriptValue &callback, const QScriptValue &params_array);
    90.     /* synchronous GET call */
    91.     QScriptValue synchronousWebCall(const QString &urlstring);
    92.     /* synchronous POST call */
    93.     QScriptValue synchronousWebCall(const QString &urlstring, const QScriptValue &params_array);
    94.  
    95. public slots:
    96.     void changeScript(const QString &script, const bool triggerStartUp = false);

    client functions (do client.xxx())
    Code (javascript):
    1.  
    2.     void cancelFindBattle(bool verbose=true);
    3.     bool playerExist(int id) const;
    4.     QString name(int id) const;
    5.     QString ownName() const;
    6.     bool battling() const;
    7.     bool busy() const;
    8.     bool hasChannel(int channelid) const;
    9.     bool away() const;
    10.     int id(const QString &name) const;
    11.     int currentChannel() const;
    12.     Channel *channel(int channelid);
    13.     int ownId() const;
    14.     int ownAuth() const;
    15.  
    16.     int auth(int id) const;
    17.     bool isIgnored(int id) const;
    18.  
    19.     QString authedNick(int id) const;
    20.     QColor color(int id) const;
    21.  
    22.     QString tier(int player) const;
    23.     QStringList tiers(int player) const;
    24.  
    25.     void reconnect();
    26.  
    27.     QString defaultChannel();
    28.  
    29.     QString announcement();
    30.  
    31.     void errorFromNetwork(int errnum, const QString &error);
    32.  
    33.     void connected();
    34.     void disconnected();
    35.  
    36.     /* message received from the server */
    37.     void printLine(const QString &line);
    38.     void printHtml(const QString &html);
    39.     void printChannelMessage(const QString &mess, int channel, bool html);
    40.  
    41.     /* sends what's in the line edit */
    42.     void sendText();
    43.     void playerLogin(const PlayerInfo &p, const QStringList &tiers);
    44.     void playerReceived(const PlayerInfo &p);
    45.     void announcementReceived(const QString &);
    46.     void tiersReceived(const QStringList &tiers);
    47.     void playerLogout(int);
    48.     void sendRegister();
    49.     void setReconnectPass(const QByteArray&);
    50.     void cleanData();
    51.     void onReconnectFailure(int reason);
    52.     /* removes the pointer to the challenge window when it is destroyed */
    53.     void clearChallenge();
    54.     /* Display the info for that player */
    55.     void seeInfo(int id, QString tier="");
    56.     void seeInfo(QTreeWidgetItem *it);
    57.     /* Challenge info by the server */
    58.     void challengeStuff(const ChallengeInfo &c);
    59.     /* Channels list */
    60.     void channelCommandReceived(int command, int channel, DataStream *stream);
    61.     void channelsListReceived(const QHash<qint32, QString> &channels);
    62.     void sortChannels();
    63.     void sortChannelsToggle(bool enabled);
    64.     void channelPlayers(int chanid, const QVector<qint32> &ids = QVector<qint32>());
    65.     void addChannel(const QString &name, int id);
    66.     void channelNameChanged(int id, const QString &name);
    67.     void removeChannel(int id);
    68.     void leaveChannelR(int index);
    69.     void leaveChannel(int id);
    70.     void activateChannel(const QString& text);
    71.     void join(const QString& text);
    72.     void itemJoin(QListWidgetItem *);
    73.     void lineJoin();
    74.     void firstChannelChanged(int tabindex);
    75.     void channelActivated(Channel *c);
    76.     void pingActivated(Channel *c);
    77.     void showChannelsContextMenu(const QPoint & point);
    78.     /* battle... */
    79.     void battleStarted(int battleid, int id, int id2, const TeamBattle &team, const BattleConfiguration &conf);
    80.     void battleStarted(int battleid, int id1, int id2);
    81.     void battleReceived(int battleid, int id1, int id2);
    82.     void battleFinished(int battleid, int res, int winner, int loser);
    83.     void battleCommand(int battleid, const QByteArray&command);
    84.     void saveBattleLogs(bool save);
    85.     void animateHpBar(bool animate);
    86.     void changeBattleLogFolder();
    87.     void openSoundConfig();
    88.     void forfeitBattle(int);
    89.     void watchBattleOf(int);
    90.     void watchBattleRequ(int);
    91.     void watchBattle(int battleId, const BattleConfiguration &conf);
    92.     void spectatingBattleMessage(int battleId, const QByteArray &command);
    93.     void stopWatching(int battleId);
    94.     void battleListActivated(QTreeWidgetItem* it);
    95.     void loadTeam();
    96.     /* A popup that asks for the pass */
    97.     void askForPass(const QByteArray &salt);
    98.     /* A popup that asks for a server pass */
    99.     void serverPass(const QByteArray &salt);
    100.     /* When someone is kicked, banned or temp banned */
    101.     void playerKicked(int,int);
    102.     void playerBanned(int,int);
    103.     void playerTempBanned(int dest, int src, int time);
    104.     /* When you kick someone */
    105.     void kick(int);
    106.     void ban(int);
    107.     void tempban(int, int);
    108.     void pmcp(QString);
    109.     /* PM */
    110.     void startPM(int);
    111.     void closePM(int);
    112.     void removePM(int id, const QString);
    113.     void PMReceived(int, const QString);
    114.     /* CP */
    115.     void controlPanel(int);
    116.     void setPlayer(const UserInfo &ui);
    117.     void requestBan(const QString &name);
    118.     void requestTempBan(const QString &name, int time);
    119.     /* Ranking */
    120.     void seeRanking(int);
    121.     /* Away... */
    122.     void awayChanged(int id, bool away);
    123.     void goAway(int away);
    124.     void goAwayB(bool away) {
    125.         goAway(away);
    126.     }
    127.     void changeButtonStyle(bool old);
    128.     void changeBattleWindow(bool old);
    129.     void changeNicknames(bool old);
    130.     void enableLadder(bool);
    131.     void sortPlayersByTiers(bool);
    132.     void sortPlayersByAuth(bool);
    133.     void setChannelSelected(int);
    134.     void enablePlayerEvents();
    135.     void disablePlayerEvents();
    136.     void deleteCustomEvents();
    137.     int getEventsForChannel(QString const& channel);
    138.     void showPlayerEvents(bool b, int event, QString option);
    139.     void showIdleEvents(bool);
    140.     void showBattleEvents(bool);
    141.     void showChannelEvents(bool);
    142.     void showTeamEvents(bool);
    143.     void toggleAutoJoin(bool autojoin);
    144.     void toggleDefaultChannel(bool def);
    145.     void showTimeStamps(bool);
    146.     void showTimeStamps2(bool);
    147.     void pmFlash(bool);
    148.     void toggleIncomingPM(bool);
    149.     void togglePMTabs(bool);
    150.     void togglePMLogs(bool);
    151.     void movePlayerList(bool);
    152.     void ignoreServerVersion(bool);
    153.     void versionDiff(const ProtocolVersion &v, int level);
    154.     void serverNameReceived(const QString &sName);
    155.     void tierListReceived(const QByteArray &array);
    156.     void changeTier();
    157.     void openBattleFinder();
    158.     void findBattle(const FindBattleData&);
    159.     /* Ignored */
    160.     void removeIgnore(int);
    161.     void ignore(int);
    162.     void ignore(int, bool);
    163.     /* Teambuilder slots */
    164.     void openTeamBuilder();
    165.     void reloadTeamBuilderBar();
    166.     void changeTeam();
    167.     void changeTeam(const TeamHolder &t);
    168.     /* Automatic removal of players in memory */
    169.     void fadeAway();
    170.     void registerPermPlayer(int id);
    171.     QStringList const& eventSettings() const;
    172.  
    173. signals:
    174.     void done();
    175.     void userInfoReceived(const UserInfo &ui);
    176.     void tierListFormed(const QStringList &tiers);
    177.     void PMDisabled(bool value, int starterAuth);
    178.     void togglePMs(bool value);
    179.     void PMDisconnected(bool disconnected);
    180.     void titleChanged();
    181.  

    Signals are special. Client emits them when something happens , and you can do client.togglePMs.connect(function(isToggled) {...} ), that will trigger the function when a certain PM option is toggled (I don't remember which one).

    It's not very useful for the client, but for the network interface it may be better.

    You can access it doing network = client.network();

    Network interface function:
    Code (javascript):
    1.  
    2.     /* slots called by the network */
    3.     void error();
    4.     void wasConnected();
    5.     void commandReceived (const QByteArray &command);
    6.  
    7.     /* by a channel */
    8.     void channelCommand(int command, int channelid, const QByteArray &body);
    9.  
    10.     /* by the battle window */
    11.     void battleCommand(int, const BattleChoice &comm);
    12.     void battleMessage(int, const QString &mess);
    13.  
    14.     /* By the pm window */
    15.     void sendPM(int id, const QString &mess);
    16.  
    17.     /* By the control panel */
    18.     void getUserInfo(const QString &name);
    19.     void getBanList();
    20.     void CPUnban(const QString &name);
    21.     /* By the rankings window */
    22.     void getRanking(const QString &tier, const QString &name);
    23.     void getRanking(const QString &tier, int page);
    24.  
    25.     /* By the challenge window */
    26.     void sendChallengeStuff(const ChallengeInfo &c);
    27.  
    28.     void sendChanMessage(int channelid, const QString &message);
    29.  
    30. signals:
    31.     /* to send to the network */
    32.     void sendCommand(const QByteArray &command);
    33.     /* to send to the client */
    34.     void connectionError(int errorNum, const QString &errorDesc);
    35.     void protocolError(int errorNum, const QString &errorDesc);
    36.     void connected();
    37.     void disconnected();
    38.     /* Message to appear in all the mainchats */
    39.     void messageReceived(const QString &mess);
    40.     void htmlMessageReceived(const QString &mess);
    41.     void channelMessageReceived(const QString &mess, int channel, bool html);
    42.     /* Command specific to a channel */
    43.     void channelCommandReceived(int command, int channel, DataStream *stream);
    44.     /* player from the players list */
    45.     void playerReceived(const PlayerInfo &p);
    46.     /* login of a player */
    47.     void playerLogin(const PlayerInfo &p, const QStringList& tiers);
    48.     void teamApproved(const QStringList &tiers);
    49.     /* logout... */
    50.     void playerLogout(int id);
    51.     /* challengerelated */
    52.     void challengeStuff(const ChallengeInfo &c);
    53.     /* battle including self */
    54.     void battleStarted(int battleid, int id1, int id2, const TeamBattle &myteam, const BattleConfiguration &conf);
    55.     /* battle of strangers */
    56.     void battleStarted(int battleid, int id1, int id2);
    57.     void battleFinished(int battleid, int res, int srcid, int destid);
    58.     void battleMessage(int battleid, const QByteArray &mess);
    59.     void spectatedBattle(int battleId, const BattleConfiguration &conf);
    60.     void spectatingBattleMessage(int battleId, const QByteArray &mess);
    61.     void spectatingBattleFinished(int battleId);
    62.     void passRequired(const QByteArray &salt);
    63.     void serverPassRequired(const QByteArray &salt);
    64.     void notRegistered(bool);
    65.     void playerKicked(int p, int src);
    66.     void playerBanned(int p, int src);
    67.     void playerTempBanned(int p, int src, int time);
    68.     void regAnnouncementReceived(const QString &announcement);
    69.     void serverReceived(const ServerInfo &info);
    70.     void PMReceived(int id, const QString &mess);
    71.     void awayChanged(int id, bool away);
    72.     void tierListReceived(const QByteArray &tl);
    73.     void announcement(const QString &announcement);
    74.     /* From the control panel */
    75.     void userInfoReceived(const UserInfo &ui);
    76.     void userAliasReceived(const QString &s);
    77.     void banListReceived(const QString &n, const QString &ip, const QDateTime &expires);
    78.     void versionDiff(const ProtocolVersion&, int level);
    79.  
    80.     void serverNameReceived(const QString &serverName);
    81.     /* Ranking */
    82.     void rankingStarted(int,int,int);
    83.     void rankingReceived(const QString&,int);
    84.     void channelsListReceived(const QHash<qint32, QString> &channels);
    85.     void channelPlayers(int chanid, const QVector<qint32> &channels);
    86.     void addChannel(QString name, int id);
    87.     void channelNameChanged(int id, const QString &name);
    88.     void removeChannel(int id);
    89.     void reconnectPassGiven(const QByteArray&);
    90.     void reconnectSuccess();
    91.     void reconnectFailure(int reason);
    92.  

    You see the network interface has a signal for everything it receives from the server, you can do for example client.network().addChannel.connect(function(name, id) { print ("A channel was created: " + name + " with id " + id);}).

    Sample simple script: (open sound config, spam somebody by PM, spams the main chat and displays tier list)

    Code (javascript):
    1.  
    2.  p, li { white-space: pre-wrap; }  ({
    3.  
    4.  
    5.  clientStartUp: function() {
    6.  // print("Start");
    7.  },
    8.  
    9.  
    10.  beforeSendMessage : function(msg, channel) {
    11.     if (msg == "reconnect") {
    12.        client.reconnect();
    13.        sys.stopEvent();
    14.        return;
    15.     }
    16.     if (msg == "~sound") {
    17.         client.openSoundConfig();
    18.         sys.stopEvent();
    19.     } else if (msg == ".") {
    20.         sys.stopEvent();
    21.         for (var i = 1; i < 4; i++) {
    22.             client.network().sendChanMessage(channel, "This is a script test -- " + i);
    23.         }
    24.     } else if (msg.substr(0, 4) == "~id ") {
    25.         print("Id of " + msg.substr(4) + ": " + client.id(msg.substr(4)) + ".");
    26.         sys.stopEvent();
    27.     } else if (msg.substr(0, 6) == "~spam ") {
    28.         sys.stopEvent();
    29.         var id = client.id(msg.substr(6));
    30.         for (var i = 0; i < 10; i++) {
    31.             client.network().sendPM(id, "This is a script test -- " + i);
    32.         }
    33.     } else if (msg == "~tiers") {
    34.         print("The tiers are: " + client.getTierList());
    35.         sys.stopEvent();
    36.     } else if (msg.substr(0, 6) == "~info ") {
    37.         sys.stopEvent();
    38.         var id = client.id(msg.substr(6));
    39.         print("Tiers of " + msg.substr(6) + ": " + client.tiers(id) + ".");
    40.     }
    41.  }
    42.  
    43.  
    44.  })
    45.  
    46.  
    Crystal moogle has more evolved scripts: https://github.com/CrystalMoogle/PO-User-Scripts
     
    Last edited by a moderator: Aug 24, 2012
  2. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
    Is there a way to get the channel list yet? :<

    The only thing I see remotely related is void channelsListReceived(const QHash<qint32, QString> &channels); But I don't think that does what I want :x
     
  3. MindFreak

    MindFreak Member

    Joined:
    Jun 23, 2012
    Messages:
    32
    Likes Received:
    0
  4. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    Actually that would, if not for some qt bug...

    Looks like a client function needs to be added (like Q_INVOKABLE QHash<qint32, QString> channelNames() const {return m_channelNames;} )
     
  5. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
    Right, when I tried using channelsListReceived I only got undefined values from it :x

    They shouldn't crash a server since they are client scripts...
     
  6. MindFreak

    MindFreak Member

    Joined:
    Jun 23, 2012
    Messages:
    32
    Likes Received:
    0
    naw i put another scripts and there is no problem.. for the moment..
     
  7. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    For next update:

    client.channelNames(), client.channelId(), client.channelName() added

    client.channel(), and channel object has those functions:
    [secret]
    Code (javascript):
    1.  
    2.     int id() const {
    3.         return myid;
    4.     }
    5.     void setId(int id);
    6.  
    7.     int ownId() const;
    8.     QString name() const {
    9.         return myname;
    10.     }
    11.     bool hasPlayer(int player) const {
    12.         return ownPlayers.contains(player);
    13.     }
    14.     bool hasRemoteKnowledgeOf(int player) const;
    15.     void sortAllPlayersByTier();
    16.     void sortAllPlayersNormally();
    17.     void addEvent(int event);
    18.     void removeEvent(int event);
    19.     bool eventEnabled(int event);
    20.     void resetEvents();
    21.     void restoreEventSettings();
    22.     void makeReadyToQuit() {
    23.         readyToQuit = true;
    24.     }
    25.     bool isReadyToQuit() const {
    26.         return readyToQuit;
    27.     }
    28.     QString addChannelLinks(const QString &line);
    29.     void checkFlash(const QString &haystack, const QString &needle);
    30.     void printLine(const QString &str, bool flashing = true, bool act=true);
    31.     void printHtml(const QString &str, bool act = true);
    32.  
    33. signals:
    34.     void quitChannel(int chanid);
    35.     void battleReceived2(int battleid, int id1, int id2);
    36.     void activated(Channel *c);
    37.     void pactivated(Channel *c);
    [/secret]
     
  8. Wanderer M

    Wanderer M Dancer

    Joined:
    Sep 14, 2011
    Messages:
    36
    Likes Received:
    0
    PO Trainer Name:
    Wanderer M
    Can't you make the client scripts go into a file just like the server scripts?
    It would be way easier to script with Notepad++ instead of the Client Scripting window.
     
  9. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    They are in a file, in your appdata folder. %APPDATA%/Dreambelievers/Pokemon-Online/Scripts/scripts.js

    Just make sure to keep the script window closed when editing scripts with notepad.
     
    Wanderer M likes this.
  10. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    %APPDATA/%LOCAL%/Dreambelievers/etc.
     
  11. Donkey

    Donkey Banned

    Joined:
    Jun 30, 2011
    Messages:
    251
    Likes Received:
    0
    I'm not really sure how to use this: void channelPlayers(int chanid, const QVector<qint32> &channels);

    I want an array containing all of the players in a channel, but I seem to be getting undefined values and I think I'm using it wrong...can someone post working code that gets all the players in a channel? Thanks.
     
  12. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    I'm afraid you're going to go through all the players and do channel.hasPlayer(playerId)
     
  13. Donkey

    Donkey Banned

    Joined:
    Jun 30, 2011
    Messages:
    251
    Likes Received:
    0
    How exactly do I go through all the players?
     
  14. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    By using beforePlayerReceived and beforePlayerRemoved you can keep a list of players updated. I know it's not ideal, but you're free to improve the scripting plugin :x
     
  15. Donkey

    Donkey Banned

    Joined:
    Jun 30, 2011
    Messages:
    251
    Likes Received:
    0
    ha, I'll let you handle that. Thanks!
     
  16. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
    Hmm, is it possible to get an event that activates as you're getting a challenge?
    So that you could auto-refuse challenges or something.

    Personally I don't really care about it, idle works for me, but apparently, people don't like going idle to stop challenges and would prefer a separate way of stopping challenges. If the answer's no, then that's fine :x. It's nothing important.
     
  17. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    you can do

    client.network().challengeStuff.disconnect(client.challengeStuff);

    will ignore all challenges (the poor challengers won't see a refuse message though :()
     
  18. Arceus

    Arceus Member

    Joined:
    May 20, 2010
    Messages:
    238
    Likes Received:
    0
    Use the beforeChallengeIssued event.
     
  19. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
    It doesn't exist in client scripts.

    Ok, but I think I'll just leave it. It's better with a message. People will have to deal with idle~
     
  20. Aerith

    Aerith Banned

    Joined:
    Jan 6, 2011
    Messages:
    354
    Likes Received:
    1
    stepEvent() doesn't work, I had to use step() for some reason to get it working

    unless stepEvent() does something different
     
  21. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
  22. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    It's step on the server, hence it is/was step on the client..
     
  23. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Sorry for the double post - but can there be an event added that is called when a cp window is opened? Such as void onControlPanel(const QString &name)

    With it, the scripts can do client.network.getUserInfo(name) and client.network.getBanList() (the user doesn't have to refresh the banlist or click on search, then)
     
  24. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    You can use network.getUserInfo() and getBanList() already and connect them into your own callbacks.
     
  25. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    I know, but there's no event to use them when a cp opened.
     
  26. [ƦЄ]Blade

    [ƦЄ]Blade Not sure.

    Joined:
    Mar 6, 2011
    Messages:
    75
    Likes Received:
    0
    You mean
    Code (javascript):
    1. QScriptValue abilityNum(const QString &ability);
    :cool:
     
  27. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
    This was asked for before, but I don't think anything happened with it... but would it be possible to get a changeName function for client scripts?
    Changes the name in the same way a profile change would, unlike sys.changeName() which is more of a "mask" I guess.

    Don't know if it's possible, but I'd like it :x
     
  28. Ethan

    Ethan Member

    Joined:
    Nov 6, 2011
    Messages:
    238
    Likes Received:
    0
    Definitely possible. I'll look into it.

    Done
     
    Last edited: Aug 21, 2012
  29. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
    I've been looking and I'm coming up blank, but is there anyway to catch a PM you send to a player?

    Client Scripts need love too ;_;
     
    Last edited by a moderator: Apr 4, 2014
  30. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    None yet.

    Can there be an event for global messages (messages sent to every channel). before/afterChannelMessage doesn't catch them...
     
    Last edited: Sep 1, 2012
  31. Yttrium

    Yttrium Well-Known Member Developer Developer

    Joined:
    Sep 29, 2010
    Messages:
    618
    Likes Received:
    280
    PO Trainer Name:
    Yttrium
    client.network().messageReceived.connect works for that...
     
  32. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
  33. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Wouldn't that make it call ChannelMessage for every channel?
     
  34. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
    Yes, which is what I was aiming for, though I was debating whether or not it would be better in the end to just do it for global messages.
     
  35. Yttrium

    Yttrium Well-Known Member Developer Developer

    Joined:
    Sep 29, 2010
    Messages:
    618
    Likes Received:
    280
    PO Trainer Name:
    Yttrium
    How would one use client.findBattle? :x
     
  36. Lamperi

    Lamperi I see what you did there

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

    No way to use it unless the special data type FindBattleData is implemented in Javascript bindings (With C++ code).
     
  37. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Can this be updated with the new functions?
     
  38. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
    I'm gonna make a post with all the new script functions (server too) and post it in the stickied thread, but I'll update this one too with client ones.
     
  39. Spheal

    Spheal New Member

    Joined:
    Dec 7, 2012
    Messages:
    2
    Likes Received:
    0
    Where would you put "client.network().addChannel.connect(function(name, id) { print ("A channel was created: " + name + " with id " + id);})"? for it to work .
     
  40. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    167
    anywhere... Put it before the ({}) of the script.