🤠
cedoscript
  • Introduction
  • Documentation
    • Packets
    • Setting Command
    • Java Imports
    • Examples
      • Creating a Pack
      • Custom Block Animation
      • Bhop
      • Setting Creation
      • Post Notification
      • Gradient Round Rectangle
      • Applying a gradient
      • Simulate a command
  • api
    • Events
    • Settings
    • Objects
      • EntityLivingBase
      • ItemStack
      • Player Abilities
      • Color
      • TimerUtil
      • Continual Animation
      • ShaderUtil
      • FrameBuffer
      • Rainbow
      • Drag
      • Pair
      • Module
  • Bindings
    • Client
    • Player
    • Packet
    • Action
    • Facing
    • Potion
    • Notification
    • Render
    • Stats
    • Font
    • User
    • World
Powered by GitBook
On this page

Was this helpful?

  1. Documentation
  2. Examples

Simulate a command

This will display how you can simulate making a command

var script = initScript({    
    name: "Clip Command",    
    description: "Use +clip [value] to vclip up and down",    
    author: "cedo"
})

script.onPlayerSendMessage(function (event) {    
    var message = event.getMessage()    
    if (message.contains("+clip")) {        
        event.cancel()        
        // Split it into an array by using spaces
        var array = message.split(" ")
        // if there is more than one message after the "-clip"       
        if (array.length > 1) {            
            var clipValue = parseInt(array[1])  
            // Check if it failed to parse the string          
            if (clipValue.isNaN()) {                
                client.printClientMsg("Invalid clip value " + array[1])            
            } else {
                //Finally set the position according to the clipvalue on the y axis                
                player.setPosition(player.x(), player.y() + clipValue, player.z())            
            }        
        } else {            
            client.printClientMsg("Error please specify a distance to clip")        
        }    
    }
})
PreviousApplying a gradientNextEvents

Last updated 2 years ago

Was this helpful?

Command is fully working and all edge cases are caught