0.0.1 • Published 6 months ago

@infernus/nex-ac v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@infernus/nex-ac

npm npm npm bundle size

A wrapper of the popular SA-MP nex-ac library for samp-node.

Notice

  • Mandatory use raknet and streamer
  • Removed SKY and non-streamer code

Getting started

pnpm add @infernus/core @infernus/raknet @infernus/nex-ac

Example

import { GameMode } from '@infernus/core'
import { $t, antiCheatKickWithDesync, defineNexACConfig, onCheatDetected } from '@infernus/nex-ac'

// other imports and code

defineNexACConfig(() => {
  return {
    LOCALE: 'en_US',
    DEBUG: true,
  }
})

onCheatDetected(({ player, ipAddress, type, code, next }) => {
  if (type) {
    GameMode.blockIpAddress(ipAddress, 0)
    return next()
  }

  switch (code) {
    case 5:
    case 6:
    case 11:
    case 14:
    case 22:
    case 32: {
      return next()
    }
    case 40: {
      player.sendClientMessage(-1, $t('MAX_CONNECTS_MSG', null, player.locale))
      break
    }
    case 41: {
      player.sendClientMessage(-1, $t('UNKNOWN_CLIENT_MSG', null, player.locale))
      break
    }
    default: {
      player.sendClientMessage(-1, $t('KICK_MSG', [code], player.locale))
      break
    }
  }
  antiCheatKickWithDesync(player, code)
  return next()
})
0.0.1

6 months ago