1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Internal Server Error, Please help

Discussion in 'Development' started by MulkiGT, Jun 5, 2020.

  1. MulkiGT

    MulkiGT Silverfish

    Messages:
    18
    GitHub:
    babosapple
    so i was make an UI Plugin, but something went wrong. So when player click on one of the button they got kicked and got "Internal Server Error" Message
    Here's my Code: https://pastebin.com/tqxMrtWH (Sorry i use pastebin instend cuz i dont know how to wrote code menu)
    And heres i got this error message in my console: "Argument 1 passed to MulkiAqi192\ChatCotmine\Player given, called in C:\Users\asus\Desktop\PM\plugins\ChatColors\src\MulkiAqi19 line 62"
    i dont know how to fix this cuz am new PHP Programmer, i will appreciate it if someone want to help me ;)
    Sorry for my bad english
     
    Last edited: Jun 5, 2020
  2. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    you have a capital A in setDisplayNAme
     
  3. MulkiGT

    MulkiGT Silverfish

    Messages:
    18
    GitHub:
    babosapple
    i fixed that but then when i clicked at Yellow button i got another error:
    "Argument 1 passed to MulkiAqi192\ChatColors\main onChatYellow() must be an instance of pocketmine\event\player\PlayerChatEvent, instance of pocketmine\Player given, called in C:\Users\asus\Desktop\PM\plugins\ChatColors\src\MulkiAqi192\ChatColors\Main.php on line 52" (EXCEPTION) in "plugins/ChatColors/src/MulkiAqi192/ChatColors/Main" at line 69"
     
    Last edited: Jun 5, 2020
  4. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    of course you will.. what are you trying to achieve here anyway?
     
  5. MulkiGT

    MulkiGT Silverfish

    Messages:
    18
    GitHub:
    babosapple
    i want to change player Format when they click one of the UI button...
    and can you explain whats the error mean please?
     
    Last edited: Jun 5, 2020
  6. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    onChatYellow() must be an instance of pocketmine\event\player\PlayerChatEvent, instance of pocketmine\Player given. exactly what the error says.. your onChatYellow parameter is asking for PlayerChatEvent, but you are giving Player
     
  7. MulkiGT

    MulkiGT Silverfish

    Messages:
    18
    GitHub:
    babosapple
    Ok thank you i think its hard to make this plugin (for me) xD
    i will mark this as Solved now thank you :)
     
    Last edited: Jun 5, 2020
  8. MulkiGT

    MulkiGT Silverfish

    Messages:
    18
    GitHub:
    babosapple
    oh btw if i'm not brothering you, can you tell me how to give PlayerChatEvent to the onChatYellow? cuz i have no idea how to change Player to PlayerChatEvent
     
    Last edited: Jun 5, 2020
  9. MulkiGT

    MulkiGT Silverfish

    Messages:
    18
    GitHub:
    babosapple
    or anyone if you want to help me with this problem hehe
    am still doing research for the problem, but i will appreciate if you help me in here :)
     
  10. MulkiGT

    MulkiGT Silverfish

    Messages:
    18
    GitHub:
    babosapple
  11. Mohagames205

    Mohagames205 Spider Jockey

    Messages:
    26
    GitHub:
    mohagames205
    No that's not how it works. The methods you use are listening for events, so the methods/functions will be called whenever a play chats. (this only happens if you registered a listener).

    To achieve what you want, you would need to save the chatcolor preference of the player in a database, file or array. When the player chats the PlayerChatEvent will be triggered automatically. In that method you can execute whatever code you want it to execute when a player chats.

    PHP:
    // This will trigger whenever the player chats.

    public function onChat(PlayerChatEvent $e)
    {
         
    $e->sendMessage("You have sent a message");   
    }
     
  12. MulkiGT

    MulkiGT Silverfish

    Messages:
    18
    GitHub:
    babosapple
    ohh i see, how do i make the player database?
     
  13. MulkiGT

    MulkiGT Silverfish

    Messages:
    18
    GitHub:
    babosapple
    ok i fixed my problem by myself hehe
    for someone in the future if you're begginer proggramer like me and you have the same problem, the error said you put the wrong member or function something like that. Instend you need to use array & database to save player by doing the command
    PHP:
    public red = [];
    and then you need to add player to the array when player excute the command
    PHP:
     $sendername $sender->getName();
       
    $this->red[$sendername] = $sendername;
    and then check the player if the player is registered in the array
    PHP:
    if(isset($this->red[$player->getName()])){
                
    $event->setMessage("§c" $msg);
            }
    and done UwU, thank you @Mohagames205 & @Levi for helping me
     
    Seeker and Levi like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.