Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Help] Command Add Points

Newbie Spellweaver
Joined
Apr 24, 2015
Messages
31
Reaction score
7
I am trying to make Add Points Command but when i refresh LevelUpPoints the GS Crash due to DataSend Loop gives error due to exceeded Buffer Size but the buffer size is not the problem... anyway is there another way to refresh leveluppoints after add ?!
 
Joined
Oct 8, 2006
Messages
740
Reaction score
289
Make a new function for gObjLevelUpPointAdd.

The gObjLevelUpPointAdd you are trying to use is only for single attribute point adding (clicking the + button to add single point).

Also, what information you gave me is not helping me to see where or how you made the adding for commands for attributes.



Link removed
 
Last edited:
Upvote 0
Newbie Spellweaver
Joined
Apr 24, 2015
Messages
31
Reaction score
7
Can you share me Source of
Make a new function for gObjLevelUpPointAdd.

I have many modifications in the source so i cant run that Gameserver
 
Last edited:
Upvote 0
Joined
Oct 8, 2006
Messages
740
Reaction score
289
In the user.h add:

Code:
extern BOOL CommandAddPoints(BYTE type, LPOBJECTSTRUCT lpObj, int points);

In user.cpp add:

Code:
BOOL CommandAddPoints(BYTE type, LPOBJECTSTRUCT lpObj, int points)
{if (lpObj->Type > OBJTYPE_NPC)
{LogAddC(LOGC_RED, lMsg.Get(521), lpObj->AccountID, lpObj->Name, __FILE__, __LINE__); return FALSE;    }

if (lpObj->LevelUpPoint < points)    {
        LogAddChar("AddPointsCmd", lpObj, "You don't have %d - Current points: %d", points, lpObj->LevelUpPoint);        return FALSE;    }

switch (type)
{
case 0: lpObj->Strength += points; break;
case 1: lpObj->Dexterity += points; break;
case 2: lpObj->Vitality += points;
lpObj->MaxLife += lpObj->VitalityToLife;
 gObjCalcMaxLifePower(lpObj->m_Index); break;
case 3:lpObj->Energy += points;lpObj->MaxMana += lpObj->EnergyToMana; break;
case 4:lpObj->Leadership += points; break;
    }

lpObj->LevelUpPoint -= points;

gObjCalCharacter(lpObj->m_Index, 1);
return TRUE;}
 
Upvote 0
Newbie Spellweaver
Joined
Apr 24, 2015
Messages
31
Reaction score
7
I used this method before, the problem that LevelupPoints doesnt affect just only after relog
 
Upvote 0
Joined
Oct 8, 2006
Messages
740
Reaction score
289
I will try to set up a testing environment for that S12 and see what's the problem with it.



Meanwhile, post your code of:
- How are you adding the commands
- How are you using the functions
- How you defined the commands

Otherwise, I can't guess what you've done there.
 
Upvote 0
Newbie Spellweaver
Joined
Apr 24, 2015
Messages
31
Reaction score
7
INSIDE ->> BOOL CGMMng::ManagementProc(LPOBJECTSTRUCT lpObj, char* szCmd, int aIndex)
case ADD_STRENGTH_CMD: { gCommand.AddPointsCommand(lpObj, GetTokenNumber(), 0); } break; and others same with changing CommandType From 0 to 4
------------------------------------------------------------------------------------------------------------------------
VOID CCommands::AddPointsCommand(LPOBJECTSTRUCT lpObj, INT Points, DWORD CmdStatsType)
{
LPPMSG_LVPOINTADD lpMsg;
PHeadSubSetB((LPBYTE)&lpMsg, 0xF3, 0x06, sizeof(LPPMSG_LVPOINTADD));
lpMsg->Type = CmdStatsType;
for (int i=0; i<Points; i++)
{
g_Function.LevelUpPointAdd(lpMsg, lpObj->m_Index);
}

lpObj->Money -= lpAddPointsInfo.nReqZen;

GCMoneySend(lpObj->m_Index, lpObj->Money);
}
-------------------------------------------------------------------------------------------------------------------------

Please If there any contact better :)

Discord or Skype or Whatsapp
 
Last edited:
Upvote 0
Joined
Jul 31, 2012
Messages
490
Reaction score
93
At least guide you in the right direction.

I have used this feature for years and it is 100% functional.

PHP:
void CCommands::AddStats(int aIndex, LPCSTR AddPoints, DWORD Type)
{
	char Message[255];

	int Points = atoi(AddPoints);
	if(Points < 1) return;

	LPOBJ lpObj = &gObj[aIndex];
	
	if(g_Configs.AddStatsEnable == 0) return;
	
	if(Points > g_Configs.AddStatsMaxPoints)
	{
		sprintf(Message,"You can add %d point(s)",g_Configs.AddStatsMaxPoints);
		GCServerMsgStringSend(Message,aIndex,1);
		return;
	}

	if(g_Configs.AddStatsLevel > lpObj->Level)
	{
		sprintf(Message,"You must be %d level to use this command",g_Configs.AddStatsLevel);
		GCServerMsgStringSend(Message,aIndex,1);
		return;
	}

	if(g_Configs.AddStatsCost > lpObj->Money)
	{
		sprintf(Message,"You need %d of Zen to use this command",g_Configs.AddStatsCost);
		GCServerMsgStringSend(Message,aIndex,1);
		return;
	}

	if(Type == 4 && lpObj->Class != CLASS_DARKLORD)
	{
		GCServerMsgStringSend("Command is only to DarkLord",aIndex,1);
		return;
	}

	if(lpObj->LevelUpPoint < Points)
	{
		GCServerMsgStringSend("Don't have you sufficient points",aIndex,1);
		return;
	}

	int maxStr = Points + lpObj->Strength;
	if (Type == 3) {
		if (maxStr > g_Configs.MaxStats) {
			sprintf(Message, "Max stats is %d point(s)", g_Configs.MaxStats);
			GCServerMsgStringSend(Message, aIndex, 1);
			return;
		}
	}
	int maxAgi = Points + lpObj->Dexterity;
	if (Type == 2) {
		if (maxAgi > g_Configs.MaxStats) {
			sprintf(Message, "Max stats is %d point(s)", g_Configs.MaxStats);
			GCServerMsgStringSend(Message, aIndex, 1);
			return;
		}
	}
	int maxVit = Points + lpObj->Vitality;
	if (Type == 1) {
		if (maxVit > g_Configs.MaxStats) {
			sprintf(Message, "Max stats is %d point(s)", g_Configs.MaxStats);
			GCServerMsgStringSend(Message, aIndex, 1);
			return;
		}
	}
	int maxEne = Points + lpObj->Energy;
	if (Type == 0) {
		if (maxEne > g_Configs.MaxStats) {
			sprintf(Message, "Max stats is %d point(s)", g_Configs.MaxStats);
			GCServerMsgStringSend(Message, aIndex, 1);
			return;
		}
	}
	int maxCmd = Points + lpObj->Leadership;
	if (Type == 4) {
		if (maxCmd > g_Configs.MaxStatsCmd) {
			sprintf(Message, "Max stats is %d point(s)", g_Configs.MaxStatsCmd);
			GCServerMsgStringSend(Message, aIndex, 1);
			return;
		}
	}

	lpObj->Money -= g_Configs.AddStatsCost;
	GCMoneySend(aIndex, lpObj->Money);

	switch(Type)
	{
		case 3:
			lpObj->Strength += Points;
		break;
		case 2:
			lpObj->Dexterity += Points;
		break;
		case 1:
			lpObj->Vitality += Points;
			lpObj->MaxLife += lpObj->VitalityToLife * Points;
			GCReFillSend(lpObj->m_Index,lpObj->MaxLife + lpObj->AddLife,0xFE,0,lpObj->iMaxShield+lpObj->iAddShield);
		break;
		case 0:
			lpObj->Energy += Points;
			lpObj->MaxMana += lpObj->EnergyToMana * Points;
			gObjSetBP(lpObj->m_Index);
			GCManaSend(lpObj->m_Index,lpObj->MaxMana + lpObj->AddMana,0xFE,0,lpObj->MaxBP);
		break;
		case 4:
			lpObj->Leadership += Points;
		break;
	}
	// =================================================
	//	YOU NEED THIS FOR CORRECT SENDING FUNCTION.
	// =================================================
	BYTE PMSG_USE_STAT_FRUIT[8] = { 0xC1,0x08,0x2C,0x00,0x01,0x00,0x03,0x00 };
	PMSG_USE_STAT_FRUIT[4] = LOBYTE(Points);
	PMSG_USE_STAT_FRUIT[5] = HIBYTE(Points);
	PMSG_USE_STAT_FRUIT[6] = (BYTE)Type;
	DataSend(aIndex,(unsigned char*)PMSG_USE_STAT_FRUIT,8);
	// =================================================
	lpObj->LevelUpPoint -= Points;
	GCLevelUpMsgSend(lpObj->m_Index,1);
	// ----
	gObjCalCharacter(aIndex);
	// ----
	sprintf(Message,"%d Added points!",Points);
	GCServerMsgStringSend(Message,aIndex,1);
	sprintf(Message,"Already have you %d Points",lpObj->LevelUpPoint);
	GCServerMsgStringSend(Message,aIndex,1);
}
 
Upvote 0
Newbie Spellweaver
Joined
Apr 24, 2015
Messages
31
Reaction score
7
Thanks alot for your help, but am sorry cant use GCLevelUpMsgSend it sends level up effect + differs the experience of the character.
 
Upvote 0
Back
Top