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

Search for Word in Message

Comments in 'Plugin Development' started by CraftYourBukkit, Jun 4, 2015.

  1. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Hey, I want to search for a word in a Message(PlayerChatEvent) but I don't know how. I would have done something like
    PHP:
    if(str_contain("Hey")){}
    but that doesn't exist. Do you have a way to do it?

    EDIT: Found a way :)
    Last edited: Jun 4, 2015
  2. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    So what is way? Pls
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    // This is in PlayerChatEvent, so 
    $message $event->getMessage();
    $word1 "hey";
                
    $search strpos($message$word1);

                if (
    $search === false) {
                    
    // Word $word1 not found in $message
                
    } else {
                    
    // Word found in $message, the Position of it is $search
                
    }
    PEMapModder and HotFireyDeath like this.
  4. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    981
    Plugins:
    9
    Look through the PHP manual here: php.net
  5. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Why? I found this way so why should I search for others?
  6. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Creeperface likes this.
  8. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Why everybody says"learn php" when anybody is looking for help? Pls.
  9. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Because if you learn php you won't have to ask here all the time.
  10. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    But it's about the API :D
    TheKofola12 likes this.
  11. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Exactly...
    This is a forum for get help, but the 90% of times you only get people saying "Learn PHP".
    CrazedMiner and Taha_The_Hacker like this.
  12. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    yes, @shoghicp translated PHP bin file, so we don't think everything about PHP is there. somethings changed, like when he told us don't do ?> (PHP close tag) with the API.
    TheKofola12 likes this.
  13. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    strpos is a PHP function, not PM API.
    Because it is true :p
    Trivia: I never said that before. ^_^
    PM is mostly OOP, so learning for web development won't work.
    PEMapModder likes this.
  14. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    981
    Plugins:
    9
    See? You can't even tell the difference between PHP and the PocketMine API.
  15. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    I don't mean stripos
    TheKofola12 likes this.
  16. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Does the API have its own language?, No. So learn PHP before learning the API or you won't understand the API. ;)
  17. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Because most of the time the person asking for help has little to no PHP knowledge.
  18. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Can we stop arguing about this and stop telling people to learn PHP, if you came to the forums looking for help and all you got was "Go learn PHP and the PocketMine API" you would be pretty pissed.
    Legoboy0215 likes this.
  19. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    I wasn't though, since that is the truth. Just abusing it is annoying though :D
  20. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Yes it is annoying when people spam it for no reason. I used to get annoyed by it too.
    But if @PEMapModder and @Gamecrafter hadn't tell me to "Learn PHP" and provided links to my problems I wouldnt know some of the stuff i know today
    Taha_The_Hacker likes this.

Share This Page

Advertisement