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

Solved Set full server msg ?

Comments in 'Plugin Development' started by Svile, Jul 29, 2015.

  1. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    I tried PlayerPreLoginEvent but do not work :/ if someone can help me ...
  2. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PlayerPreLoginEvent: before the Player has barely anything set up, just the username and some extremely primitive data
    PlayerLoginEvent: when things like player entity have been setup
    PlayerRespawnEvent: when spawnpoint is sent to the Player
    PlayerJoinEvent: when the Player has successfully joined and spawned.
    CrazedMiner, Falk, hoyinm14mc and 3 others like this.
  4. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    I need it to kick the player before the join so i can' t use the respawn event (is called also when a player die) ... How i said i have already tried to use the PlayerPreloginEvent and the PlayerLoginEvent but the server kick the player and after some seconds crash
    PHP:
    ErrorCall to a member function setHeldItemSlot() on null
    File
    : /src/pocketmine/Player__32bit
    Line
    1772
    Type
    E_ERROR

    Code
    :
    [
    1763]                 if($ev->isCancelled()){
    [
    1764]                     $this->close($this->getLeaveMessage(), $ev->getKickMessage());
    [
    1765]
    [
    1766]                     break;
    [
    1767]                 }
    [
    1768]
    [
    1769]                 if($this->isCreative()){
    [
    1770]                     $this->inventory->setHeldItemSlot(0);
    [
    1771]                 }else{
    [
    1772]                     $this->inventory->setHeldItemSlot(0);
    [
    1773]                 }
    [
    1774]
    [
    1775]                 $pk = new PlayStatusPacket();
    [
    1776]                 $pk->status PlayStatusPacket::LOGIN_SUCCESS;
    [
    1777]                 $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));
    [
    1778]
    [
    1779]                 if($this->spawnPosition === \null and isset($this->namedtag->SpawnLevel) and ($level $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level){
    [
    1780]                     $this->spawnPosition = new Position($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level);
    [
    1781]                 }
  5. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    crash report?

    and u can use the respawn event...
    u only have to set a array with playername by death and check it befor and if the players died do nothing... if (!isset($var[$name])
    Svile and iksaku like this.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Don't kick in PlayerPreLoginEvent. Cancel the event directly.
    CrazedMiner likes this.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
  8. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    I need to modify the server is full message ... And i don' t know how ... So i tried to kick a player on join when the server is full and set a reason . Custom Alerts don' t work :/
  9. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    is possibile to use $player->close("", "custom full server msg") on PlayerPreLoginEvent ? To change the message?
  10. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    Solved ! :p :D thanks to all
    $player->close();
    $event->setCancelled();
    work perfectly.
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Hack: use DataPacketSendEvent.
    For setting message, $event->setKickMessage()
    Player::close() is not recommended. It is kind of PocketMine internals.
    Cancel PlayerKickEvent and kick the Player in PlayerLoginEvent with your message to $player->kick($reason)

Share This Page

Advertisement