Reserving playernames?
Posted: Mon Jul 25, 11 11:57 am
Is it possible to create something to disallow certain playernames? i.e. reserve a playername to an ip range or domain name?
class NameChecker extends Mutator;
var() config string NameToCheck;
var() config string IPToCheck;
var PlayerPawn Player;
function PreBeginPlay()
{
Level.Game.BaseMutator.AddMutator(Self);
Super.PreBeginPlay();
SetTimer(0.1);
}
function Timer()
{
local string IP;
if(DeusExPlayer(Player).PlayerReplicationInfo.PlayerName~=NameToCheck))
{
IP = DeusExPlayer(Player).GetPlayerNetworkAddress();
IP = Left(IP, InStr(IP, ":"));
Log(Player.PlayerReplicationInfo.PlayerName$"("$IP$") Found.");
if(IP!=IPToCheck)
{
Player.ClientMessage("You're not allowed to use this name");
//Player.ConsoleCommand("debug gpf");
//-- Perhaps even rename?
Player.ConsoleCommand("setname IM-STOPEED");
}
else if(IP==IPToCheck)
{
Player.ClientMessage("Welcome, "$NameToCheck$);
}
}
Super.Timer();
}
defaultproperties
{
NameToCheck="Shinobi"
IPToCheck="127.0.0.1"
}
~DJ~ wrote:I thought of having a quick go.. haven't tested this but something like this should do the trick..
- Code: Select all
class NameChecker extends Mutator;
It's untested..
Can't say it would work definitely.. but I see nothing wrong, Tommorow I'll test it just incase.
~DJ~ wrote:I thought of having a quick go.. haven't tested this but something like this should do the trick..
Shinobi wrote:Can you make it so it can check against a domain (i have dynamic ip) eg: shinobidx87@servebeer.com
~DJ~ wrote:Are IPs THAT THAT dynamic? I thought only the last digits change.. last I checked it's possible to add a wildcard in an IP ban manually on the DeusEx.ini.. wonder if that would be possible on checking IP.. Not sure how would I get a wildcard on a string though.
function bool CheckIPPolicy(string Address)
{
local int i, j, LastMatchingPolicy;
local string Policy, Mask;
local bool bAcceptAddress, bAcceptPolicy;
// strip port number
j = InStr(Address, ":");
if(j != -1)
Address = Left(Address, j);
bAcceptAddress = True;
for(i=0; i<50 && IPPolicies[i] != ""; i++)
{
j = InStr(IPPolicies[i], ",");
if(j==-1)
continue;
Policy = Left(IPPolicies[i], j);
Mask = Mid(IPPolicies[i], j+1);
if(Policy ~= "ACCEPT")
bAcceptPolicy = True;
else
if(Policy ~= "DENY")
bAcceptPolicy = False;
else
continue;
j = InStr(Mask, "*");
if(j != -1)
{
if(Left(Mask, j) == Left(Address, j))
{
bAcceptAddress = bAcceptPolicy;
LastMatchingPolicy = i;
}
}
else
{
if(Mask == Address)
{
bAcceptAddress = bAcceptPolicy;
LastMatchingPolicy = i;
}
}
}
if(!bAcceptAddress)
Log("Denied connection for "$Address$" with IP policy "$IPPolicies[LastMatchingPolicy]);
return bAcceptAddress;
}