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

checking if the player has talked

Comments in 'Plugin Development' started by zombie_Power, Oct 31, 2015.

  1. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Greetings,

    I am little stuck. How would I check if the player has typed something? Packets?
    Sorry I am a little unsure


    Regards,
    ZP
  2. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Are you looking for PlayerChatEvent? PlayerCommandPreprocessEvent?
  3. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    PlayerChatEvent- I want to check it the player(s) has/have talked.
    Legoboy0215 likes this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    When a player talks, save the state into a database...

    (GIGO: you explain little about what you want, I will explain little too about what I know)
  5. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PlayerChatEvent is fired when a player talks(types something). Use it.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If you want to include typing commands and typing chat both, then use PlayerCommandPreprocessEvent.
  7. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    It should be named as PlayerChatPreprocess :p
  8. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    That is the question, how would I do it?
  9. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PHP:
    use pocketmine\event\player\PlayerChatEvent;

    Public function 
    onChat(PlayerChatEvent $event) {
      
    // Code to be executed
    }
  10. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    I do know that, I am unsure of how I would check it the player talked/ typed something
  11. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    The PlayerChatEvent is fired when a player types something. If you mean you want to check if the event is not cancelled then that would be:
    PHP:
    if($event->isCancelled() !== false)
    Otherwise im not sure what you mean.
  12. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    So lets say, if a player types something in a period of time, they wont receive the affects, however, if they don't, they will. ( I am really confused how to set it out)
  13. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Just check if the player talks during this period. Im not sure how u have the "period" setup but it wwould look something like this:
    PHP:
    public function onChat(PlayerChatEvent $event) {
    if(
    $periodIsEnabled) {
      
    // code to be excecuted if they talk during the period
      
    }
    }
    Thats all.
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Just add a tag
    PHP:
    /**
     * @ignoreCancelled true
     */
    Before the function declaration.
  15. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    I already created the task (still working on it).

    Anyways thanks for assistance.
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use an array class property that contains per-player information. Check that array in tasks.
  17. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    @Hotshot_9930 it is a private plugin:D

    it is basically a quiz-type plugin. The concept is that, when the player correctly answers the question, they receive special effects and rewards​

Share This Page

Advertisement