megaman
04/07/2020, 07:16 PM
E ae galera como vocês estão?
Hoje vim postar essa custom para quem utiliza source muemu.
Essa custom serve para o adm presentear o player que está iniciando no servidor.
Vamos lá
Primeiramente você vai a source do seu GameServer e vai criar esses dois arquivos:
GiftForNew.h
E adicione o código:
#pragma once
#define MAX_CLASS 7
struct GIFT_INFO
{
int Class;
int SetID;
int Level;
int Luck;
int Option;
int Excellent;
int Time;
};
class CGift
{
public:
CGift();
virtual ~CGift();
void Init();
void Load(char* path);
void SetInfo(GIFT_INFO info);
void GiftItem(LPOBJ lpObj);
public:
GIFT_INFO m_GiftInfo[MAX_CLASS];
};
extern CGift gGiftNew;
GiftForNew.cpp
E adicione o código:
#include "stdafx.h"
#include "GameServer.h"
#include "GameMain.h"
#include "Util.h"
#include "User.h"
#include "GiftForNew.h"
#include "CashShop.h"
#include "MemScript.h"
#include "Notice.h"
#include "DSProtocol.h"
#include "ItemManager.h"
#include "ServerInfo.h"
CGift gGiftNew;
CGift::CGift() // OK
{
this->Init();
}
CGift::~CGift() // OK
{
}
void CGift::Init() // OK
{
memset(this->m_GiftInfo,0,sizeof(this->m_GiftInfo));
}
void CGift::Load(char* path) // OK
{
CMemScript* lpMemScript = new CMemScript;
if(lpMemScript == 0)
{
ErrorMessageBox(MEM_SCRIPT_ALLOC_ERROR,path);
return;
}
if(lpMemScript->SetBuffer(path) == 0)
{
ErrorMessageBox(lpMemScript->GetLastError());
delete lpMemScript;
return;
}
this->Init();
try
{
while(true)
{
if(lpMemScript->GetToken() == TOKEN_END)
{
break;
}
if(strcmp("end",lpMemScript->GetString()) == 0)
{
break;
}
GIFT_INFO info;
info.Class = lpMemScript->GetNumber();
info.SetID = lpMemScript->GetAsNumber();
info.Level = lpMemScript->GetAsNumber();
info.Luck = lpMemScript->GetAsNumber();
info.Option = lpMemScript->GetAsNumber();
info.Excellent = lpMemScript->GetAsNumber();
info.Time = lpMemScript->GetAsNumber();
this->SetInfo(info);
}
}
catch(...)
{
ErrorMessageBox(lpMemScript->GetLastError());
}
delete lpMemScript;
}
void CGift::SetInfo(GIFT_INFO info) // OK
{
if(CHECK_RANGE(info.Class,MAX_CLASS) == 0)
{
return;
}
this->m_GiftInfo[info.Class] = info;
}
void CGift::GiftItem(LPOBJ lpObj)
{
if(gServerInfo.m_TheGift == 0)
{
return;
}
if(lpObj->TheGift >= 1)
{
return;
}
lpObj->TheGift += 1;
GDSaveTheGiftData(lpObj->Index);
int Days = this->m_GiftInfo[lpObj->Class].Time;
time_t t = time(NULL);
localtime(&t);
DWORD iTime = (DWORD)t + Days * 86400;
GDCreateItemSend(lpObj->Index,0xEB,0,0,GET_ITEM(7,this->m_GiftInfo[lpObj->Class].SetID),this->m_GiftInfo[lpObj->Class].Level,0,0,this->m_GiftInfo[lpObj->Class].Luck,this->m_GiftInfo[lpObj->Class].Option,-1,this->m_GiftInfo[lpObj->Class].Excellent,0,0,0,0,0xFF,iTime);
GDCreateItemSend(lpObj->Index,0xEB,0,0,GET_ITEM(8,this->m_GiftInfo[lpObj->Class].SetID),this->m_GiftInfo[lpObj->Class].Level,0,0,this->m_GiftInfo[lpObj->Class].Luck,this->m_GiftInfo[lpObj->Class].Option,-1,this->m_GiftInfo[lpObj->Class].Excellent,0,0,0,0,0xFF,iTime);
GDCreateItemSend(lpObj->Index,0xEB,0,0,GET_ITEM(9,this->m_GiftInfo[lpObj->Class].SetID),this->m_GiftInfo[lpObj->Class].Level,0,0,this->m_GiftInfo[lpObj->Class].Luck,this->m_GiftInfo[lpObj->Class].Option,-1,this->m_GiftInfo[lpObj->Class].Excellent,0,0,0,0,0xFF,iTime);
GDCreateItemSend(lpObj->Index,0xEB,0,0,GET_ITEM(10,this->m_GiftInfo[lpObj->Class].SetID),this->m_GiftInfo[lpObj->Class].Level,0,0,this->m_GiftInfo[lpObj->Class].Luck,this->m_GiftInfo[lpObj->Class].Option,-1,this->m_GiftInfo[lpObj->Class].Excellent,0,0,0,0,0xFF,iTime);
GDCreateItemSend(lpObj->Index,0xEB,0,0,GET_ITEM(11,this->m_GiftInfo[lpObj->Class].SetID),this->m_GiftInfo[lpObj->Class].Level,0,0,this->m_GiftInfo[lpObj->Class].Luck,this->m_GiftInfo[lpObj->Class].Option,-1,this->m_GiftInfo[lpObj->Class].Excellent,0,0,0,0,0xFF,iTime);
}
Após isso entre no arquivo ServerInfo.cpp e adicione essa linha:
gGiftNew.Load(gPath.GetFullPath("Custom\\GiftForNew.txt"));
Em User.h adicione:
struct OBJECTSTRUCT
{
BYTE TheGift; // only add in is struct
};
Em User.cpp adicione:
void gObjCharZeroSet(int aIndex) // OK
{
lpObj->TheGift = 0; // only add in is void
}
Em DsProtocol.cpp adicione:
void DGCharacterInfoRecv(SDHP_CHARACTER_INFO_RECV* lpMsg) // OK
{
gGiftNew.GiftItem(lpObj); // only add in is void
}
void GDSaveTheGiftData(int aIndex)
{
LPOBJ lpUser = &gObj[aIndex];
THEGIFT_GD_SAVE_DATA pRequest;
pRequest.header.set(0xD9, 0x07, sizeof(pRequest));
memcpy(pRequest.Name, lpUser->Name, 11);
pRequest.index = aIndex;
pRequest.TheGift = lpUser->TheGift;
gDataServerConnection.DataSend((BYTE*)&pRequest,pRequest.header.size);
}
Em DsProtocol.h adicione:
struct SDHP_CHARACTER_INFO_RECV
{
BYTE TheGift; // only add in is struct
};
struct THEGIFT_GD_SAVE_DATA
{
PSBMSG_HEAD header;
WORD index;
char Name[11];
BYTE TheGift;
};
//
void GDSaveTheGiftData(int aIndex);
Em ObjectManager.cpp adicione:
bool CObjectManager::CharacterInfoSet(BYTE* aRecv,int aIndex) // OK
{
lpObj->TheGift = lpMsg->TheGift; // only add in is bool
}
Pronto, com a parte do GameServer finalizada vamos então abrir a source do DataServer.
Com a source do DataServer aberta procure por:
DataServerProtocol.cpp e adicione:
void DataServerProtocolCore(int index,BYTE head,BYTE* lpMsg,int size) // OK
{
case 0xD9:
switch(((lpMsg[0]==0xC1)?lpMsg[3]:lpMsg[4]))
{
case 0x07:
GDSaveTheGiftRecv((THEGIFT_GD_SAVE_DATA*)lpMsg); // Only add in the case 0xD9
break;
}
break;
}
void GDCharacterInfoRecv(SDHP_CHARACTER_INFO_RECV* lpMsg,int index) // OK
{
pMsg.TheGift = gQueryManager.GetAsInteger("TheGift"); // only add in is void
}
void GDSaveTheGiftRecv(THEGIFT_GD_SAVE_DATA* lpMsg) // OK
{
gQueryManager.ExecQuery("UPDATE Character SET TheGift = %d WHERE Name = '%s'",lpMsg->TheGift, lpMsg->Name);
gQueryManager.Close();
}
Em DataServerProtocol.h adicione:
struct SDHP_CHARACTER_INFO_SEND
{
BYTE TheGift; // only add in is struct
};
struct THEGIFT_GD_SAVE_DATA
{
PSBMSG_HEAD header;
WORD index;
char Name[11];
BYTE TheGift;
};
void GDSaveTheGiftRecv(THEGIFT_GD_SAVE_DATA* lpMsg);
Pronto pessoal, feito todo esse processo sem erros execute a seguinte query no seu SQL:
USE MUONLINE
GO
alter table [Character] add [TheGift] int not null default(0)
E na pasta Data/Custom do seu servidor crie o arquivos GiftForNew.txt e nesse arquivo texto adicione essas informações:
//================================================== =================================
// Description: Gift set item with time for new player
// ----------------------------------------------------------------------------------
//================================================== =================================
//================================================== =================================
// Class SetID Level Luck Option Excellent Days
//================================================== =================================
0 2 9 1 7 3 1 //Dark Wizard
1 5 9 1 7 3 1 //Dark Knight
2 10 9 1 7 3 1 //Elf
3 15 9 1 7 3 1 //Magic Gladiator
4 5 9 1 7 3 1 //Dark Lord
5 39 9 1 7 3 1 //Summoner
6 59 9 1 7 3 1 //Rage Fighter
end
No exemplo acima cada classe iniciante está ganhando um set.
Créditos pelo código:
infinite
Hoje vim postar essa custom para quem utiliza source muemu.
Essa custom serve para o adm presentear o player que está iniciando no servidor.
Vamos lá
Primeiramente você vai a source do seu GameServer e vai criar esses dois arquivos:
GiftForNew.h
E adicione o código:
#pragma once
#define MAX_CLASS 7
struct GIFT_INFO
{
int Class;
int SetID;
int Level;
int Luck;
int Option;
int Excellent;
int Time;
};
class CGift
{
public:
CGift();
virtual ~CGift();
void Init();
void Load(char* path);
void SetInfo(GIFT_INFO info);
void GiftItem(LPOBJ lpObj);
public:
GIFT_INFO m_GiftInfo[MAX_CLASS];
};
extern CGift gGiftNew;
GiftForNew.cpp
E adicione o código:
#include "stdafx.h"
#include "GameServer.h"
#include "GameMain.h"
#include "Util.h"
#include "User.h"
#include "GiftForNew.h"
#include "CashShop.h"
#include "MemScript.h"
#include "Notice.h"
#include "DSProtocol.h"
#include "ItemManager.h"
#include "ServerInfo.h"
CGift gGiftNew;
CGift::CGift() // OK
{
this->Init();
}
CGift::~CGift() // OK
{
}
void CGift::Init() // OK
{
memset(this->m_GiftInfo,0,sizeof(this->m_GiftInfo));
}
void CGift::Load(char* path) // OK
{
CMemScript* lpMemScript = new CMemScript;
if(lpMemScript == 0)
{
ErrorMessageBox(MEM_SCRIPT_ALLOC_ERROR,path);
return;
}
if(lpMemScript->SetBuffer(path) == 0)
{
ErrorMessageBox(lpMemScript->GetLastError());
delete lpMemScript;
return;
}
this->Init();
try
{
while(true)
{
if(lpMemScript->GetToken() == TOKEN_END)
{
break;
}
if(strcmp("end",lpMemScript->GetString()) == 0)
{
break;
}
GIFT_INFO info;
info.Class = lpMemScript->GetNumber();
info.SetID = lpMemScript->GetAsNumber();
info.Level = lpMemScript->GetAsNumber();
info.Luck = lpMemScript->GetAsNumber();
info.Option = lpMemScript->GetAsNumber();
info.Excellent = lpMemScript->GetAsNumber();
info.Time = lpMemScript->GetAsNumber();
this->SetInfo(info);
}
}
catch(...)
{
ErrorMessageBox(lpMemScript->GetLastError());
}
delete lpMemScript;
}
void CGift::SetInfo(GIFT_INFO info) // OK
{
if(CHECK_RANGE(info.Class,MAX_CLASS) == 0)
{
return;
}
this->m_GiftInfo[info.Class] = info;
}
void CGift::GiftItem(LPOBJ lpObj)
{
if(gServerInfo.m_TheGift == 0)
{
return;
}
if(lpObj->TheGift >= 1)
{
return;
}
lpObj->TheGift += 1;
GDSaveTheGiftData(lpObj->Index);
int Days = this->m_GiftInfo[lpObj->Class].Time;
time_t t = time(NULL);
localtime(&t);
DWORD iTime = (DWORD)t + Days * 86400;
GDCreateItemSend(lpObj->Index,0xEB,0,0,GET_ITEM(7,this->m_GiftInfo[lpObj->Class].SetID),this->m_GiftInfo[lpObj->Class].Level,0,0,this->m_GiftInfo[lpObj->Class].Luck,this->m_GiftInfo[lpObj->Class].Option,-1,this->m_GiftInfo[lpObj->Class].Excellent,0,0,0,0,0xFF,iTime);
GDCreateItemSend(lpObj->Index,0xEB,0,0,GET_ITEM(8,this->m_GiftInfo[lpObj->Class].SetID),this->m_GiftInfo[lpObj->Class].Level,0,0,this->m_GiftInfo[lpObj->Class].Luck,this->m_GiftInfo[lpObj->Class].Option,-1,this->m_GiftInfo[lpObj->Class].Excellent,0,0,0,0,0xFF,iTime);
GDCreateItemSend(lpObj->Index,0xEB,0,0,GET_ITEM(9,this->m_GiftInfo[lpObj->Class].SetID),this->m_GiftInfo[lpObj->Class].Level,0,0,this->m_GiftInfo[lpObj->Class].Luck,this->m_GiftInfo[lpObj->Class].Option,-1,this->m_GiftInfo[lpObj->Class].Excellent,0,0,0,0,0xFF,iTime);
GDCreateItemSend(lpObj->Index,0xEB,0,0,GET_ITEM(10,this->m_GiftInfo[lpObj->Class].SetID),this->m_GiftInfo[lpObj->Class].Level,0,0,this->m_GiftInfo[lpObj->Class].Luck,this->m_GiftInfo[lpObj->Class].Option,-1,this->m_GiftInfo[lpObj->Class].Excellent,0,0,0,0,0xFF,iTime);
GDCreateItemSend(lpObj->Index,0xEB,0,0,GET_ITEM(11,this->m_GiftInfo[lpObj->Class].SetID),this->m_GiftInfo[lpObj->Class].Level,0,0,this->m_GiftInfo[lpObj->Class].Luck,this->m_GiftInfo[lpObj->Class].Option,-1,this->m_GiftInfo[lpObj->Class].Excellent,0,0,0,0,0xFF,iTime);
}
Após isso entre no arquivo ServerInfo.cpp e adicione essa linha:
gGiftNew.Load(gPath.GetFullPath("Custom\\GiftForNew.txt"));
Em User.h adicione:
struct OBJECTSTRUCT
{
BYTE TheGift; // only add in is struct
};
Em User.cpp adicione:
void gObjCharZeroSet(int aIndex) // OK
{
lpObj->TheGift = 0; // only add in is void
}
Em DsProtocol.cpp adicione:
void DGCharacterInfoRecv(SDHP_CHARACTER_INFO_RECV* lpMsg) // OK
{
gGiftNew.GiftItem(lpObj); // only add in is void
}
void GDSaveTheGiftData(int aIndex)
{
LPOBJ lpUser = &gObj[aIndex];
THEGIFT_GD_SAVE_DATA pRequest;
pRequest.header.set(0xD9, 0x07, sizeof(pRequest));
memcpy(pRequest.Name, lpUser->Name, 11);
pRequest.index = aIndex;
pRequest.TheGift = lpUser->TheGift;
gDataServerConnection.DataSend((BYTE*)&pRequest,pRequest.header.size);
}
Em DsProtocol.h adicione:
struct SDHP_CHARACTER_INFO_RECV
{
BYTE TheGift; // only add in is struct
};
struct THEGIFT_GD_SAVE_DATA
{
PSBMSG_HEAD header;
WORD index;
char Name[11];
BYTE TheGift;
};
//
void GDSaveTheGiftData(int aIndex);
Em ObjectManager.cpp adicione:
bool CObjectManager::CharacterInfoSet(BYTE* aRecv,int aIndex) // OK
{
lpObj->TheGift = lpMsg->TheGift; // only add in is bool
}
Pronto, com a parte do GameServer finalizada vamos então abrir a source do DataServer.
Com a source do DataServer aberta procure por:
DataServerProtocol.cpp e adicione:
void DataServerProtocolCore(int index,BYTE head,BYTE* lpMsg,int size) // OK
{
case 0xD9:
switch(((lpMsg[0]==0xC1)?lpMsg[3]:lpMsg[4]))
{
case 0x07:
GDSaveTheGiftRecv((THEGIFT_GD_SAVE_DATA*)lpMsg); // Only add in the case 0xD9
break;
}
break;
}
void GDCharacterInfoRecv(SDHP_CHARACTER_INFO_RECV* lpMsg,int index) // OK
{
pMsg.TheGift = gQueryManager.GetAsInteger("TheGift"); // only add in is void
}
void GDSaveTheGiftRecv(THEGIFT_GD_SAVE_DATA* lpMsg) // OK
{
gQueryManager.ExecQuery("UPDATE Character SET TheGift = %d WHERE Name = '%s'",lpMsg->TheGift, lpMsg->Name);
gQueryManager.Close();
}
Em DataServerProtocol.h adicione:
struct SDHP_CHARACTER_INFO_SEND
{
BYTE TheGift; // only add in is struct
};
struct THEGIFT_GD_SAVE_DATA
{
PSBMSG_HEAD header;
WORD index;
char Name[11];
BYTE TheGift;
};
void GDSaveTheGiftRecv(THEGIFT_GD_SAVE_DATA* lpMsg);
Pronto pessoal, feito todo esse processo sem erros execute a seguinte query no seu SQL:
USE MUONLINE
GO
alter table [Character] add [TheGift] int not null default(0)
E na pasta Data/Custom do seu servidor crie o arquivos GiftForNew.txt e nesse arquivo texto adicione essas informações:
//================================================== =================================
// Description: Gift set item with time for new player
// ----------------------------------------------------------------------------------
//================================================== =================================
//================================================== =================================
// Class SetID Level Luck Option Excellent Days
//================================================== =================================
0 2 9 1 7 3 1 //Dark Wizard
1 5 9 1 7 3 1 //Dark Knight
2 10 9 1 7 3 1 //Elf
3 15 9 1 7 3 1 //Magic Gladiator
4 5 9 1 7 3 1 //Dark Lord
5 39 9 1 7 3 1 //Summoner
6 59 9 1 7 3 1 //Rage Fighter
end
No exemplo acima cada classe iniciante está ganhando um set.
Créditos pelo código:
infinite