PDA

View Full Version : |Source| Custom Gift para novos usuários - source muemu



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

robsonsoares
06/07/2020, 10:31 AM
ao compilar deu este erro


Severity Code Description Project File Line Suppression State
Error MSB8036 The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". GameServer C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Wi n32\PlatformToolsets\v140\Toolset.targets 34

Mentor
06/07/2020, 11:02 AM
ao compilar deu este erro


Severity Code Description Project File Line Suppression State
Error MSB8036 The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". GameServer C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Wi n32\PlatformToolsets\v140\Toolset.targets 34

Isso deve ser um problema no seu compilador, qual compilador você está usando?

instalei a versão 8.1 SDK ver se resolve:

[Only registered and activated users can see links]

robsonsoares
06/07/2020, 11:09 AM
Isso deve ser um problema no seu compilador, qual compilador você está usando?

instalei a versão 8.1 SDK ver se resolve:

[Only registered and activated users can see links]


obrigado man

trabalho e tempos com mu..

queria expandir meu conhecimento..

vou instalar aqui e te digo dps obrigado mesmo..

15 minutes:------- Atualizado -------


Isso deve ser um problema no seu compilador, qual compilador você está usando?

instalei a versão 8.1 SDK ver se resolve:

[Only registered and activated users can see links]



instalei

aperteu F5

[Only registered and activated users can see links]


como sou novo
vou te perguntar

ele demora para o processo concluir ou eu finalizo ele clicando em debug e em terminar all

o processo seria no data server ele abriu

Mentor
06/07/2020, 12:07 PM
Geralmente quando adiciono algo eu compilo usando F7 = Build Solition
O visual studio que utilizo para essa source muemu é vs 2010 ultimate.
Ainda não adicionei essa custom no meu projeto, quando eu for adicionar vou gravar um vídeo adicionando isso, e ver se vai ficar ok.
Mas o tópico pelo que ví está bem mastigado kkkkkk

robsonsoares
06/07/2020, 06:16 PM
Geralmente quando adiciono algo eu compilo usando F7 = Build Solition
O visual studio que utilizo para essa source muemu é vs 2010 ultimate.
Ainda não adicionei essa custom no meu projeto, quando eu for adicionar vou gravar um vídeo adicionando isso, e ver se vai ficar ok.
Mas o tópico pelo que ví está bem mastigado kkkkkk

Mentor decupe as perguntas
podem ate ser d uma ignorância minha por estar começando!

troqei o vs para vs 2010

ajustei
e na compilção da como se faltasse arquivos
1>SkillManager.cpp(7): fatal error C1083: Cannot open include file: '..\\..\\Util\\Math.h': No such file or directory

procurei esse cpp ai e nao achei muito menos o diretorio Util

Denis Alves
06/07/2020, 09:14 PM
Mentor decupe as perguntas
podem ate ser d uma ignorância minha por estar começando!

troqei o vs para vs 2010

ajustei
e na compilção da como se faltasse arquivos
1>SkillManager.cpp(7): fatal error C1083: Cannot open include file: '..\\..\\Util\\Math.h': No such file or directory

procurei esse cpp ai e nao achei muito menos o diretorio Util

No update 4 ou 8, da source do louis, tem a pasta Util que falta para você compilar