IP Ban command by Twisted
I never tested this but it should work in theory
"/ban username"
Code:
BOOL TextCmd_BANNISH( CScanner & scanner )
{
#ifdef __WORLDSERVER
CUser* pUser = (CUser*)scanner.dwValue;
if( !IsValidObj( pUser ) )
{
pUser->AddText( "Invalid user." );
return TRUE;
}
scanner.GetToken();
u_long idTarget = CPlayerDataCenter::GetInstance()->GetPlayerId( scanner.token );
if( idTarget == 0 )
idTarget = pUser->m_idPlayer;
CUser* pTarget = g_UserMng.GetUserByPlayerID( idTarget );
if( !IsValidObj( pTarget ) )
{
pUser->AddText( "Invalid target name." );
return TRUE;
}
CString TNickName;
CString UNickName;
char szBannish[MAX_PATH];
CString strTargetIp;
CString strPath;
TNickName = pTarget->GetName();
UNickName = pUser->GetName();
CString strIp = pTarget->m_playAccount.lpAddr;
CString strAccnt = pTarget->m_playAccount.lpszAccount;
if( pUser->IsAuthHigher( AUTH_GAMEMASTER ) )
{
sprintf( szBannish, "%s , you have been Banned by [Staff member]--> %s", TNickName, UNickName );
pTarget->AddText( szBannish );
strTargetIp.Format( "%s - %s // Accnt %s UserNname %s was banned by Staff member %s ", strIp, strIp, strAccnt, TNickName, UNickName );
strPath.Format( "..\\Program\\IPCut.ini" );
DSystemLog( strTargetIp, strPath, 0 );
pUser->AddText("User has been Banned");
}
#endif // __WORLDSERVER
return TRUE;
}
Code:
ON_TEXTCMDFUNC( TextCmd_BANNISH, "ban", "BU", "BAN", "BU", TCM_SERVER, AUTH_GAMEMASTER2 , "·¹º§ ¼³Á¤ Çϱâ" )
NOTE: I MADE THIS FOR LTD SOURCE aka DITS rev 4 and up
NOTE 2: to add this to an other source you must add DSystemLog which is easy if you have read through multiple sources
EDIT: I will improve code within the next day or so, working some minor details out
let me know how it works
Re: IP Ban command by Twisted
Well this seems quite useful.
Only one question. Does the IPCut.ini file get reloaded after? If not, the ban would only take effect after a restart of the accountserver.
Re: IP Ban command by Twisted
Quote:
Originally Posted by
ShadowDragon42
Well this seems quite useful.
Only one question. Does the IPCut.ini file get reloaded after? If not, the ban would only take effect after a restart of the accountserver.
Hmm that I'm not sure of if it doesn't then you would have to find the function that bans ip's in IPCut.ini and edit it for use with a lua so you could reload after each ban
again I never really got to use this but once on myself and it worked on me but never got to ban another user
WEWT: 420th post ~ HITS BOWL
Re: IP Ban command by Twisted
Quote:
Originally Posted by
420twisted1
Hmm that I'm not sure of if it doesn't then you would have to find the function that bans ip's in IPCut.ini and edit it for use with a lua so you could reload after each ban
again I never really got to use this but once on myself and it worked on me but never got to ban another user
WEWT: 420th post ~ HITS BOWL
Yeah, I was curious when reading this. It does seem interesting and quite a good idea. Though, a couple edits and it should work just fine.
I like the idea and I am going to play with it a bit. Thanks for the release. :)
Re: IP Ban command by Twisted
Quote:
Originally Posted by
Artistic
Yeah, I was curious when reading this. It does seem interesting and quite a good idea. Though, a couple edits and it should work just fine.
I like the idea and I am going to play with it a bit. Thanks for the release. :)
good I hope it proves to be useful
Re: IP Ban command by Twisted
Quote:
Originally Posted by
420twisted1
good I hope it proves to be useful
Oh, I am sure it will. I created an MSN Bot (out of pure enjoyment) that allows my staff to ban players using [ban name how many days] which was a fun project but yeah. Lol.
I want to have a ban command in game for obvious reasons. I will definitely let you know if I can get a fully functional working ban command and release it. :)
Re: IP Ban command by Twisted
Quote:
Originally Posted by
Artistic
Oh, I am sure it will. I created an MSN Bot (out of pure enjoyment) that allows my staff to ban players using [ban name how many days] which was a fun project but yeah. Lol.
I want to have a ban command in game for obvious reasons. I will definitely let you know if I can get a fully functional working ban command and release it. :)
my Email: brandon_esqueda@live.com add me to messenger I think I already know a better way of doing this but i have to cook dinner and do some stuff but id love some one new to bounce ideas off of
Re: IP Ban command by Twisted
420twisted1 you should try it, before release it. Well doesn't really matter. I'll try it, and come back with my suggestion.
-question-
does it works with resource?
//Jellcent
Re: IP Ban command by Twisted
Quote:
Originally Posted by
Jellcent
420twisted1 you should try it, before release it
At least he's contributing to this community ... I mean, you could at least say thanks.
Quote:
Originally Posted by
Jellcent
does it works with resource?
Dude what...? You implement this in a source, not resource.
The interaction with the resource files of this snippet goes as far as writing the target players IP in IPCut.ini.
Re: IP Ban command by Twisted
cffazot - Jellcent is a new user here that's why he don't really know what source and resource yet so just remind him if what this both for.
On: Looks like this would be useful especially if you don't actually using toms antihack because atm that's the only way (i knew) to ipban a user.
Re: IP Ban command by Twisted
Take a look at dpsrvr.cpp on line 271 (AccountServer).
You should add your banned IPs like there in addition to just writing it into the "IPCut.ini". That way your bann is Active instantly.
Re: IP Ban command by Twisted
Quote:
Originally Posted by
TheRealFoam
Take a look at dpsrvr.cpp on line 271 (AccountServer).
You should add your banned IPs like there in addition to just writing it into the "IPCut.ini". That way your bann is Active instantly.
There are plenty of ways to do it, but that is what I was thinking as well. You could also reload the IPCut.ini when the /ban command is used but you'd be giving people the ability to spam the /ban command.
Though, adding a condition to the command itself should allow it to work perfectly if done right.
Re: IP Ban command by Twisted
Quote:
Originally Posted by
Artistic
There are plenty of ways to do it, but that is what I was thinking as well. You could also reload the IPCut.ini when the /ban command is used but you'd be giving people the ability to spam the /ban command.
Though, adding a condition to the command itself should allow it to work perfectly if done right.
That's one way of doing it.
The way I was considering last night, is adding an IP check to the OnCertify function in CERTIFIER\DPCertified.cpp
It checks various things there, like MSG_VER, resource modified (if you have it activated), and checking if there are single quotes in the account name or password.
Best way I can think of, is have the Certifier load a different IP bans file when it starts up. In the OnCertify function, it could check if the file was modified recently. If it was, reload it then check to see if the person logging in is able to. If it wasn't, just check them.
Re: IP Ban command by Twisted
Code:
if( !IsValidObj( pUser ) )
{
pUser->AddText( "Invalid user." );
may cause access violations. You should log the errors instead of sending them(well at least that one). Otherwise good job i guess.
Code:
if( idTarget == 0 )
idTarget = pUser->m_idPlayer;
/ban
opps...
Re: IP Ban command by Twisted
Quote:
Originally Posted by
KrYpT0n
Code:
if( !IsValidObj( pUser ) )
{
pUser->AddText( "Invalid user." );
may cause access violations. You should log the errors instead of sending them. Otherwise good job i guess.
HAH, I didn't even notice that lol KrYpT0n's right.