Need help

Need help

Postby tinyCreeper » 10 Jul 2013, 23:04

Ok so I'm trying to code a command a disinfect command, and I don't want it to be able to be used on someone who is already a human. Would the command to check that be

Code: Select all
if (!who.isHuman)



?
tinyCreeper
 
Posts: 48
Joined: 05 Jul 2013, 12:21

Re: Need help

Postby HETAL » 10 Jul 2013, 23:14

Code: Select all
/*
    Copyright 2011 MCForge
      
   Dual-licensed under the   Educational Community License, Version 2.0 and
   the GNU General Public License, Version 3 (the "Licenses"); you may
   not use this file except in compliance with the Licenses. You may
   obtain a copy of the Licenses at
   
   http://www.opensource.org/licenses/ecl2.php
   http://www.gnu.org/licenses/gpl-3.0.html
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the Licenses are distributed on an "AS IS"
   BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
   or implied. See the Licenses for the specific language governing
   permissions and limitations under the Licenses.
*/
namespace MCForge.Commands
{
    /// <summary>
    /// This is the command /disinfect
    /// use /help disinfect in-game for more info
    /// </summary>
    public sealed class CmdDisInfect : Command
    {
        public override string name { get { return "disinfect"; } }
        public override string shortcut { get { return "di"; } }
        public override string type { get { return "game"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
        public CmdDisInfect() { }
        public override void Use(Player p, string message)
        {
            Player who = null;
            if (message == "") { who = p; message = p.name; } else { who = Player.Find(message); }
            if (!who.infected || !Server.zombie.GameInProgess())
            {
                p.SendMessage("Cannot disinfect player");
            }
            else
            {
                if (!who.referee)
                {
                    Server.zombie.DisinfectPlayer(who);
                    Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " just got Disnfected!");
                }
            }
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/disinfect [name] - disinfects [name]");
        }
    }
}
that's the mcforge version it won't compile but it might help I don't know if its if (!who.isHuman) for mcdzienny
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: Need help

Postby tinyCreeper » 10 Jul 2013, 23:16

I need a check to see if someone is a human, I don't see one in that cmd.
The cmd I have now works fine but if you disinfect someone who is a human already, it still works and there will be 2 of the same person when you type /humans. I'm just trying to add a check so that it won't work when the person is a human already.
Last edited by tinyCreeper on 10 Jul 2013, 23:21, edited 1 time in total.
tinyCreeper
 
Posts: 48
Joined: 05 Jul 2013, 12:21

Re: Need help

Postby HETAL » 10 Jul 2013, 23:20

Says it like this
Code: Select all
if (!who.infected || !Server.zombie.GameInProgess())
try this its for mcforge though
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: Need help

Postby ismellike » 10 Jul 2013, 23:21

The mcdzienny version is actually who.isZombie
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: Need help

Postby tinyCreeper » 10 Jul 2013, 23:23

But there is no check for human or would you do !who.isZombie?
Last edited by tinyCreeper on 10 Jul 2013, 23:26, edited 1 time in total.
tinyCreeper
 
Posts: 48
Joined: 05 Jul 2013, 12:21

Re: Need help

Postby HETAL » 10 Jul 2013, 23:26

Could be
Code: Select all
who.isZombie=false
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: Need help

Postby tinyCreeper » 10 Jul 2013, 23:32

Ok I got it! its

Code: Select all
!who.isZombie


Thanks ismellike.

I have another question though, if I wanted to make a check that the player being disinfected isn't the only zombie, thus leaving no zombies, how would I do that?
I had:

Code: Select all
(InfectionSystem.InfectionSystem.infected.Count <= 1)


but that didn't work.
tinyCreeper
 
Posts: 48
Joined: 05 Jul 2013, 12:21

Re: Need help

Postby tinyCreeper » 10 Jul 2013, 23:44

Wait, nvm I got it all, thanks everyone.
tinyCreeper
 
Posts: 48
Joined: 05 Jul 2013, 12:21


Return to Help in Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron