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

Error syntax :/ Idk why..

Comments in 'Plugin Development' started by NycuRO, Apr 26, 2016.

  1. NycuRO
    Offline

    NycuRO Active Member

    Joined:
    Oct 19, 2015
    Posts:
    64
    Minecraft User:
    NycuRK
    PHP:
    <?php

    namespace nycuro\Spiral;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\level\particle\FlameParticle;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\event\Listener;

    class 
    Spiral extends PluginBase implements Listener {
       
        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getLogger()->info("SpiralParticle has been enabled.");
        }
       
        
    /*
        255,0,0,1 - Red
        0,255,0,1 - Green
        0,0,255,1 - Blue
        192,192,192,1 - Gray
        255,255,0,1 - Yellow
        255,0,255,1 - Magenta
        */
       
        
    public function onMove(PlayerMoveEvent $event) {
            
    $sender $event->getPlayer();
            
    $level $sender->getLevel();
            
    $x X;
            
    $y Y;
            
    $z Z;
            
    $radius 0.5;
            
    $count 100;
            
    $center = new Vector3($x$y$z);
            
    $particle = new DustParticle($centermt_rand(), mt_rand(), mt_rand(), mt_rand());
            for(
    $yaw 0$y $center->y$y $center->4$yaw += (M_PI 2) / 20$y += 20){
                
    $x = -sin($yaw) + $center->x;
                
    $z cos($yaw) + $center->z;
                
    $particle->setComponents($x$y$z);
                
    $level->addParticle($particle);
            }
        }
       
        public function 
    onDisable() {
            
    $this->getLogger()->info("SpiralParticle has been disabled.");
        }
       
    }
  2. NycuRO
    Offline

    NycuRO Active Member

    Joined:
    Oct 19, 2015
    Posts:
    64
    Minecraft User:
    NycuRK
    Error: syntax error, unexpected '$y ' (T_VARIABLE), expecting ';'
    File: /plugins/zip_Spiral_v1.0.0 CODE/src/nycuro/Spiral/Spiral
    Line: 37
    Type: E_PARSE

    THIS CRASH WAS CAUSED BY A PLUGIN
    此次出错由插件引起

    Code:
    [28] $sender = $event->getPlayer();
    [29] $level = $sender->getLevel();
    [30] $x = X;
    [31] $y = Y;
    [32] $z = Z;
    [33] $radius = 0.5;
    [34] $count = 100;
    [35] $center = new Vector3($x, $y, $z);
    [36] $particle = new DustParticle($center, mt_rand(), mt_rand(), mt_rand(), mt_rand());
    [37] for($yaw = 0, $y = $center->y; $y < $center->y + 4; $yaw += (M_PI * 2) / 20, $y += 1 / 20){
    [38] $x = -sin($yaw) + $center->x;
    [39] $z = cos($yaw) + $center->z;
    [40] $particle->setComponents($x, $y, $z);
    [41] $level->addParticle($particle);
    [42] }
    [43] }
    [44]
    [45] public function onDisable() {
    [46] $this->getLogger()->info("SpiralParticle has been disabled.");
    [47] }
  3. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    Learn PHP
  4. NycuRO
    Offline

    NycuRO Active Member

    Joined:
    Oct 19, 2015
    Posts:
    64
    Minecraft User:
    NycuRK
    Again error syntax în line 37..
  5. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    I guess you haven't learned PHP yet, have you?
  6. NycuRO
    Offline

    NycuRO Active Member

    Joined:
    Oct 19, 2015
    Posts:
    64
    Minecraft User:
    NycuRK
    Yes.. :( but Idk how fix this error .
    I always give over it.. :(
  7. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
    use pocketmine\level\particle\DustParticle;
    PHP:
    # fix some code
    public function onMove(PlayerMoveEvent $event) {
            
    $sender $event->getPlayer();
            
    $level $sender->getLevel();
            
    $x $sender->x;
            
    $y $sender->y;
            
    $z $sender->z;
            
    $center = new Vector3($x$y$z);
            
    $particle = new DustParticle($centermt_rand(1,255), mt_rand(1,255), mt_rand(1,255));
            for(
    $yaw 0$y $center->y$y $center->4$yaw += (M_PI 2) / 20$y += 20){
                
    $x = -sin($yaw) + $center->x;
                
    $z cos($yaw) + $center->z;
                
    $particle->setComponents($x$y$z);
                
    $level->addParticle($particle);
            }
        }
    Last edited: Apr 26, 2016
  8. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Well, that was one thing, but that doesn't fix the syntax error.(You also do not need the 1, 255 in mt_rand()..) @NycuRO, if you would have learned it, then you would know what the error means. Take a closer look at the specific line:
    PHP:
    for($yaw 0$y $center->y$y $center->4$yaw += (M_PI 2) / 20$y += 20){
    So, the error tells you: "unexpected '$y ' (T_VARIABLE), expecting ';'" -> "Yo, there's a '$y' even though I need a ';'!". What does that mean? Let's take a closer look.
    PHP:
    $yaw += (M_PI 2) / 20$y += 20
    This is the last expression in your for loop. But wait.. let's take a look at the place where it wants a ';', but there is a $y..
    PHP:
    20$y += 
    Ah, I think I found it! Why is there a ','? Have you learned for loops yet? If not, do that before you ask why this is not working! (This actually doesn't work anywhere).
    And please, do not tell me that I didn't help you. I am not the only person not giving you the whole correct code, but giving you hints on fixing it/finding the error. A 'real' developer does not ask for code, he asks for help, so he can fix the code.

    By the way, the same error is in that line a second time. (Search it yourself now.)
  9. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    I know iam donot fix all code iam fix some code
  10. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    You are lacking the ability to analyzing the error and debugging the code. It is very important in making plugins.
    Primus likes this.
  11. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Doesn't change the fact you gave him the code instead of helping
  12. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    Now now... every little thing helps :3
  13. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Giving the code does this:
    Guy replaces old code with new one
    Guy tests the new code
    If it doesn't work, he comes here and be like "Your code doesn't work you didn't help"
    If it works, he just says "thanks"

    The person won't read the code, which makes him not able to call the plugins his own ones, since he then only copies, copies and copies
  14. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
  15. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    Ok true. :) But still it helped
  16. NycuRO
    Offline

    NycuRO Active Member

    Joined:
    Oct 19, 2015
    Posts:
    64
    Minecraft User:
    NycuRK
    anymore, but I do not understand a thing . I want the pocketmine become increasingly better , right? Everyone to use it , right? well then developed it brother Calum . Why mcpe servers to be weaker than those of pc ? Because of you . A professional can help a loser, explaining . How's school . The teacher teaches the student . After the student becomes teacher. In my opinion , this would be an approach more.
    method of telling to look alone is a mistake, because it discourages . You can explain themselves. extra stop wasting time with Finder .
  17. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV


    [​IMG]
    Survingo and minebuilder0110 like this.
  18. NycuRO
    Offline

    NycuRO Active Member

    Joined:
    Oct 19, 2015
    Posts:
    64
    Minecraft User:
    NycuRK
    Yes,why not
  19. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    You HAVE to UNDERSTAND that once you go OFFLINE there won't be anyone to HELP you if you don't LEARN how to do it yourself RIGHT NOW!
  20. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110

Share This Page

Advertisement