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

Error help

Comments in 'Plugin Development' started by CaptainKenji17, Oct 18, 2015.

  1. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    [.PHP]<?php
    namespace PEMapModder\LocalVote;
    use pocketmine\command\CommandSender;
    use pocketmine\command\Command;
    use pocketmine\event\Listener;
    use pocketmine\plugin\PluginBase;
    class Main extends PluginBase{
    public $currentSessions = [];
    public function onEnable(){
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new CheckTask($this), 10, 10);
    }
    public function onCommand(CommandSender $issuer, Command $cmd, $label, array $params){
    $yes = false;
    switch($cmd->getName()){
    case "votestart":
    $src = $issuer->getName();
    if(!isset($params[0])){
    $duration = 60;
    }else{
    $duration = (int) (((float) array_shift($params)) * 60);
    if(count($params) === 0){
    $q = "Do you like this server?";
    }else{
    $q = implode(" ", $params);
    }
    $ses = new VoteSession($src, $q, $duration);
    $this->currentSessions[$ses->id] = $ses;
    $this->getServer()->broadcastMessage("$src started a vote: " . $q . "\nType /yes $ses->id for yes, /no $ses->id for no");
    break;
    case "yes":
    $yes = true;
    case "no":
    if(!isset($params[0])){
    return false;
    }
    $id = (int) array_shift($params);
    if(!isset($this->currentSessions[$id])){
    $issuer->sendMessage("Vote #$id does not exist!");
    return true;
    }
    $this->currentSession[$id]->results[strtolower($issuer->getName())] = $yes;
    $issuer->sendMessage("You have voted " . ($yes ? "yes":"no") . ".");
    break;
    }
    return false;
    }
    }[/.PHP]
    Code:
    Error: syntax error, unexpected 'case' (T_CASE)
    File: /VoteLOcal.phar/src/PEMapModder/LocalVote/Main
    Line: 31
    Type: E_PARSE
    
    THIS CRASH WAS CAUSED BY A PLUGIN
    
    Code:
    [22]         if(count($params) === 0){
    [23]           $q = "Do you like this server?";
    [24]         }else{
    [25]           $q = implode(" ", $params);
    [26]         }
    [27]         $ses = new VoteSession($src, $q, $duration);
    [28]         $this->currentSessions[$ses->id] = $ses;
    [29]         $this->getServer()->broadcastMessage("$src started a vote: " . $q . "\nType /yes $ses->id for yes, /no $ses->id for no");
    [30]         break;
    [31]       case "yes":
    [32]         $yes = true;
    [33]       case "no":
    [34]         if(!isset($params[0])){
    [35]           return false;
    [36]         }
    [37]         $id = (int) array_shift($params);
    [38]         if(!isset($this->currentSessions[$id])){
    [39]           $issuer->sendMessage("Vote #$id does not exist!");
    [40]           return true;
    [41]         }

    link: https://github.com/CaptainKenji17/LocalVote
    Last edited: Oct 18, 2015
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    can you edit it and put it on a [.php] bracket?
    so i can at least see the code without +line breaks
  3. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    I Don't know how
  4. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Created pull request.
  5. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    thank you, now theres a bug i cnt type /yes /no cn u fix it and remove the set timing and make it default to 1min?
  6. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    You can.. but you didn't do
    PHP:
    break;
    in the end of "Yes" case and the "No" case and
    PHP:
    return true
    in the end of "Yes"
    CaptainKenji17 likes this.
  7. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    PHP:
    return true
    in the end of "Yes"[/QUOTE] I dont know this


    never mind m8
  8. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Created another important pull request.
    CaptainKenji17 likes this.
  9. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    It has to be in the END
  10. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    another pull is coming..
  11. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    m8 this is not my plugin so idek, can you fix it? and changse some things like make a v0te and its 1 minute as default u dont need to type how many minute like just like this /vs Do you like taha? not /vs 1 adadawd thing, and make it not allow to create a vote while a vote is running
  12. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    I saw your reply saying u dont understand what i wanted it to be, and I dont know how to reply you there so here I will tell you some clearly kenji's speech

    [The current LocalVote]
    /vs = start a vote
    /vs {time} {your vote text}

    and itll say

    $src has started a vote: your vote text
    type /yes 1 if yes, type /no 1 if no

    since it didnt worked I dont know what happened next

    [What I wanted it to be]
    /vs {your vote text} (Remove {time} and set it default in 1 minute)

    so itll be
    $src has started a vote : {Your vote text}
    type /yes if yes, type /no if no (remove the $id just make it directly /yes, /no)

    once a vote is running and someone started a vote
    ''cant vote right now, please wait until a vote is done"

    and on end

    Vote by $src: {your vote text} has ended

    /yes = {count of the humans did /yes}
    /no = {count of humands did /no}

    you can only vote once a vote and itll say
    voted yes if you did /yes
  13. ItsMegaMCPE
    Offline

    ItsMegaMCPE New Member

    Joined:
    Aug 2, 2015
    Posts:
    5
    Minecraft User:
    MegaOS

Share This Page

Advertisement