Compass Waypoints

Discussion in 'CommandHelper Scripts' started by sebdomsan54, Jan 31, 2016.

  1. sebdomsan54

    sebdomsan54 Member

    This code is ment to be expanded onto later as part of a form of travle that i wish to implement on my server
    So basicly players can craft a book called a notepad by tossing leather ink and a feather into a carfting table
    They must them add pages to it by clicking on it in there inventory with paper
    now when every they right click it will give them a sheet of paper with there cords on it they can name it will and anvil and it wont cause any isuses.
    if they right click with this paper there compass will point to the location they were standing when they made it

    PHP:
    add_recipe(
        array(
            type: 'SHAPELESS',
            result: array(type: 340, qty: 1, meta: array(display: 'Notepad', lore:array('Notepad', 'Pages: 0'))),
            ingredients: array('288', '351:0', '334')
        )
    )

    bind ('inventory_click', null, null, @c, null
        if (@c[action] == 'SWAP_WITH_CURSOR'){
            if (@c[cursoritem][type] == '339'){
                if (@c[slotitem][meta][lore][0] == 'Notepad'){
                    if (@c[slotitem][qty] == '1'){
                        if (@c[clicktype] == 'LEFT'){
                         @d = get_itemmeta(player(), @c[slot])[lore][1]
                         @e = split('Pages: ', @d)
                         @f = get_itemmeta(player(), @c[slot])
                         @f[lore][1] = concat('Pages: ', (@e[1] + @c[cursoritem][qty]))
                         set_itemmeta(player(), @c[slot], @f)
                            set_timeout(1, closure(){
                             ptake_item(player(), 339, @c[cursoritem][qty])
                            )}
                         #cancel()
                       }else if (@c[clicktype] == 'RIGHT'){
                        }else{
                         msg(error)
                         msg(@c[clicktype])
                        }
                    }else if (@c[slotitem][qty] > 1){
                     tmsg(player(), 'you can not add pages to more than one notebook at a time.')
                    }
                }
            }
        }
    )

    bind('player_interact', null, null, @c, null
    try(
    @hand = (get_mob_equipment(entity_id(puuid()))[weapon])
    @equipment = (get_mob_equipment(entity_id(puuid())))
    )
    if(@hand == null){
    @hand = array()
    @hand[type] = '0'
    }
    if (@hand[type] == '340'){
        if (@hand[meta][lore][0] == 'Notepad'){
         @pagecount = split('Pages: ', @hand[meta][lore][1])[1]
            if (@hand[qty] == '1'){
                if (@pagecount >= '1'){
                 @meta = array()
                 @loc = ploc(player())
                 @loc[x] = round(@loc[x], 2)
                 @loc[y] = round(@loc[y], 2)
                 @loc[z] = round(@loc[z], 2)
                 @loc[pitch] = round(@loc[pitch], 2)
                 @loc[yaw] = round(@loc[yaw], 2)
                 @meta['lore'] = array('Location', @loc[x], @loc[y], @loc[z], @loc[world], @loc[pitch], @loc[yaw])
                 @giveitem = pgive_item(player(), 339, 1, @meta)
                 @equipment[weapon][meta][lore][1] = concat('Pages: ', (@pagecount - 1))
                 set_mob_equipment(entity_id(puuid()), @equipment)
                    if (@giveitem > 0){
                     @equipment[weapon][meta][lore][1] = concat('Pages: ', (@pagecount))
                     set_mob_equipment(entity_id(puuid()), @equipment)
                     msg('you do not have enough inventory space for that');
                     exit()
                    }
                }else{
                 tmsg(player(), 'you need to add pages to your note page by clicking on it with sheets of paper.')
                }
            }else if (@hand[qty] > '1'){
             tmsg(player(), 'you can not stack notepads.')
            }
        }
    }
    )


    bind('player_interact', null, null, @c, null
    try(
    @hand = (get_mob_equipment(entity_id(puuid()))[weapon])
    )
    if(@hand == null){
    @hand = array()
    @hand[type] = '0'
    }
    if (@hand[type] == '339'){
        if (@hand[meta][lore][0] == 'Location'){
         @loc = @hand[meta][lore]
         @loca = array()
         @loca[world] = @loc[4]
         @loca[x] = round(@loc[1], 2)
         @loca[y] = round(@loc[2], 2)
         @loca[z] = round(@loc[3], 2)
         set_compass_target(player(), @loca)
        }
    }
    )

     
    Last edited: Jan 31, 2016