Script Changes coming with the new update

Discussion in 'Server and Client Scripting' started by coyotte508, Aug 6, 2010.

  1. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    I have not yet starting updating the scripting module, but I have already done the channel system so i have a good idea of what's to come, and the update should be on sunday hopefully.

    Player Id Management

    Player ids will not be as small as possible anymore. Ids will gradually increase, meaning players will have unique IDs that no player after will have.

    That means that some scripts, like masskick, will have to be redone, that if you keep arrays over players, to save rams, you should delete the part in the array corresponding to a player when they log off, like so: delete array[playerid]. That also means that PA will be useless in the way they were useful before. For PAs,when a player logs off, their index in the PA is deleted.

    A scripting function, sys.playerIds(), will be added. It'll return an array containing the ids of all the players online. You can use this function in your sendall scripts, masskick ...

    Array Functions

    The function sys.getTierList() will now return an array. (because i discovered how to do so). If there are any other functions that should logically return an array, they'll do, but i don't remember any other at the moment.

    Channels

    Next update will have channels. A player can join up to 7 channels. For the moment, auth is per server and not per channel. When a player logs on, he'll automatically join the main channel. A player can join any channel, by creating it if necessary, and the channel will be destroyed when all players quit that channel.

    The main channel will always have the id 0, and will not be destroyed even if all players log off or switch to another channel.

    4 events will be added: channelJoin(playerid, channelid) and channelLeave(playerid, channelid), channelCreated(channelid, channelName, playerid), channelDestroyed(channelid, channelName). The join/create/destroy events will be stoppable, not the leave one. The playerId in the createEvent is for when a players joins a channel that doesn't exist (hence creating it), you have the id of the player who is creating the channel. When a player logs on, channelJoin will be called, even if this is on the main channel. When a player logs off, channelLeave will be called on all the channel the player is on.

    It is advised to allow the user to have at least one channel open at all times. Naturally, the server won't allow a user to leave a channel if it's the last channel open, but it's possible with scripts. If a user has no channel open, he has a blank screen replacing main chat, players list, and battles list, and it's not very nice.

    Channel functions to be added:

    • channelIds(): Returns the list of the id of the channels
    • channel(channelid): Returns the name of that channel
    • channelId(channelName)
    • channelsOfPlayer(playerId): List of the channel ids a player is on
    • playersOfChannel(channelid): List of the players a channel is on
    • kick(playerid, channelid)
    • putInChannel(playerid, channelid): Forces a player to join a channel. Will bypass the 7 channels limit
    • createChannel(channelName): creates an channel with that name. The channel won't be destroyed until one player logs on that channel and off when he's the only plyer online. Returns the id of the create channel
    • existChannel(channelName): returns true if a channel with that name exists
    • isInChannel(playerid, channelid)
    • isInSameChannel(player1, player2)
    beforeChatMessage and afterChatMessage will take a third argument telling the channel id the message was posted in. There's a possibility that in the future, the client could talk directly to the server not being in a channel, and then the id would be -1.

    sendMessage and sendAll will take an optional third argument giving the channelId. If the argument is not here, it will send a message to the user on all his channels, and sendAll on all the channels.

    --

    In short, apart from the getTierList() change, all scripts should still work, except that they wouldn't make a difference between channels.
     
    Last edited: Aug 8, 2010
  2. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Edited, so up.

    Also the new PA functions work wonder, if you want to avoid calling delete var[x] in the beforePlayerLogOut event, you should use it.
     
  3. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
  4. Lutra

    Lutra All Gen Battler/Scripter

    Joined:
    Apr 25, 2010
    Messages:
    509
    Likes Received:
    188
    PO Trainer Name:
    Lutra
    Has sys.webCall changed? resp doesn't seem to be storing anything with me.
     
  5. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    No, it shouldn't have...
     
  6. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Well it did. Uploaded a fixed server (with a few other fixes)