Solo usuarios registrados pueden comentar y agradecer, Logueate o Registrate

Autor Topic: LuaSystem Implementation Guide for GameServer  (Visto 443 veces)

0 Miembros and 1 Guest are viewing this topic.

Offline Watuyusei Posteado: September 15, 2025, 01:02:22 PM | Modificado: Today at 02:07:56 PM by Watuyusei

  • 0 puntos por ventas
  • *
  • Rank: Dedicado
  • Posts: 34
  • Gracias recibida: 299
  • 00
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!


Offline rando #1 Posteado: September 15, 2025, 04:37:33 PM

  • 0 puntos por ventas
  • *
  • Rank: Principiante
  • Posts: 7
  • Gracias recibida: 1
  • fr
Hello, MessageSend is working? type and color

I transferred from season 3 to season 6 and couldn't manage it because it sends a message to the game server side with GCNoticeSend

I downloaded the SSEMU 2.5.9 version from which lua was removed and I had to transfer it manually

void GCNewMessageSend(int aIndex,int type,int color,int message,...) // OK
{
#if(GAMESERVER_EXTRA==1)

char buff[128] = {0};

va_list arg;

va_start(arg,message);

vsprintf_s(buff,gMessage->GetText(message,gObj[aIndex].Lang),arg);

va_end(arg);

#if(GAMESERVER_UPDATE==603)

gNotice->GCNoticeSend(aIndex,1,0,0,0,0,0,"%s",buff);

#else

PMSG_NEW_MESSAGE_SEND pMsg;

pMsg.header.set(0xF3,0xE4,sizeof(pMsg));

pMsg.type = type;

pMsg.color = color;

memcpy(pMsg.message,buff,sizeof(pMsg.message));

DataSend(aIndex,(BYTE*)&pMsg,pMsg.header.size);

#endif

#endif
}

When I try to modify the code, the game server crashes



Offline Watuyusei #2 Posteado: September 15, 2025, 04:58:51 PM

  • 0 puntos por ventas
  • *
  • Rank: Dedicado
  • Posts: 34
  • Gracias recibida: 299
  • 00
Hello, MessageSend is working? type and color

I transferred from season 3 to season 6 and couldn't manage it because it sends a message to the game server side with GCNoticeSend

I downloaded the SSEMU 2.5.9 version from which lua was removed and I had to transfer it manually

void GCNewMessageSend(int aIndex,int type,int color,int message,...) // OK
{
#if(GAMESERVER_EXTRA==1)

char buff[128] = {0};

va_list arg;

va_start(arg,message);

vsprintf_s(buff,gMessage->GetText(message,gObj[aIndex].Lang),arg);

va_end(arg);

#if(GAMESERVER_UPDATE==603)

gNotice->GCNoticeSend(aIndex,1,0,0,0,0,0,"%s",buff);

#else

PMSG_NEW_MESSAGE_SEND pMsg;

pMsg.header.set(0xF3,0xE4,sizeof(pMsg));

pMsg.type = type;

pMsg.color = color;

memcpy(pMsg.message,buff,sizeof(pMsg.message));

DataSend(aIndex,(BYTE*)&pMsg,pMsg.header.size);

#endif

#endif
}

When I try to modify the code, the game server crashes

Yes, MessageSend is working correctly. The issue you're experiencing is related to how the system handles different game server versions and the transition from Season 3 to Season 6.



The crash likely occurs because:
Packet Structure Mismatch: The client expects a specific packet format that may not match your server's version
Missing Dependencies: The gMessage object or gNotice object might not be properly initialized
Buffer Overflow: The message buffer might exceed the expected size.

Verify Message System Initialization: Make sure gMessage and gNotice are properly loaded
Test with Simple Messages: Start with basic messages to isolate the issue

.lua

Gracias:


Offline drtew #3 Posteado: September 16, 2025, 02:31:19 PM

  • 0 puntos por ventas
  • *
  • Rank: Principiante
  • Posts: 3
  • Gracias recibida: 0
  • pk
I downloaded the SSEMU 2.5.9 version from which lua was removed and I had to transfer it manually

void GCNewMessageSend(int aIndex,int type,int color,int message,...) // OK
{
#if(GAMESERVER_EXTRA==1)

char buff[128] = {0};

va_list arg;

va_start(arg,message);

vsprintf_s(buff,gMessage->GetText(message,gObj[aIndex].Lang),arg);

va_end(arg);

#if(GAMESERVER_UPDATE==603)

gNotice->GCNoticeSend(aIndex,1,0,0,0,0,0,"%s",buff);

#else

PMSG_NEW_MESSAGE_SEND pMsg;

pMsg.header.set(0xF3,0xE4,sizeof(pMsg));

pMsg.type = type;

pMsg.color = color;

memcpy(pMsg.message,buff,sizeof(pMsg.message));

DataSend(aIndex,(BYTE*)&pMsg,pMsg.header.size);
minecraft edition apk
#endif


Solo usuarios registrados pueden comentar y agradecer, Logueate o Registrate


 

Related Topics

  Subject / Started by Replies Last post
4 Replies
5365 Views
Last post July 26, 2019, 06:27:49 PM
by -Rastaa.TSM☢
2 Replies
2926 Views
Last post July 07, 2021, 09:02:44 PM
by Miisoia
0 Replies
1326 Views
Last post May 14, 2021, 04:04:27 AM
by zodiacddos
0 Replies
524 Views
Last post June 13, 2022, 03:04:56 PM
by whodhell
0 Replies
78 Views
Last post May 12, 2025, 03:23:55 PM
by jonson6677