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

Calling a custom function help

Comments in 'Plugin Development' started by Xfusionios, Jun 2, 2014.

  1. Xfusionios
    Offline

    Xfusionios Active Member Plugin Developer

    Joined:
    Aug 24, 2013
    Posts:
    67
    Plugins:
    2
    Minecraft User:
    XFusionios
    Ok so i made a function like so
    PHP:
    public function TestFunction() {
    console("Test");
    }
    But i dont know how to call the function i trie $this->TestFunction(); but it didn't work. Never done much with creating functions.
  2. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    The function itself looks fine to me. How are you calling it? With a command?
  3. Xfusionios
    Offline

    Xfusionios Active Member Plugin Developer

    Joined:
    Aug 24, 2013
    Posts:
    67
    Plugins:
    2
    Minecraft User:
    XFusionios
    Yes im calling it with a command.
  4. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    Hmm, looks fine to me. You're doing everything right from what I can see, I usually use functions to process info and output something. I'm no php pro but my functions usually have some sort of input or return something. @Falk , any suggestions?
  5. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    Post the whole code?
    PEMapModder and Tuff like this.
  6. Xfusionios
    Offline

    Xfusionios Active Member Plugin Developer

    Joined:
    Aug 24, 2013
    Posts:
    67
    Plugins:
    2
    Minecraft User:
    XFusionios
    Nvm i figured out what i did but does anyone know how to get the username of a player that just spawned?
  7. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    PHP:
    public function init(){
                
    $this->api->addHandler("player.join", array($this,"onJoin"));
    }

    public function 
    onJoin($p){
                
    $username $p->username;
    }
    Xfusionios likes this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use "player.spawn" for newly spawned.
    Xfusionios likes this.

Share This Page

Advertisement