SOLVED

Discussion in 'Skript' started by Mattllama9877, Apr 16, 2018.

  1. Hi I need a way to make it when you kill a zombie or any mob it will run a command. Does anyone know of a way to do this? I need it were it will give a key. So for a example if you kill a zombie it will do this.

    on death of zombie:
    if chance of 100%:
    make console execute command "cr givekey %player% legendary 1"

    But it dosnt give a key at all. Am I doing something wrong? or is it not possible?

    Thanks!
     
  2. Does anything show up in console? Like a message saying "Unknown Command" or even Skript giving a null error?
     
  3. This is all it says.

    [Server] INFO givekey: <none> was offline.
    [Server] INFO Player must be online to receive items.
     
  4. Code (Text):
        @EventHandler
        public void onZombieDeath(EntityDeathEvent event) {
            if (event.getEntity() instanceof Zombie) {
                Player player = event.getEntity().getKiller();
                Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "cr givekey " + player.getName() + " legendary 1");
            }
        }
    That will give the player who killed the zombie a key.
     
    • Funny Funny x 2
  5. I don't even know were I would do that xD? Is that java? lol if so I don't do java I only use Skript
     
  6. Use %attacker% instead of player.
     
    • Agree Agree x 2
  7. OMG!!! you my friend are the BEST!!! thank you sooooo much! :)
     
    • Friendly Friendly x 1
  8. on death of zombie:
    chance of 100%:
    make console execute command "cr givekey %attacker% legendary 1"
     
  9. Op already fixed his problem
     
  10. example:
    Code (Text):
    on death of zombie:
        if attaker = Player:
            execute attacker command "cr givekey %attacker% legendary 1"
    https://skripthub.net
     
  11. Execute console command*
     
  12. ok
    Code (Text):
    on death of zombie:
        if attaker = Player:
            execute console command "cr givekey %attacker% legendary 1"
     

Share This Page