Page 1 of 1

Reserving playernames?

PostPosted: Mon Jul 25, 11 11:57 am
by Shinobi
Is it possible to create something to disallow certain playernames? i.e. reserve a playername to an ip range or domain name?

PostPosted: Tue Jul 26, 11 12:50 am
by Aidan
I'm pretty sure this has already been invented.

Check the download archives.

PostPosted: Thu Jul 28, 11 12:50 am
by Shinobi
Okay thanks. *looks*

PostPosted: Thu Jul 28, 11 10:25 am
by Dae
I also think I've seen this feature, but I don't remember what mutator implements it.

PostPosted: Thu Jul 28, 11 12:32 pm
by ~DJ~
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;

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"
}


It's untested..

Can't say it would work definitely.. but I see nothing wrong, Tommorow I'll test it just incase.

PostPosted: Thu Jul 28, 11 1:19 pm
by Shinobi
Can you make it so it can check against a domain (i have dynamic ip) eg: shinobidx87@servebeer.com

would that work? I could try the one above now, i'll let u know if u dont test it before me

PostPosted: Thu Jul 28, 11 1:39 pm
by Alex
~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.

Don't you think that will totally spam the serverlog & player ever 0.1 second? =/ It doesn't remember if it checked a player or not. Thus if someone enters with a name in the list, and he HAS the correct IP address, it keeps saying "WELCOME!" x10 per second.

PostPosted: Thu Jul 28, 11 2:01 pm
by Dae
~DJ~ wrote:I thought of having a quick go.. haven't tested this but something like this should do the trick..

It's a better idea to use a function such as ModifyPlayer which is called every time player respawns, instead of Timer().

PostPosted: Thu Jul 28, 11 4:24 pm
by ~DJ~
Ooh.. yeah.. dint thought about that...thanks Alex for pointing out. :oops:

I actually edited one of the stuff I did for IP stuff.

Thanks for the ModifyPlayer thingie, Dae; Although I was just pointing out a basic idea anyhow, something like that doing the trick. :oops:

Shinobi wrote:Can you make it so it can check against a domain (i have dynamic ip) eg: shinobidx87@servebeer.com


Well.. that's the problem. This IP stuff isn't generally used because of people having dynamic IPs. I'm not sure but I suppose it's not possible..

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. :o

PostPosted: Thu Jul 28, 11 4:42 pm
by Alex
~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. :o

Just read the code that checks if a joining player is banned or not:
Code: Select all
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;
}

PostPosted: Thu Jul 28, 11 9:17 pm
by Shinobi
Does this work?