logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
DM's based upon database

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
Nul_Char



Joined: 11 Jan 2005
Posts: 4

PostPosted: Sat Mar 19, 2005 18:30    Post subject: DM's based upon database Reply with quote

I remember somewhere I saw a message that talk about using NWNX to allow DM login's. Then it would boot people that try to login as DM, however not on the list. Does someone have this script?

Thanks!
Nul_Char
Back to top
View user's profile Send private message
Lokey



Joined: 02 Jan 2005
Posts: 158

PostPosted: Sun Mar 20, 2005 6:28    Post subject: Reply with quote

I'd use public cd key over account name (trivial to use someone else's account, sadly). Then simply check if they're a DM on enter, and compare the cdkey to what you have in your database, if not found boot them.
_________________
Neversummer PW NWNx powered mayhem Wink
Back to top
View user's profile Send private message
Liberty Valance



Joined: 06 Jan 2005
Posts: 21
Location: A Persistent World West2

PostPosted: Sun Mar 20, 2005 21:02    Post subject: Reply with quote

that'd be me... it's an easy task to change it to CD key if you want... however, i trust my DMs to be savvy enough to make a password that's hard to guess, and not give it out to anyone. this way, they can log in at a friend's house or whatever, and aren't restricted to logging in from their home computer. also, it's much easier to find their login name (just talk to them), as opposed to having to write a script to grab their public CD key Wink

Here's how mine works...
you may want to make some modifications - mine uses a table called "dmauth" with two columns, "isdm" and "playername"

Code:

int GetStatus(object oEnteringPC) {
  int iStatus = 0;
  // pull status from the DB, if there is no entry for the player, will return zero
  SQLExecDirect("SELECT `isdm` FROM `dmauth` WHERE `playername`='" + GetPCPlayerName(oEnteringPC) + "'");

  if (SQLFetch() != SQL_ERROR) {
    iStatus = StringToInt(SQLGetData(1));
  } else {
    // there was an error executing the SQL statement (DB down?)
    // return error code indicating such
    iStatus = -1;
  }

  return iStatus;
}

void main {}
{
  // Your onClientEnter code may already have an object for GetEnteringObject(); if you wish to use that object instead,
  // simply remove this line and replace all instances of "oEnteringPC" in this sample main() with your object name
  object oEnteringPC = GetEnteringObject();
  int isRealDM = GetStatus(oEnteringPC);

  // There was a problem with the SQL query - boot the player, to prevent potential issues
  //with unusual characters in login name or other such exploits
  if (isRealDM == -1) {
    DelayCommand(0.1, WriteTimestampedLogEntry("Player " +
      GetPCPlayerName(oEnteringPC) + " - invalid SQL query in GetStatus() in onClientEnter event"));
    DelayCommand(1.0, BootPC(oEnteringPC));
  }

  // If GetStatus() did not return 1 but player is attempting to log in as DM, they aren't authorized.  Boot them.
  if (GetIsDM(oEnteringPC) && isRealDM != 1) {
    // Log it for posterity
    DelayCommand(0.1, WriteTimestampedLogEntry("Player " +
      GetPCPlayerName(oEnteringPC) + " attempted to log in" +
      " as DM, without authorization, from " + GetPCIPAddress(oEnteringPC) + "!"));
    DelayCommand(1.0, BootPC(oEnteringPC));
    return;
  }

  //...
  // Your on client enter code here
  //...
}


enjoy!
_________________
A Persistent World West2 | APWW2 Forums
Wirehead Studios
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group