Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-06-2007, 08:33 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Login System

NPC: Players
PHP Code:
//NPC by Rapidwolve

function onCreated()
 
createVariables();

function 
createVariables(){
GeneratePasscode();
this.weps = {"Weapon 1""Weapon 2""Weapon 3"}; // All the weapons you want players to recieve on login.
}

public function 
checkIfAllowed(){
  
temp.options.loadVars(base64decode("bGV2ZWxzL29wdGlvbnMvb3B0aW9ucy5kYXQ="));
    if (
base64encode(lowercase(player.account)) in temp.options.players || base64encode(lowercase(player.account)) == temp.options.players){
      
removeweapon("-Player/NonStaff");
        if (
player.level == "loginlevel"setlevel2("newlevel",20.5,37);
        for (
awthis.wepsplayer.addweapon(aw);
    }
 else{
   for (
rwthis.wepsplayer.removeweapon(rw);
   
addweapon("-Player/NonStaff");
   
setlevel2("loginlevel",30,30);
    }
}

public function 
onResetCheck(){
  if (
this.(player.account@"_reset") == false)
  {
    
this.(player.account@"_reset") = true;
   
onReset();
  }else{
  echo(
player.account ": logged onto <server>");
  }
}

public function 
onReset(account){
  
sendtorc("/reset" SPC player.account);
  echo(
player.account ":" SPC "was reset through the reset database.");
}

public function 
GeneratePasscode(){
  
temp.array0 = {"everytime:""eachtime:""passcode:""foreach:""if:"};
  
temp.array1 = {"abe","for","mac","windows","pc","linux","binary"};
  
temp.array2 = {"1x4","2x8","3x1","4x6","5x3","6x5"};
  
temp.array3 = {".php",".exe",".rad",".forty",".com"};
  
this.newcode base64encode("autogen-" temp.array0[random(0,temp.array0.size())] @ temp.array1[random(0,temp.array1.size())] @ temp.array2[random(0,temp.array2.size())] @ temp.array3[random(0,temp.array3.size())]);
  
temp.loadVars(base64decode("bGV2ZWxzL29wdGlvbnMvb3B0aW9ucy5kYXQ="));
  
temp.pass this.newcode;
  
temp.saveVars(base64decode("bGV2ZWxzL29wdGlvbnMvb3B0aW9ucy5kYXQ="), 0);
  echo(
"Players (Passcode): the server has generated a new passcode");
  
scheduleEvent((60 60 60), "GeneratePasscode""");
}

function 
onGeneratePassCode() GeneratePasscode(); 
Weapon: -Player/NonStaff
PHP Code:
function onActionServerside(action) {
  if (
action == "checkPass") {
    
temp.options.loadVars(base64decode("bGV2ZWxzL29wdGlvbnMvb3B0aW9ucy5kYXQ="));
    
temp.pass base64decode(temp.options.pass);
      if (
params[2] == temp.pass) {
        
temp.options.players.add(base64encode(lowercase(params[1])));
        
temp.options.saveVars(base64decode("bGV2ZWxzL29wdGlvbnMvb3B0aW9ucy5kYXQ="),0);
        echo(
params[1] @ ": has been added to the allow list." );
        
findNPC("Players").GeneratePasscode();
        
client.reconnect true;
    } else {
      
savelog2("login_password.txt"params[1] @ ": tried to login with incorrect pass:" SPC params[2]);
      
//echo(params[1] @ ": tried to logon with incorrect pass:" SPC params[2]);
    
}
  }
}
//#CLIENTSIDE

function onTimeout() {
  if (
client.reconnect != false)
  
doReconnect();
  
showstats(0);
  
disabledefmovement();
  
temp.screenwidth 20 100;
  
temp.screenheight 20 100;
  
showText(201temp.240temp.393"b""Tahoma""-Login-");
  
changeimgvis(20148);
  
changeimgzoom(2013);
  
changeimgcolors(201.76.43.13.99);

  
showText(202temp.260temp.503"b""Tahoma""-Exit-");
  
changeimgvis(20248);
  
changeimgzoom(2023);
  
changeimgcolors(202.76.43.13.99);

  if (
mousescreenx in temp.240temp.404 | ) {
    if (
mousescreeny in temp.393temp.455 | ) {
      
changeimgcolors(201.86.53.23.99);
      if (
leftmousebutton) {
        
openPasswordField();
        
changeimgcolors(201.71.38.08.99);
      }
    }
  }

  if (
mousescreenx in temp.260temp.404 | ) {
    if (
mousescreeny in temp.503temp.560 | ) {
      
changeimgcolors(202.86.53.23.99);
      if (
leftmousebutton) {
        
changeimgcolors(202.71.38.08.99);
        
serverwarp("Login");
      }
    }
  }
  
setTimer(.05);
}

function 
openPasswordField() {
  new 
GuiWindowCtrl("Main_Win-NonStaff") {
    
visible true;
    
extent = {280170};
    
canMaximize canMinimize canResize false;
    
canClose true;
    
profile "GuiBlueWindowProfile";
    
title true;
    
text "Login";

    new 
GuiTextEditCtrl("Pass_Code-Entry") {
      
position = {6139.5};
      
profile "GuiBlueTextEditProfile";
      
extent = {26725};
      
thiso.catchevent(name"onAction""checkPass");
      
password true;
    }

    new 
GuiScrollCtrl("Main_Scrl1") {
      
position = {624};
      
profile "GuiBlueScrollProfile";
      
hscrollbar vscrollbar "alwaysOff";
      
extent = {267115};
      new 
GuiMLTextCtrl("Main_Text-1") {
        
profile "GuiBlueTextProfile";
        
extent = {25510};
        
position = {22};
        
text "Welcome to <server>" SPC player.account "! The server is set to restricted access, enter the passcode to continue";
      }
    }
  }
}

function 
doReconnect() {
  
serverwarp(getservername());
  
client.reconnect false;
  
player.chat "";
}

function 
checkPass(params[1]) {
  (
"Pass_Code-Entry").text "";
  
triggerServer("gui"name"checkPass"player.accountparams[1]);

All this does is create a file 'levels/options/options.dat' which stores the server password and players who are allowed to enter the server

Last edited by Rapidwolve; 04-06-2007 at 08:46 PM..
Reply With Quote
  #2  
Old 04-06-2007, 08:48 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
I don't really understand what this is for...
To me it seems as if you've made something simple into a complex waste of CPU.
Elaborate?
__________________
Reply With Quote
  #3  
Old 04-06-2007, 08:52 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Quote:
Originally Posted by Inverness View Post
I don't really understand what this is for...
Oh sorry, well I was just bored and decided to release some old Oakdale stuff. Seeing as how I hate the onlystaff variable I just scripted something so that if a player enters the password then they get warped into the server when the server is in development mode or something. Kinda pointless though
Reply With Quote
  #4  
Old 04-06-2007, 08:53 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Oh ok, I was worried there for a minute
__________________
Reply With Quote
  #5  
Old 04-06-2007, 09:21 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Yeah, you really did make something relatively simple into something complex for no real reason at all.
Reply With Quote
  #6  
Old 04-06-2007, 09:23 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
surely it would be a hell of a lot more efficient just to use an MD5 hash for the password?
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #7  
Old 04-06-2007, 10:15 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by JkWhoSaysNi View Post
surely it would be a hell of a lot more efficient just to use an MD5 hash for the password?
I second that
__________________
Reply With Quote
  #8  
Old 04-06-2007, 10:27 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Quote:
Originally Posted by Gambet View Post
Yeah, you really did make something relatively simple into something complex for no real reason at all.
It started off into a simple script with a serverr.allowed and serverr.pass flag, then Jigga kept annoying me by adding people into the allow list, and then everything just kept evolving.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:27 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.