This guide provides step-by-step instructions for implementing the LuaSystem feature in the GameServer. The LuaSystem allows the server to execute Lua scripts for various game events and provides a bridge between C++ and Lua scripting.
Integrated Files:
Core Lua System Files:
- ScriptLoader.h - Header file for script loader class
- ScriptLoader.cpp - Implementation of script loader
- LuaFunction.h - Header file for Lua function bindings
- LuaFunction.cpp - Implementation of Lua function bindings
Lua Library Files:
- lua52.lib - Lua 5.2 static library
- Lua header files in Util/lua/include/ directory
Base Configuration:
File: stdafx.h
- Lua include: #include "..\\..\\Util\\lua\\include\\lua.hpp"
- Lua library: #pragma comment(lib,"..\\..\\Util\\lua\\lua52.lib")
- LuaSystem enabled: #define LuaSystem 1
- Customer variables: extern char CustomerName[32]; and extern WORD CustomerLicenseId;
File: ServerInfo.cpp
- ScriptLoader include: #include "ScriptLoader.h"
- CustomerLicenseId definition: WORD CustomerLicenseId;
- Lua initialization in ReadScriptInfo():

Completed Integrations:
Attack System Integration
File: Attack.cpp - CheckPlayerTarget function (line 1650)

Item Management Integration
File: ItemManager.cpp - 3 integrated functions
1. CGItemGetRecv function (line 3009) - Item Pick:

2. CGItemDropRecv function (line 3278) - Item Drop:

3. CGItemMoveRecv function (line 3458) - Item Move:

NPC Talk Integration
File: NpcTalk.cpp - CGNpcTalkRecv function (line 1288)

Object Management Integration
File: ObjectManager.cpp - 4 integrated functions
1. User Respawn (line 392):

2. Character Close (line 727):

3. Monster Die (line 4770):

4. User Die (line 4877):

User System Integration
File: User.cpp - 2 integrated functions
1. Timer Thread (line 118):

2. Player Killer Check (line 2620):

Command Manager Integration
File: CommandManager.cpp - 2 integrated functions
1. Command Manager Check (line 270):

2. Command Done (line 270):

Data Server Protocol Integration
File: DSProtocol.cpp - Character Entry (line 1533)

Available Lua Functions
Dynamic Monster System:
- MonsterAdd() - Create monsters dynamically
- MonsterDelete() - Delete monsters
- SummonAdd() - Create custom summons
- SummonDelete() - Delete summons
Item System:
- OnUserItemPick() - Item pickup control
- OnUserItemDrop() - Item drop control
- OnUserItemMove() - Item movement control
Event System:
- OnCharacterEntry() - Character entry
- OnCharacterClose() - Character close
- OnUserRespawn() - User respawn
- OnUserDie() - User death
- OnMonsterDie() - Monster death
- OnNpcTalk() - NPC conversation
- OnCheckUserTarget() - Target verification
- OnCheckUserKiller() - Killer verification
- OnCommandManager() - Command management
- OnCommandDone() - Command completed
- OnTimerThread() - Server timer
Message System:
- MessageSend() - Send message to specific player
- MessageSendToAll() - Send message to all players
Download:

XOXO feel free to ask for help!