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

Help, error

Comments in 'Plugin Development' started by Skullex, Mar 1, 2016.

  1. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    Is there another way to do this??

    PHP:
    $this->event $event;
    $this->entity $entity;
    $this->entity null;
    If you would like to see my entire code just ask :)
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    What?
    first what how to do 'this' do you think that you included your question on the title?
    second WHAT ERROR?
    third what do you mean by that global var?
  3. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    please describe more about your question
    Skullex likes this.
  4. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    @Skullex we can help you so much send the code... and the error code... but with 3 variables we can't help you much
    Skullex likes this.
  5. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    PHP:
    <?php

    namespace SHE\SpecialHitEvents;


    use 
    pocketmine\event\entity\EntityDamageByEntityEvent/*
    The only real needed event, but I'll be adding more.. maybe 'not making any promises'
    */


    use pocketmine\event\Listener;


    use 
    pocketmine\plugin\PluginBase;


    use 
    pocketmine\utils\TextFormat as Color;


    use 
    pocketmine\level\particle\ExplodeParticle;


    use 
    pocketmine\level\particle\FloatingTextParticle



    class 
    HitEvents extends PluginBase implements Listener {

        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
       
    /*    $this->event = $event;
        $this->entity = $entity;
        $this->entity = null;
    */
        
    public function onDamage(EntityDamageByEntityEvent event){
            
    $event->getEntity->getLevel()->addParticle(new ExplodeParticle($this->entity->add(0.1 mt_rand(19) * mt_rand(-11), 0.1 mt_rand(59), 0.1 mt_rand(1,9) * mt_rand(-11)), Color::YELLOW "SMACK"));
            
    $event->getEntity->getLevel()->addParticle(new DustParticle($this->entity->add(mt_rand(-33), mt_rand(-33), mt_rand(-33)), 21116180255));
        }

        public function 
    onDisable(){
            
    $this->getLogger()->info("SpecialHitEvents has been successfully Disabled!");
            return 
    true;
        }
    }
  6. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    I used that in my code and I got an error. I'll list the error in a separate post
  7. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    its out of the function Learn PHP and give us error
    Last edited: Mar 1, 2016
  8. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    If I didn't know php this wouldn't be here, hush.

    The error
    Code:
    PHP Parse error: syntax error, unexpected '$this' (T_VARIABLE), expecting function (T_FUNCTION) in /var/www/tmp/5/SpecialHitEvents/src/SHE/SpecialHitEvents.php on line 33
    Errors parsing /var/www/tmp/5/SpecialHitEvents/src/SHE/SpecialHitEvents.php
    
  9. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    What I want to know is a better way I could use this. Apparently that doesn't work
  10. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    do it on a function, not outside of a function AND inside a class.
    Skullex likes this.
  11. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    Thank you
  12. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    @Skullex or you define it in 1 function and makes public $blabla;
    Skullex likes this.

Share This Page

Advertisement