How to make a player invicible?

Discussion in 'Plugin Development' started by gamemakertim, Jun 19, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    gamemakertim

    I am makeing a new game plugin
    and i want spectators that they can see what's happening, but not influence the rest of the game.

    I try many things, but cant solve how it works. can some one help me whit the code work?


    - MakerTim (A dutch coder, sorry for bad language)
     
  2. Offline

    ZeusAllMighty11

    Try something like:

    PHP:
    @EventHandler
    Player player 
    game.getPlayers(); // define Player player as all players in the game. Game = custom method
    public onPlayerDamage(PlayerDamageEvent e){ // player damage event (i think it's called)
    if player.isSpectating// isSpectating represents a custom method you would create to define a 'dead' or eliminated player
    event.setCancelled(true);
    player.getCurrentHealth().setCurrentHealth(500);
    }
    }
    Something like that
     
  3. Offline

    CorrieKay

    there are three ways you can go with this.

    1) give the spectators a permission, then cancel damage on players who have the permission
    2) add them to a set or list and cancel damage if theyre in the set/list
    3) give them creative mode, and block blockbreaks for people in creative mode.

    blarg! ninja'd!
     
  4. Offline

    ZeusAllMighty11

    I thought he said 'invincible' not 'invisible' . 0_o
     
  5. Offline

    CorrieKay

    ...so did i.

    also, holy cow, can you actually set a players health above 20? o3o
     
  6. Offline

    ZeusAllMighty11

    LOL My bad. Been up all night, XD

    Not sure why I did 500 o.0
     
  7. Offline

    Elvennomad

    I think he's trying to make them floating camera's. The issue with keeping the players body in the game is they can still use it to say Block an incoming arrow. Human shield. It's an exploit.
     
  8. Offline

    FTWin01Gurl

    You could set god mode for them, make them invisible.. give them creative but prevent them from actually interacting with anything. Then when the game is over or spectating mode stops, they go back. The issue? Players can exploit a glitch to spawn any item they want. I'd personally suggest a clean inventory during spectator mode (no items), while their current world inventory is stored in a Map, and then set it back when they quit or the game is over.
     
  9. Offline

    gamemakertim

    Can someone gif me a code for makeing them invisible?
     
  10. Offline

    CorrieKay

    player.hidePlayer(player2);
     
  11. Offline

    jf46784

    Or you can just tell the people not in spectating mode that the spectator's y is 1000 or something. That involves packets and I'm very new to bukkit plugins so I unfortunately can't give code sorry.
     
  12. Offline

    gamemakertim

    Tanks :D. i gonna use that one

    At Y1000 they cant see what is happening, and they gonna fall down
     
Thread Status:
Not open for further replies.

Share This Page