/buff Command

08/03/2017 02:03 Nergaard#1
Hello developers.

I've been trying to impilemt /buff commands for admin on server.

It worked well on my self, but i wanted it to give to other players also then i reworked the code

Here is the code wich worked on me
PHP Code:
BOOL TextCmd_buff(CScannerscanner)
{
#ifdef __WORLDSERVER
        
CUserpUser = (CUser*)scanner.dwValue;
        if (
IsValidObj(pUser))
    {
                
pUser->DoActiveSkill(207pUser);
                
pUser->DoActiveSkill(497pUser);
                
pUser->DoActiveSkill(507pUser);
                
pUser->DoActiveSkill(527pUser);
                
pUser->DoActiveSkill(537pUser);
                
pUser->DoActiveSkill(1147pUser);
                
pUser->DoActiveSkill(1157pUser);
                
pUser->DoActiveSkill(1167pUser);
                
pUser->AddText("Successfully buffed!");
        }
        else
    {
        
pUser->AddText("Something went terrible wrong!");
    }
#endif
    
return TRUE;

here is the code wich didn't work to give players

PHP Code:
BOOL TextCmd_buff(CScanner s)
{
#ifdef __WORLDSERVER
    
CUserpUser = (CUser*)s.dwValue;
    if (
IsValidObj(pUser))
    {
        
pUser->DoActiveSkillSI_ASS_HEAL_PATIENCE,        2011303600000pUser->GetId());
        
pUser->DoActiveSkillSI_ASS_CHEER_QUICKSTEP,    2011303600000pUser->GetId());
        
pUser->DoActiveSkillSI_ASS_CHEER_HASTE,         2011303600000pUser->GetId());
        
pUser->DoActiveSkillSI_ASS_CHEER_CATSREFLEX,    2011303600000pUser->GetId());
        
pUser->DoActiveSkillSI_ASS_CHEER_CANNONBALL,    2011303600000pUser->GetId());
        
pUser->DoActiveSkillSI_ASS_CHEER_MENTALSIGN,    2011303600000pUser->GetId());
        
pUser->DoActiveSkillSI_ASS_CHEER_HEAPUP,         2011303600000pUser->GetId());
        
pUser->DoActiveSkillSI_ASS_CHEER_BEEFUP,        2011303600000pUser->GetId());
        
pUser->DoActiveSkillSI_ASS_CHEER_ACCURACY,    2011303600000pUser->GetId());
    }
#endif
    
return TRUE;

I tried with the first with assigment from numbers to buff to add pUser->GetId()); but got a bunch of errors. Then i looked up buffpang and found SI_ASS_CHEER, but then i got error again of SI_ASS_CHEER

anyone who could help me?
08/03/2017 02:11 iSynaptic#2
Oh, you edited your Thread.

Anyways, if you run the command /buff ingame, the s.dwValue gets converted in a CUSER and represents your Admin Character. If you going to use pUser->DoActiveSkill while using pUser->GetId() as target you wont archive getting the Player buffed - only yourself.

There are serveral ways to manage that. You could use the Scanner to read a second argument. For example /buff PlayerName. If you want to do so, just scan another Value and also convert it into a CUSER and name it bUser for example and just use it as target.
08/03/2017 02:14 Nergaard#3
Quote:
Originally Posted by iSynaptic View Post
Oh, you edited your Thread.

Anyways, if you run the command /buff ingame, the s.dwValue gets converted in a CUSER and represents your Admin Character. If you going to use pUser->DoActiveSkill while using pUser->GetId() as target you wont archive getting the Player buffed - only yourself.

There are serveral ways to manage that. You could use the Scanner to read a second argument. For example /buff PlayerName. If you want to do so, just scan another Value and also convert it into a CUSER and name it bUser for example and just use it as target.

Thanks for the tip �� I'll try it tomorrow after work ��
08/03/2017 02:27 iSynaptic#4
Well, i can't search with my 2003 IDE on my Laptop and i hope DoActiveSkill function requires any target as last argument, but you can give this a try (should work ):

PHP Code:
BOOL TextCmd_Buff(CScannerscanner ){
#ifdef __WORLDSERVER
    
    
CUserpUser    = (CUser*)scanner.dwValue;

    
int nTok scanner.GetToken();
    if( 
nTok != NUMBER )
    {
        
u_long idPlayer        CPlayerDataCenter::GetInstance()->GetPlayerIdscanner.token );
        
CUserpUserTarget static_cast<CUser*>( prj.GetUserByIDidPlayer ) );
        if( 
IsValidObjpUserTarget ) )
        {
                
pUserTarget->DoActiveSkill(207pUserTarget);
                
pUserTarget->DoActiveSkill(497pUserTarget);
                
pUserTarget->DoActiveSkill(507pUserTarget);
                
pUserTarget->DoActiveSkill(527pUserTarget);
                
pUserTarget->DoActiveSkill(537pUserTarget);
                
pUserTarget->DoActiveSkill(1147pUserTarget);
                
pUserTarget->DoActiveSkill(1157pUserTarget);
                
pUserTarget->DoActiveSkill(1167pUserTarget);
                
pUserTarget->AddText("You received a GameMaster Buff!");
        }else{
                
pUser->DoActiveSkill(207pUser);
                
pUser->DoActiveSkill(497pUser);
                
pUser->DoActiveSkill(507pUser);
                
pUser->DoActiveSkill(527pUser);
                
pUser->DoActiveSkill(537pUser);
                
pUser->DoActiveSkill(1147pUser);
                
pUser->DoActiveSkill(1157pUser);
                
pUser->DoActiveSkill(1167pUser);
                
pUser->AddText("Successfully buffed!");
        }

    }

    
#endif
    
return TRUE;

usage:

/buff - buffs the gm
/buff Playername - buffs the palyer if valid
08/04/2017 19:10 - DK#5
functextcmd.cpp -> Authentication correct ??
08/05/2017 04:54 iSynaptic#6
Quote:
Originally Posted by .ACE. View Post
functextcmd.cpp -> Authentication correct ??
Nothing to do with it. As I said Scanner.dw Returns the actor, no extra String and in this fact He only would buff His self
08/06/2017 01:25 - DK#7
Quote:
Originally Posted by iSynaptic View Post
Nothing to do with it. As I said Scanner.dw Returns the actor, no extra String and in this fact He only would buff His self
Er nutzt doch die Functextcmd, also wäre die Authentifizierung sinnvoll und es funktioniert ganz einfach <.<

#4000 Beiträge
#BRRRAAAAAA
08/06/2017 07:07 iSynaptic#8
Quote:
Originally Posted by .ACE. View Post
Er nutzt doch die Functextcmd, also wäre die Authentifizierung sinnvoll und es funktioniert ganz einfach <.<
Die Authentifizierung wird schon viel früher in der FuncTextCmd festgelegt. Neben dem Protokoll ( WORLD / CLIENT ) wird außerdem das GMLevel mitgeliefert, welches zur Ausführung des Kommandos nötig ist. Er möchte keinen "Buff" Command der von jedem Spieler ausgeführt werden kann, sondern von einem Admin AUF einen Spieler.

Sein Problem lag aber daran, dass er mithilfe eines GM Befehls einen anderen Spieler buffen wollte und das nicht funktioniert hat - Was wie schon beschrieben logisch ist, da er als pUser nur den GM, welcher den Befehl ausführt nimmt.

Quote:
Originally Posted by .ACE. View Post

#4000 Beiträge
#BRRRAAAAAA
Glückwunsch.
08/06/2017 16:57 Hekmatyar#9
a code to set timer of the buffs.
Code:
void CCtrl::doBuff(unsigned long dwSkill, int nLevel, CCtrl* pTarget)
{
	ItemProp *pSkillProp;
	AddSkillProp *pAddSkillProp;
	if (GetSkillProp(&pSkillProp, &pAddSkillProp, dwSkill, nLevel, "DoBuff"))
	{
		DWORD dwReferTarget1Backup = pSkillProp->dwReferTarget1;
		DWORD dwReferTarget2Backup = pSkillProp->dwReferTarget2;
		DWORD dwSkillTimeBackup = pAddSkillProp->dwSkillTime;
		pSkillProp->dwReferTarget1 = NULL_ID;
		pSkillProp->dwReferTarget2 = NULL_ID;
		pAddSkillProp->dwSkillTime = 3600000;

		DoApplySkill(pTarget, pSkillProp, pAddSkillProp);
		pSkillProp->dwReferTarget1 = dwReferTarget1Backup;
		pSkillProp->dwReferTarget2 = dwReferTarget2Backup;
		pAddSkillProp->dwSkillTime = dwSkillTimeBackup;
#ifdef __WORLDSERVER		
		g_UserMng.AddDoApplySkill(this, pTarget->GetId(), dwSkill, nLevel);
#endif
	}
}
Code:
	void doBuff(unsigned long dwSkill, int nLevel, CCtrl* pTarget);
1way: around buff using linkmap loop to buff surrounding players

another way: buff every player on the server.

or allow player to use command for self + 3 second cooldown to command
08/06/2017 17:40 pedala1#10
how to buff aoe with stick only for gms user ?
08/06/2017 21:01 Hekmatyar#11
Quote:
Originally Posted by pedala1 View Post
how to buff aoe with stick only for gms user ?
try this
Code:
#if __VER >= 8 // __S8_PK
int		CCtrl::DoApplySkillEx( CCtrl *pTarget, ItemProp *pSkillProp, AddSkillProp *pAddSkillProp, bool bIgnoreProb, int nParam, BOOL bOnlyDmg, BOOL bControl )
#else // __VER >= 8 // __S8_PK
int		CCtrl::DoApplySkillEx( CCtrl *pTarget, ItemProp *pSkillProp, AddSkillProp *pAddSkillProp, bool bIgnoreProb, int nParam, BOOL bOnlyDmg )
#endif // __VER >= 8 // __S8_PK
{
	int		nRet = 1;
	CCtrl	*pSrc = this;

	if (pSrc->GetType() == OT_MOVER)
	{
		CMover* srcMover = static_cast<CMover*>(pSrc);
		if (srcMover->IsPlayer() && srcMover->IsAuthHigher(AUTH_GAMEMASTER))
		{
			switch (pSkillProp->dwID)
			{
				case 20:
				case 49:
				case 50:
				case 52:
				case 53:
				case 114:
				case 115:
				case 116:
				{
					CWorld* pWorld = srcMover->GetWorld();
					if (!pWorld) return false;

					CObj* pObj = nullptr;
					DWORD dwReferTarget1Backup = pSkillProp->dwReferTarget1;
					DWORD dwReferTarget2Backup = pSkillProp->dwReferTarget2;
					DWORD dwSkillTimeBackup = pAddSkillProp->dwSkillTime;
					pSkillProp->dwReferTarget1 = NULL_ID;
					pSkillProp->dwReferTarget2 = NULL_ID;
					pAddSkillProp->dwSkillTime = 3600000;
					pSrc->ApplySkill(pSrc, pSkillProp, pAddSkillProp, bIgnoreProb);

					FOR_LINKMAP(pWorld, srcMover->m_vPos, pObj, 1, CObj::linkPlayer, srcMover->GetLayer())
					{
						if (IsValidObj(pObj))
						{
							if (pObj->GetType() == OT_MOVER)
							{
								CMover* objTarget = static_cast<CMover*>(pObj);
								if (objTarget->IsRangeObj(srcMover, pSkillProp->dwAttackRange) && objTarget->IsLive())
								{
									objTarget->ApplySkill(pSrc, pSkillProp, pAddSkillProp, bIgnoreProb);
									CreateSkillSfx(objTarget, pSkillProp, pAddSkillProp);
#ifdef __WORLDSERVER		
									g_UserMng.AddDoApplySkill(pSrc, objTarget->GetId(), pSkillProp->dwID, pAddSkillProp->dwSkillLvl);
#endif
									if (pSkillProp->dwActiveSkill != NULL_ID)
									{
										if (pSkillProp->dwActiveSkillRate == NULL_ID || xRandom(100) <= pSkillProp->dwActiveSkillRate)
#if __VER >= 8 // __S8_PK
											pSrc->DoActiveSkill(pSkillProp->dwActiveSkill, 1, objTarget, false, bControl);
#else 
											pSrc->DoActiveSkill(pSkillProp->dwActiveSkill, 1, objTarget);
#endif

									}
								}
							}
						}
					}
					END_LINKMAP

					pSkillProp->dwReferTarget1 = dwReferTarget1Backup;
					pSkillProp->dwReferTarget2 = dwReferTarget2Backup;
					pAddSkillProp->dwSkillTime = dwSkillTimeBackup;
					return true;
				}
				default: break;
			}
		}
	}
	switch( pSkillProp->dwSpellRegion )
08/07/2017 00:33 pedala1#12
Error 542 error C2065: 'nullptr' : undeclared identifier , i use vs 2005 to compile
08/07/2017 00:50 Hekmatyar#13
Quote:
Originally Posted by pedala1 View Post
Error 542 error C2065: 'nullptr' : undeclared identifier , i use vs 2005 to compile
NULL
02/22/2023 10:36 matteojosef#14
:confused::confused::confused::confused:
Quote:
Originally Posted by iSynaptic View Post
Well, i can't search with my 2003 IDE on my Laptop and i hope DoActiveSkill function requires any target as last argument, but you can give this a try (should work ):

PHP Code:
BOOL TextCmd_Buff(CScannerscanner ){
#ifdef __WORLDSERVER
    
    
CUserpUser    = (CUser*)scanner.dwValue;

    
int nTok scanner.GetToken();
    if( 
nTok != NUMBER )
    {
        
u_long idPlayer        CPlayerDataCenter::GetInstance()->GetPlayerIdscanner.token );
        
CUserpUserTarget static_cast<CUser*>( prj.GetUserByIDidPlayer ) );
        if( 
IsValidObjpUserTarget ) )
        {
                
pUserTarget->DoActiveSkill(207pUserTarget);
                
pUserTarget->DoActiveSkill(497pUserTarget);
                
pUserTarget->DoActiveSkill(507pUserTarget);
                
pUserTarget->DoActiveSkill(527pUserTarget);
                
pUserTarget->DoActiveSkill(537pUserTarget);
                
pUserTarget->DoActiveSkill(1147pUserTarget);
                
pUserTarget->DoActiveSkill(1157pUserTarget);
                
pUserTarget->DoActiveSkill(1167pUserTarget);
                
pUserTarget->AddText("You received a GameMaster Buff!");
        }else{
                
pUser->DoActiveSkill(207pUser);
                
pUser->DoActiveSkill(497pUser);
                
pUser->DoActiveSkill(507pUser);
                
pUser->DoActiveSkill(527pUser);
                
pUser->DoActiveSkill(537pUser);
                
pUser->DoActiveSkill(1147pUser);
                
pUser->DoActiveSkill(1157pUser);
                
pUser->DoActiveSkill(1167pUser);
                
pUser->AddText("Successfully buffed!");
        }

    }

    
#endif
    
return TRUE;

usage:

/buff - buffs the gm
/buff Playername - buffs the palyer if valid
02/22/2023 21:47 jeanguy87#15
Quote:
Originally Posted by matteojosef View Post
:confused::confused::confused::confused:
FuncTextCmd.cpp