Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved NoDamageTicks

Comments in 'Plugin Development' started by ImagicalGamer, Mar 31, 2016.

  1. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    This isn't working, is my code wrong?
    PHP:
    $this->noDamageTicks 300;
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    What? It is never going to woek without you giving us the relevant code.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Because we have no idea what $this is and what you are doing with it?

    Edit: It works. Just this line alone, it has no problems.
    ImagicalGamer likes this.
  4. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    That is the relevant code, I was asking if I needed to do:
    PHP:
    $this->noDamageTicks => 300;
    or
    PHP:
    $this->noDamageTicks 300;
  5. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    Ok thanks.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    `=` is an assignment operator. Use `===` for comparison (`===` for strict comparison, `==` for less strict comparison).

    http://php.net/operators.assignment
    http://php.net/manual/en/language.operators.comparison.php

    As we assume that you understand PHP operators, it is reasonable for us to think that `$this->noDamageTicks = 300;` means to set `$this->noDamageTicks` to 300 rather than checking if it is equal. Please, explain more next time.

    And the greater/smaller-than-or-equal-to operators are `>=` and `<=`. `=>` is a completely different operator used for array initialization. http://php.net/manual/en/language.types.array.php#language.types.array.syntax
    Skullex and Legoboy0215 like this.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why are you adding semicolons behind these lines? If you do so, this means that you think that this line alone is a statement. However, `$this->noDamageTicks > 300` is only an expression, and this expression does not do anything alone. An expression is not a statement. (It can be a statement, but it will do nothing, so we don't call it a statement. Confused? Never mind)
    ImagicalGamer and Vaivez66 like this.
  8. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    Someone helping with the grace period on my SG repo added that, I was confused but went with it xD. I got it thanks, the ";" was a syntax error not meant to be there.
    Oneeb likes this.

Share This Page

Advertisement