/announcement (CPE Required For Clients)

/announcement (CPE Required For Clients)

Postby AFK_Games » 17 Jul 2014, 19:01

This code only works with versions of classicube that support CPE MessageTypes, enjoy:

Code: Select all
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;

namespace MCDzienny
{
    public class CmdAnnouncement: Command
    {
        public override string name { get { return "announcement"; } }
        public override string shortcut { get { return "an"; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
        public override void Use(Player p, string message)
        {
            Player.players.ForEachSync(pl =>
            {
                if (pl.Cpe.MessageTypes == 1)
                {
                    pl.SendMessage(Cpe.V1.Announcement, message);
                    return;
                }
                else
                {
                    Player.SendMessage(p, "Player's client does not support CPE MessageTypes.");
                }
            });
           
        }
       
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/announcement - Generate a global server announcement.");
        }
    }
}
AFK_Games
 
Posts: 21
Joined: 11 Apr 2014, 21:19

Re: /announcement (CPE Required For Clients)

Postby Leeizazombie » 19 Jul 2014, 07:14

Not bad <ok>

By the way when you use:
Code: Select all
else
                {
                    Player.SendMessage(p, "Player's client does not support CPE MessageTypes.");
                }

There's no real need to send that message to every other user is there? I mean it would cause confusion! :P

Also there's no need to use a return statement inside an if > else block, because even if the player supports CPE, he/she will not receive the message from the else block because that part was not returned true.
Owner of:
LeeIzaZombie Freebuild and Lava Survival V2 (Shut Down and updated)
LeeIzaZombie Survival (Comming back soon)

Contact:
Skype: leeizazombie
IRC: irc.geekshed.net, #leeizazombie, #mcclassichosting
User avatar
Leeizazombie
 
Posts: 536
Joined: 10 Jun 2013, 17:45
Location: Ireland.

Re: /announcement (CPE Required For Clients)

Postby AFK_Games » 01 Aug 2014, 14:27

Sorry, I made 1 mistake with the command at the start, and to cheer lee up I have fixed the else part :D

Code: Select all
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;

namespace MCDzienny
{
    public class CmdAnnouncement : Command
    {
        public override string name { get { return "announcement"; } }
        public override string shortcut { get { return "an"; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
        public override void Use(Player p, string message)
        {
            Player.players.ForEachSync(pl =>
            {
                if (pl.Cpe.MessageTypes == 1)
                {
                    pl.SendMessage(Cpe.V1.Announcement, message);
                    return;
                }
            });
           
        }
       
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/announcement - Generate a global server announcement.");
        }
    }
}
AFK_Games
 
Posts: 21
Joined: 11 Apr 2014, 21:19

Re: /announcement (CPE Required For Clients)

Postby HETAL » 02 Aug 2014, 18:13

@LeeIzaZombie He didn't send it to all players, he foreached pl but used p when sending the message..
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: /announcement (CPE Required For Clients)

Postby _Retaliate_ » 03 Aug 2014, 08:03

So basically it would spam whoever used the command every time the command found someone who didn't support cpe
Image
_Retaliate_
 
Posts: 68
Joined: 26 Sep 2013, 11:16

Re: /announcement (CPE Required For Clients)

Postby AndrewPH » 25 Aug 2014, 03:30

It's also worth noting that the announcement messages are one of the few CPE things that can be sent to people who don't have CPE.

It'll just show up as a normal message if they don't support the extension.
AndrewPH
 
Posts: 4
Joined: 29 Sep 2013, 19:56


Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 2 guests

cron