Private Books

Discussion in 'CommandHelper Scripts' started by sebdomsan54, Apr 17, 2016.

  1. sebdomsan54

    sebdomsan54 Member

    Private Books
    this scrips is in basic a way for player to ether add passwords to a book or only allow certain people to read the books.
    *note i cant do passwords yet because exodus is broken on 1.9.2

    [​IMG]
    [​IMG]

    PHP:
    bind('player_interact', null, null, @c,null
            if(@c[action] == 'right_click_air' || @c[action] == 'right_click_block'){
                if(@c[item] == '387:0'){
                 @bookinfo = (get_mob_equipment(entity_id(puuid(player())))[weapon])
                    if(((string_position(@bookinfo[meta][pages], password)) != -1) || ((string_position(@bookinfo[meta][pages], Password)) != '-1')){
                     cancel(true)
                     @password = ((split('\n', (split(':', @bookinfo[meta][pages])[1]))[0]))
                        @input = user_input(@c[player], if((@input == @password)){
                         cancel(false)
                        })
                    } else if(((string_position(@bookinfo[meta][pages], readers)) != -1) || ((string_position(@bookinfo[meta][pages], Readers)) != '-1')){
                     cancel(true)
                     @readerlist = ((split('\n', (split(':', @bookinfo[meta][pages])[1]))[0]))
                        if((string_position(@readerlist, @c[player])) != -1){
                         cancel(false)
                        } else{
                         msg('A magic force holds the book closed')
                        }
                    }
                }
            }
    )
  2. MCmacjuul

    MCmacjuul Member

    Your using user_input() in a wrong way, you want it like this:

    PHP:

    @pass = '12345'; // Terrible password hehe

    user_input(@c['player'], closure(@inp) {
        if(@pass == @inp) {
            // Password successful
        } else {
            // Password incorrect
        }
    });
     
    Do note that cancel() won't work when you put it in closures, so you might want to think of a different way of approaching this. You could instead make the book "locked" and "unlock" it when a password has been entered correctly. It would then lock once again when the book would be dropped or put in a container
    Last edited: Apr 18, 2016
  3. sebdomsan54

    sebdomsan54 Member


    with only this code i get
    "An unexpected exeption occured during the execution of your script. please cheak the consol for more information."

    ps: Sorry for breaking it

    [22:44:26] [Server thread/INFO]: cats_doom issued server command: /recompile
    [22:44:26] [Server thread/INFO]: CHExodius 2.2.3 has sucessfully been disabled!
    [22:44:26] [Server thread/INFO]: CHVC 1.0.3 unloaded.
    [22:44:26] [Server thread/INFO]: CHExodius 2.2.3 has sucessfully been enabled!
    [22:44:26] [Server thread/INFO]: CHVC 1.0.3 loaded.
    [22:44:26] [Server thread/INFO]: [CommandHelper]: MethodScript files processed
    [22:44:26] [Server thread/INFO]: [CommandHelper]: 11 alias(es) defined.
    [22:44:27] [Server thread/INFO]: cats_doom issued server command: /input
    [22:44:27] [Server thread/INFO]: CH: Running original command on player cats_doom ----> /input
    [22:44:27] [Server thread/INFO]: An unexpected exception occured during the execution of a script.
    [22:44:27] [Server thread/WARN]: java.lang.NoClassDefFoundError: org/bukkit/craftbukkit/v1_8_R3/entity/CraftPlayer
    [22:44:27] [Server thread/WARN]: at me.macjuul.chexodius.CHExodiusFunctions$user_input.exec(CHExodiusFunctions.java:515)
    [22:44:27] [Server thread/WARN]: at com.laytonsmith.core.Script.eval(Script.java:375)
    [22:44:27] [Server thread/WARN]: at com.laytonsmith.core.MethodScriptCompiler.execute(MethodScriptCompiler.java:1977)
    [22:44:27] [Server thread/WARN]: at com.laytonsmith.core.MethodScriptCompiler.execute(MethodScriptCompiler.java:1934)
    [22:44:27] [Server thread/WARN]: at com.laytonsmith.core.Script.run(Script.java:207)
    [22:44:27] [Server thread/WARN]: at com.laytonsmith.core.AliasCore.alias(AliasCore.java:153)
    [22:44:27] [Server thread/WARN]: at com.laytonsmith.commandhelper.CommandHelperListener.runAlias(CommandHelperListener.java:80)
    [22:44:27] [Server thread/WARN]: at com.laytonsmith.commandhelper.CommandHelperListener.onPlayerCommandPreprocess(CommandHelperListener.java:112)
    [22:44:27] [Server thread/WARN]: at sun.reflect.GeneratedMethodAccessor59.invoke(Unknown Source)
    [22:44:27] [Server thread/WARN]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [22:44:27] [Server thread/WARN]: at java.lang.reflect.Method.invoke(Method.java:498)
    [22:44:27] [Server thread/WARN]: at me.incomprehendable.dev.pwp.transparentlisteners.PerWorldPluginLoader$1.execute(PerWorldPluginLoader.java:116)
    [22:44:27] [Server thread/WARN]: at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    [22:44:27] [Server thread/WARN]: at me.incomprehendable.dev.pwp.transparentlisteners.PWPRegisteredListener.callEvent(PWPRegisteredListener.java:28)
    [22:44:27] [Server thread/WARN]: at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502)
    [22:44:27] [Server thread/WARN]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487)
    [22:44:27] [Server thread/WARN]: at net.minecraft.server.v1_9_R1.PlayerConnection.handleCommand(PlayerConnection.java:1342)
    [22:44:27] [Server thread/WARN]: at net.minecraft.server.v1_9_R1.PlayerConnection.a(PlayerConnection.java:1185)
    [22:44:27] [Server thread/WARN]: at net.minecraft.server.v1_9_R1.PacketPlayInChat.a(PacketPlayInChat.java:45)
    [22:44:27] [Server thread/WARN]: at net.minecraft.server.v1_9_R1.PacketPlayInChat.a(PacketPlayInChat.java:1)
    [22:44:27] [Server thread/WARN]: at net.minecraft.server.v1_9_R1.PlayerConnectionUtils$1.run(SourceFile:13)
    [22:44:27] [Server thread/WARN]: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    [22:44:27] [Server thread/WARN]: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    [22:44:27] [Server thread/WARN]: at net.minecraft.server.v1_9_R1.SystemUtils.a(SourceFile:45)
    [22:44:27] [Server thread/WARN]: at net.minecraft.server.v1_9_R1.MinecraftServer.D(MinecraftServer.java:721)
    [22:44:27] [Server thread/WARN]: at net.minecraft.server.v1_9_R1.DedicatedServer.D(DedicatedServer.java:400)
    [22:44:27] [Server thread/WARN]: at net.minecraft.server.v1_9_R1.MinecraftServer.C(MinecraftServer.java:660)
    [22:44:27] [Server thread/WARN]: at net.minecraft.server.v1_9_R1.MinecraftServer.run(MinecraftServer.java:559)
    [22:44:27] [Server thread/WARN]: at java.lang.Thread.run(Thread.java:745)

    PHP:
    /input = >>>
    user_input(player(), closure());
    <<<
  4. MCmacjuul

    MCmacjuul Member

    Oh I see, the latest version isn't compatible with 1.8 I'm afraid
  5. sebdomsan54

    sebdomsan54 Member

    im on 1.9 still not compatible right?
  6. MCmacjuul

    MCmacjuul Member

    It should be compatible for 1.9, at least, it is working for me on 1.9