[Src]->banip command

Codes already submitted by people of the forums.
Post Reply
Blizaga
Regular
Posts: 68
Joined: Sat Jul 08, 2006 7:39 pm

Post by Blizaga »

this command ban the ip of any player online. to use it u have do the next steps.

in Game.cpp add:

Code: Select all

void CGame::AdminOrder_BanIP(int iClientH, char *pData, DWORD dwMsgSize)
{
 char   seps[] = "= \t\n";
 char   * token, cBuff[256];
 class  CStrTok * pStrTok;
 char * pk;
 char cMsg[100], cNick[20], cIPtoBan[15];
 int i;
 FILE * pFile;
 if (m_pClientList[iClientH] == NULL) return;
 if ((dwMsgSize) <= 0) return;
 if (m_pClientList[iClientH]->m_iAdminUserLevel <= 0) {
   SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_ADMINUSERLEVELLOW, NULL, NULL, NULL, NULL);
   return;
 }
 if (m_pClientList[iClientH]->m_bIsAdminCommandEnabled == FALSE) return;

 ZeroMemory(cBuff, sizeof(cBuff));
 memcpy(cBuff, pData, dwMsgSize);
 pStrTok = new class CStrTok(cBuff, seps);
 token = pStrTok->pGet();
 token = pStrTok->pGet();
 if (token == NULL) {
   delete pStrTok;
   return;
   } 
   strcpy(cNick, token);
   pk = pStrTok->pGet();

   for (i = 0; i < DEF_MAXCLIENTS; i++)  {
     if ((m_pClientList[i] != NULL) && (memcmp(m_pClientList[i]->m_cCharName, cNick, strlen(cNick)) == 0)) {
   strcpy(cIPtoBan, m_pClientList[i]->m_cIPaddress);
        //opens cfg file
  	pFile = fopen("..\\GameConfigs\\BannedList.cfg", "a"); 
  	//notifys to player banned
    wsprintf(cMsg,"You will be banned from the server right now!");
    ShowClientMsg(i, cMsg);
  	//notifys to game master the ban is success
    wsprintf(cMsg,"%s was banned ip.",m_pClientList[iClientH]->m_cCharName);
    ShowClientMsg(iClientH, cMsg);
  	//shows log
    wsprintf(G_cTxt,"<%d> Client IP Banned: (%s)", i, cIPtoBan);
    PutLogList(G_cTxt);
  	//modifys cfg file
    fprintf(pFile, "\nbanned-ip = %s", cIPtoBan);
    fclose(pFile);
  	//updates BannedList.cfg on the server
    LocalUpdateConfigs(3);
  	//disconnects player, and he can't connect again.. :)
    DeleteClient(i, TRUE, TRUE);
  	return;
     }
   }
   delete pStrTok;
}

In Game.cpp in ChatMsgHandler(); add

Code: Select all

  if (memcmp(cp, "/banip ", 7) == 0) {
  	AdminOrder_BanIP(iClientH, cp, dwMsgSize - 21);
  	return;
  }
in Game.h add

Code: Select all

void AdminOrder_BanIP(int iClientH, char *pData, DWORD dwMsgSize);
Enjoy B)
<a href='http://imageshack.us' target='_blank'><img src='http://img224.imageshack.us/img224/2738/screenqu8.jpg' border='0' alt='user posted image' /></a><br>drajwer draw<br><a href='index.php?showtopic=7299' target='_blank'>index.php?showtopic=7299</a>
maxichalba
noob
Posts: 27
Joined: Sun Aug 27, 2006 4:50 am

Post by maxichalba »

:| w00t really cool dude!!!!!
SlammeR
Loyal fan
Posts: 219
Joined: Fri Nov 04, 2005 1:52 am
Location: Brazil

Post by SlammeR »

good work ;)
OWNED!<br><img src='http://img50.imageshack.us/img50/1386/p ... 3vsqn2.gif' border='0' alt='user posted image' /><br><br><img src="http://hbtop50.com/button.php?u=hbuonline" alt="Helbreath Top 50 - Keepin' it real." border="0" /><br><a href='http://www.hbuonline.net' target='_blank'>Helbreath United</a>
Tafka12
&lt;3 bd long time
Posts: 772
Joined: Wed Dec 28, 2005 6:32 pm

Post by Tafka12 »

how should the other GM's besides to host know the IP??
Need Checkip then :P nice work anyway.
<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' />
mcgrady
noob
Posts: 23
Joined: Sat Apr 10, 2004 2:25 am

Post by mcgrady »

cool, good work!
Hepha
Regular
Posts: 31
Joined: Wed Dec 14, 2005 10:57 pm

Post by Hepha »

g00d job.. works ;)
<img src='http://img174.imageshack.us/img174/9513 ... ionrv6.png' border='0' alt='user posted image' />
xmukox
Member
Posts: 175
Joined: Sun Sep 11, 2005 9:53 am

Post by xmukox »

nice work!
Acidx
Member
Posts: 198
Joined: Tue Mar 23, 2004 4:27 am

Post by Acidx »

hmm i dont believe this works cross server well i dont think it would dc the player cross server would it?
or even get the players info for that matter..
you should add it if it doesnt ;)
and very nice code works just like mine <3
<b>-<span style='color:green'>ACiD-x </span><span style='color:red'> Owning PCs Since 1987</span><br><img src='http://img204.imageshack.us/img204/2245/hackertf5.gif' border='0' alt='user posted image' /><br><img src='http://img509.imageshack.us/img509/6697 ... 4sc4ed.png' border='0' alt='user posted image' /><br><span style='color:orange'>i am Pwn NetGAYLORDS !</span></b><br><span style='color:blue'><br>I Pwn HBUSA =)</span>
Blizaga
Regular
Posts: 68
Joined: Sat Jul 08, 2006 7:39 pm

Post by Blizaga »

u can add if the file can't be access ...

if (pFile == NULL) {
//error message
}
else{
//banned success
}
<a href='http://imageshack.us' target='_blank'><img src='http://img224.imageshack.us/img224/2738/screenqu8.jpg' border='0' alt='user posted image' /></a><br>drajwer draw<br><a href='index.php?showtopic=7299' target='_blank'>index.php?showtopic=7299</a>
Post Reply