Wiki

Clone wiki

EFLC-Multiplayer / apiEvents

Adding your own codes to the server using server events (callbacks)

#!c++

#include <mainNetwork.h>
#include "apiWorld.h"

#include "apiPlayerEvents.h" //Includes player events (callbacks)

bool onPlayerCredentials(int playerid) //Defines a player connect function
{
    //This function will be called once a player successfully connects to this server
    //We will use "apiPlayer::get(playerid)" to GET the player class.

    apiPlayer::get(playerid).setSkin(1613899343); //Changes the player skin to NIKO's model

    apiMath::Vector3 spawnPos(-205.476f, 630.067f, 13.8088f); //Creates a vector with Central Park coordinates
    apiPlayer::get(playerid).spawn(spawnPos); //Finally we tell the player to Spawn
}

int main()
{
   //In order for "onPlayerCredentials" to be called we need to register the function
   //Continue the tutorial to see all events available and how to use them
   apiPlayerEvents::registerPlayerCredentials(onPlayerCredentials);


   if(initRaknet(8888, "Server Name", "Server location", "Server WebSite", false))
   {
       //Contents inside this code block was covered on the first tutorial
   }
   return 1;
}

Click here to continue the tutorial

List of server events:

Player Events

Vehicle Events

List of server classes:

Player

Vehicles

Objects

Blips

Checkpoints

Time and Weather

Updated