Skip to content

How to Send your own OnPacket

Muhammad Kevin edited this page May 21, 2023 · 2 revisions

In this page will tell you how to send your own OnPacket

You can make your own OnPacket using onPacketCreate() function

onPacketCreate() format

  • s = String
  • d = Integer
  • D = Integer X
  • f = Float

Example code #1 (Basic On Console Message)

if (isStr(command[0], "/testconmess")) {
    enet_peerSend(onPacketCreate("ss", "OnConsoleMessage", "Hello World"), clientPeer);
    break;
}

Example code #2 (Concat string using CatchMessage)

if (isStr(command[0], "/testconmess")) {
    char* hello = "hello world";
    enet_peerSend(onPacketCreate("ss", "OnConsoleMessage", CatchMessage("%s World", hello)), clientPeer);
    break;
}