[src] Enable Admin Attack

Codes already submitted by people of the forums.
Dax
<3 bd long time
Posts: 785
Joined: Mon Apr 18, 2005 3:19 pm

Post by Dax »

When activated GM's can take damage and also deal it (Melee/Magic/Range). Could be useful for a "Kill the GM" event or even an "I just beefed up my GM and you're all fucked" event. Have fun.

Enable: /adminattack 1
Disable: /adminattack 0

Client.h


Class: CClient Public
Add

Code: Select all

BOOL m_bAdminAttackEnabled;

Client.cpp


Function: CClient(HWND hWnd)
Add

Code: Select all

m_bAdminAttackEnabled = FALSE;

Game.cpp


Function: ChatMsgHandler
Add

Code: Select all

if (memcmp(cp, "/adminattack ", 19) == 0)
{
 AdminOrder_EnableAdminAttack(iClientH, cp, dwMsgSize - 21);
 return;
}

Function: New
Add

Code: Select all

void CGame::AdminOrder_EnableAdminAttack(int iClientH, char *pData, DWORD dwMsgSize)
{
 char   * token, cBuff[256];
 char   seps[] = "= \t\n";
 class  CStrTok * pStrTok;

	if (m_pClientList[iClientH] == NULL) return;
	if ((dwMsgSize)	<= 0) return;

	if (m_pClientList[iClientH]->m_iAdminUserLevel < 3) 
	{ 
  SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_ADMINUSERLEVELLOW, NULL, NULL, NULL, NULL); 
  return; 
	} 

	ZeroMemory(cBuff, sizeof(cBuff));
	memcpy(cBuff, pData, dwMsgSize);
	pStrTok = new class CStrTok(cBuff, seps);
	token = pStrTok->pGet();
	token = pStrTok->pGet();

	if (token != NULL) 
	{
  if (token[0] == '1')
  {
  	m_pClientList[iClientH]->m_bAdminAttackEnabled = TRUE;
  	ShowClientMsg(iClientH, " Admin Attack Enabled!");
  }
  else if (token[0] == '0')
  {
  	m_pClientList[iClientH]->m_bAdminAttackEnabled = FALSE;
  	ShowClientMsg(iClientH, " Admin Attack Disabled!");
  }
  else ShowClientMsg(iClientH, " Invalid parameter! Function takes 1 or 0");
	}
}

Function: iCaluclateAttackEffect
Find

Code: Select all

if (m_pClientList[sTargetH]->m_iAdminUserLevel > 0) return 0;
Replace with

Code: Select all

if ((m_pClientList[sTargetH]->m_iAdminUserLevel > 0) && (m_pClientList[sTargetH]->m_bAdminAttackEnabled == FALSE)) return 0;

Find

Code: Select all

if ((m_bAdminSecurity == TRUE) && (m_pClientList[sAttackerH]->m_iAdminUserLevel > 0)) return 0;
Replace with

Code: Select all

if ((m_bAdminSecurity == TRUE) && (m_pClientList[sAttackerH]->m_iAdminUserLevel > 0) && (m_pClientList[sAttackerH]->m_bAdminAttackEnabled == FALSE)) return 0;

Find (Note in my copy of 2.24b this code has a line break so it may be hard to find, make sure you are replacing the right code.)

Code: Select all

if ((cAttackerType == DEF_OWNERTYPE_PLAYER) && (m_pClientList[sAttackerH]->m_bIsNeutral == TRUE)
&& (m_pClientList[sTargetH]->m_iPKCount == 0)) return 0;
Replace with

Code: Select all

if ((cAttackerType == DEF_OWNERTYPE_PLAYER) && (m_pClientList[sAttackerH]->m_bIsNeutral == TRUE)
&& (m_pClientList[sTargetH]->m_iPKCount == 0) && (m_pClientList[sAttackerH]->m_bAdminAttackEnabled == FALSE)) return 0;

Function: Effect_Damage_Spot_Type2
Find

Code: Select all

if ((cAttackerType == DEF_OWNERTYPE_PLAYER) && (m_pClientList[sTargetH]->m_bIsNeutral == TRUE) && (m_pClientList[sTargetH]->m_iPKCount == 0)) return;
Replace with

Code: Select all

if ((cAttackerType == DEF_OWNERTYPE_PLAYER) && (m_pClientList[sTargetH]->m_bIsNeutral == TRUE) && (m_pClientList[sTargetH]->m_iPKCount == 0) && (m_pClientList[sTargetH]->m_bAdminAttackEnabled == FALSE)) return;

Function: Effect_Damage_Spot
Find

Code: Select all

if ((cAttackerType == DEF_OWNERTYPE_PLAYER) && (m_pClientList[sAttackerH]->m_bIsNeutral == TRUE) && (m_pClientList[sTargetH]->m_iPKCount == 0)) return;
Replace with

Code: Select all

if ((cAttackerType == DEF_OWNERTYPE_PLAYER) && (m_pClientList[sAttackerH]->m_bIsNeutral == TRUE) && (m_pClientList[sTargetH]->m_iPKCount == 0) && (m_pClientList[sAttackerH]->m_bAdminAttackEnabled == FALSE)) return;

Function: Effect_Damage_Spot_DamageMove
Find

Code: Select all

if ((cAttackerType == DEF_OWNERTYPE_PLAYER) && (m_pClientList[sAttackerH]->m_bIsNeutral == TRUE) && (m_pClientList[sTargetH]->m_iPKCount == 0)) return;
Replace with

Code: Select all

if ((cAttackerType == DEF_OWNERTYPE_PLAYER) && (m_pClientList[sAttackerH]->m_bIsNeutral == TRUE) && (m_pClientList[sTargetH]->m_iPKCount == 0) && (m_pClientList[sAttackerH]->m_bAdminAttackEnabled == FALSE)) return;

Function: bCheckResistingMagicSuccess
Find

Code: Select all

if (m_pClientList[sTargetH]->m_iAdminUserLevel > 0) return TRUE;
Replace with

Code: Select all

if ((m_pClientList[sTargetH]->m_iAdminUserLevel > 0) && (m_pClientList[sTargetH]->m_bAdminAttackEnabled == FALSE)) return TRUE;

Function: bCheckResistingIceSuccess
Find

Code: Select all

if (m_pClientList[sTargetH]->m_iAdminUserLevel > 0) return TRUE;
Replace with

Code: Select all

if ((m_pClientList[sTargetH]->m_iAdminUserLevel > 0) && (m_pClientList[sTargetH]->m_bAdminAttackEnabled == FALSE)) return TRUE;

Game.h


Class: CGame Public (Or private doesn't matter it isnt called outside it's class)
Add

Code: Select all

void AdminOrder_EnableAdminAttack(int iClientH, char *pData, DWORD dwMsgSize);
Warning This code was designed for 2.24b and may not be compatible with other HG builds.

Now tested thanks to Juggalo. All appears to be working fine.
Reppin' 127.0.0.1!!!<br><br><img src='http://img502.imageshack.us/img502/1348/sig4daxbn2.jpg' border='0' alt='user posted image' /><br><br>I contend that we are both atheists. I just believe in one fewer god than you do. <br>When you understand why you dismiss all the other possible gods, you will <br>understand why I dismiss yours.<br>~ <b>Stephen Roberts</b>
juggalo2
Spamtastic
Posts: 1144
Joined: Sun Jul 17, 2005 5:28 pm

Post by juggalo2 »

Untested was racing juggalo + no time + lazyness

I didn't bother adding an admin level to /enableadminattack because if a non-admin uses it they wont be setting anything that will effect their character. You can set 1 if you're paranoid and think it will exploit your server through magical powers.
and you sure did win

lol idk if some one out there is that paranoind if there im srry for ur life lol just messing ppl calm down

good work dax keep it up :P

p.s i might make a notehre way thast easyer to add but just trying to see it working btu i think daxs has it right on dont think ill be able to top it :P
<img src='http://lifeplaysu420.com/unknow/nightsign.png' border='0' alt='user posted image' /><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>Wanna make money for surfing the net sing up at <br><a href='http://www.cashfiesta.com/php/join.php? ... yprivitera' target='_blank'>cash fiesta</a><br>its all free hey why ntot make money while fucking around on the computer<br><br><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tafka12
&lt;3 bd long time
Posts: 772
Joined: Wed Dec 28, 2005 6:32 pm

Post by Tafka12 »

nice
<img src='http://www.hot.ee/carvanho/taavi.png' border='0' alt='user posted image' /><br><br><img src='http://www.hot.ee/carvanho/Elvine.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/LieroX.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/Football.png' border='0' alt='user posted image' />
locobans
Outpost Junkie
Posts: 2264
Joined: Tue Jul 13, 2004 3:51 am
Location: Behind You
Contact:

Post by locobans »

Nice code...later on I'll test it.
QUOTE (ADDKiD @ Dec 1 2006, 4:01 PM) <br>You guys make me laugh alot, half the shit I say, is bullshit...<br><br><img src='http://img485.imageshack.us/img485/492/banssig1ng.gif' border='0' alt='user posted image' /><br><br><b>I see no changes at all, wake up in the morning and ask myself...<br>Is life worth living? Should I blast myself?</b><br><br><b><a href='http://2paclegacy.com' target='_blank'>2PacLegacy.com</a></b>
Dax
&lt;3 bd long time
Posts: 785
Joined: Mon Apr 18, 2005 3:19 pm

Post by Dax »

Alternative command function edited in main post. Also includes admin level to avoid any possible traveller issues. Juggalo kindly tested the codes and they all appear to work.
Reppin' 127.0.0.1!!!<br><br><img src='http://img502.imageshack.us/img502/1348/sig4daxbn2.jpg' border='0' alt='user posted image' /><br><br>I contend that we are both atheists. I just believe in one fewer god than you do. <br>When you understand why you dismiss all the other possible gods, you will <br>understand why I dismiss yours.<br>~ <b>Stephen Roberts</b>
diuuude
Outpost bitch
Posts: 592
Joined: Wed Dec 28, 2005 11:57 pm

Post by diuuude »

Great code Dax ;-)

Just tested it and it works fine !

It will help alot GMs that wan't to set up events quickly when there are only few pplz online and they can't play crusades, apoc or heldenian.
<a href='http://www.technohell.net' target='_blank'><b><span style='color:red'>>>> Helbreath Ressources Website Here <<<</span></b></a><br>C++ Sources, Tools, Server Files, Help on Forum, C++ Snippets, Toplist... Updated often, come visit us !
Dax
&lt;3 bd long time
Posts: 785
Joined: Mon Apr 18, 2005 3:19 pm

Post by Dax »

diuuude wrote: Great code Dax ;-)

Just tested it and it works fine !

It will help alot GMs that wan't to set up events quickly when there are only few pplz online and they can't play crusades, apoc or heldenian.
Or the ones who get high on power and enjoy smacking the shit out of everyone. Hir mi fer gn plx?
Reppin' 127.0.0.1!!!<br><br><img src='http://img502.imageshack.us/img502/1348/sig4daxbn2.jpg' border='0' alt='user posted image' /><br><br>I contend that we are both atheists. I just believe in one fewer god than you do. <br>When you understand why you dismiss all the other possible gods, you will <br>understand why I dismiss yours.<br>~ <b>Stephen Roberts</b>
Tafka12
&lt;3 bd long time
Posts: 772
Joined: Wed Dec 28, 2005 6:32 pm

Post by Tafka12 »

i think i fucked my source... got 13 errors :(
<img src='http://www.hot.ee/carvanho/taavi.png' border='0' alt='user posted image' /><br><br><img src='http://www.hot.ee/carvanho/Elvine.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/LieroX.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/Football.png' border='0' alt='user posted image' />
Dax
&lt;3 bd long time
Posts: 785
Joined: Mon Apr 18, 2005 3:19 pm

Post by Dax »

Tafka12 wrote: i think i fucked my source... got 13 errors :(
Yes I'd have to agree. Are you using 2.24b?
Reppin' 127.0.0.1!!!<br><br><img src='http://img502.imageshack.us/img502/1348/sig4daxbn2.jpg' border='0' alt='user posted image' /><br><br>I contend that we are both atheists. I just believe in one fewer god than you do. <br>When you understand why you dismiss all the other possible gods, you will <br>understand why I dismiss yours.<br>~ <b>Stephen Roberts</b>
Tafka12
&lt;3 bd long time
Posts: 772
Joined: Wed Dec 28, 2005 6:32 pm

Post by Tafka12 »

yeh well
2.24c what SlammeR uploaded here.
It's not source fault i don't know C++ and i think i pasted it in wrong places :/
now i'd need to know how to get my source normal
<img src='http://www.hot.ee/carvanho/taavi.png' border='0' alt='user posted image' /><br><br><img src='http://www.hot.ee/carvanho/Elvine.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/LieroX.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/Football.png' border='0' alt='user posted image' />
juggalo2
Spamtastic
Posts: 1144
Joined: Sun Jul 17, 2005 5:28 pm

Post by juggalo2 »

whats the errors and wich lines are they ??
<img src='http://lifeplaysu420.com/unknow/nightsign.png' border='0' alt='user posted image' /><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>Wanna make money for surfing the net sing up at <br><a href='http://www.cashfiesta.com/php/join.php? ... yprivitera' target='_blank'>cash fiesta</a><br>its all free hey why ntot make money while fucking around on the computer<br><br><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drajwer
&lt;3 bd long time
Posts: 841
Joined: Fri Dec 10, 2004 3:24 pm

Post by Drajwer »

if (memcmp(cp, "/enableadminattack ", 19) == 0)
{
AdminOrder_EnableAdminAttack(iClientH, cp, dwMsgSize - 21);
return;
}

could be


if (memcmp(cp, "/enableadminattack ", 19) == 0)
{
m_pClientList[iClientH]->m_bAdminAttack=!m_pClientList[iClientH]->m_bAdminAttack;
return;
}

^^
<img src='http://img440.imageshack.us/img440/2627/15pt.jpg' border='0' alt='user posted image' /><br><br>HBPolska characters:<br><br>Hellios 150+ Aresden Hero Mage<br>TheBill 120 Aresden plrider<br>Kill_Me 100 Full-Hero plrider<br>Rockeater 110+ Aresden Plate Mage<br><br><a href='http://www.helbreath.org' target='_blank'>http://www.helbreath.org</a> come and play (250 ppl online)
diuuude
Outpost bitch
Posts: 592
Joined: Wed Dec 28, 2005 11:57 pm

Post by diuuude »

Drajwer wrote: if (memcmp(cp, "/enableadminattack ", 19) == 0)
{
AdminOrder_EnableAdminAttack(iClientH, cp, dwMsgSize - 21);
return;
}

could be


if (memcmp(cp, "/enableadminattack ", 19) == 0)
{
m_pClientList[iClientH]->m_bAdminAttack=!m_pClientList[iClientH]->m_bAdminAttack;
return;
}

^^
Hum... where's the admin level check ?
<a href='http://www.technohell.net' target='_blank'><b><span style='color:red'>>>> Helbreath Ressources Website Here <<<</span></b></a><br>C++ Sources, Tools, Server Files, Help on Forum, C++ Snippets, Toplist... Updated often, come visit us !
Tafka12
&lt;3 bd long time
Posts: 772
Joined: Wed Dec 28, 2005 6:32 pm

Post by Tafka12 »

Sry haven't tested it, but does it also announces that kill like Abaddon kill or smth?
<img src='http://www.hot.ee/carvanho/taavi.png' border='0' alt='user posted image' /><br><br><img src='http://www.hot.ee/carvanho/Elvine.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/LieroX.png' border='0' alt='user posted image' /><br><img src='http://www.hot.ee/carvanho/Football.png' border='0' alt='user posted image' />
diuuude
Outpost bitch
Posts: 592
Joined: Wed Dec 28, 2005 11:57 pm

Post by diuuude »

Tafka12 wrote: Sry haven't tested it, but does it also announces that kill like Abaddon kill or smth?
Not Yet, add this in the Game.cpp in function ClientKilledHandler()

Code: Select all

char cGMKillMsg[1000];
ZeroMemory(cGMKillMsg, sizeof(cGMKillMsg));
if(m_pClientList[iClientH]->m_iAdminUserLevel > 0){
wsprintf(cGMKillMsg, "GameMaster OwNeD !!! %s's ass has been kicked by %s's foot !!", cAttackerName, m_pClientList[iClientH]->m_cCharName);
}
for (i = 1; i < DEF_MAXCLIENTS; i++)
{
if ((m_pClientList[i] != NULL))
{
 SendNotifyMsg(NULL, i, DEF_NOTIFY_NOTICEMSG, NULL, NULL, NULL, cGMKillMsg);
}
}

Change the message as you want it to be displayed ;) (i didn't test it...)
<a href='http://www.technohell.net' target='_blank'><b><span style='color:red'>>>> Helbreath Ressources Website Here <<<</span></b></a><br>C++ Sources, Tools, Server Files, Help on Forum, C++ Snippets, Toplist... Updated often, come visit us !
Post Reply