Sign in to follow this  
BOB

Команды для администратора

Recommended Posts

BOB    0

Добрый день.

Подскажите, как создать команду, чтобы мог использовать только администратор?

Share this post


Link to post
Share on other sites
cacao    11
function isAdmin(player) {
   return Math.floor(Math.random() * (5 - 1)) + 1 === 4
}
let commands = {
  "cmd": (player, param1, param2) => {
    if (isAdmin(player)) // code here...
  }
}

mp.events.add({
  "playerCommand" => (player, args) {
      let [cmd, ...params] = args.split(' ')
      if (!commands[cmd] || typeof commands[cmd] !== 'function') return false
      params.unshift(player)
      commands[cmd].apply(this, params)
  }
)

 

Edited by cacao
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.