Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-29-2007, 05:21 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Advanced Control-NPC

Here is an advanced (sorta) Control-NPC script I made that is easy to customize for your server. I'll go threw the steps (below the code).

If you notice anythnig that is still specific to my server, please tell me and I will remove it! I think I got everything.

Here is the code:

Code of DB-NPC Control-NPC
PHP Code:
function onCreated()
{
  
this.logPlayer true// Log logging in and out
  
this.announcePlayer false// Announce in RC logging in and out
  
this.joinFile "control/serverJoin.txt"// File that contains classes to join player to
  
this.weaponsFile "control/serverWeapons.txt"// File that contains list of weapons to add
  
this.notifyFile "control/serverNotify.txt"// List of players that are on notify
  
this.pmFile "control/serverMessage.txt"// The PM the npc-server sends you
  
  
this.joinMessage "This message appears in RC when you log in!";
  
  
/*
    Vars to reset when you log in.
    For example, { clientr.disconnected, false } would set
    clientr.disconnected to false. It's really quite handy.
    For player. vars, don't include the player.
  */
  
this.resetVars = {
                     { 
"clientr.gun_id"},
                     { 
"client.frozen"false }
                   };
}
// Nothing you need to change here.
function onActionPlayerOnline()
{
  if ( 
this.joinFile != NULL )
  {
    for ( 
temp.getJoin() )
    {
      
player.jointemp.);
    }
  }
  if ( 
this.joinMessage != NULL )
  {
    echo( 
this.joinMessage );
  }
  if ( 
this.logPlayer )
  {
    
savelog2"login.txt""Player" SPC player.account SPC "logged in!" );
  }
  if ( 
this.announcePlayer )
  {
    
sendToRCplayer.account SPC "logged in!" );
  }
  if ( 
this.resetVars != NULL )
  {
    for ( 
temp.this.resetVars )
    {
      
makevar"player." temp.a[0] ) = temp.a[1];
    }
  }
  if ( 
this.weaponsFile != NULL )
  {
    for ( 
temp.getWeapons() )
    {
      
player.addweapontemp.);
    }
  }
  
temp.getNotify();
  if ( 
temp.n.index( @ player.account ) > -)
  {
    echo( 
"Notify:" SPC player.account SPC "has logged on!" );
    
savelog2"notify.txt""Player" SPC player.account SPC "logged on." );
  }
  
  if ( 
this.pmFile != NULL )
  {
    
sendPMgetPM() );
  }
  
specialLogin();
}
function 
onPlayerLogOutpl )
{
  if ( 
pl.level.name == NULL )
  {
    return;
  }
  if ( 
this.logPlayer )
  {
    
savelog2"login.txt""Player" SPC pl.account SPC "logged out!" );
  }
  if ( 
this.announcePlayer )
  {
    
sendToRCpl.account SPC "logged out!" );
  }
}
function 
specialLogin()
{
  
// Special things you need to do to the player on login.
  // for example,
  // player.login();
  // or player.unstick();
}
function 
getWeapons()
{
  
temp.lines.loadLinesthis.weaponsFile );
  for ( 
temp.temp.lines )
  {
    
temp.i.addtemp.);
  }
  return 
temp.i;
}
function 
getNotify()
{
  
temp.lines.loadLinesthis.notifyFile );
  for ( 
temp.temp.lines )
  {
    
temp.i.addtemp.);
  }
  return 
temp.i;
}
function 
getJoin()
{
  
temp.lines.loadLinesthis.joinFile );
  for ( 
temp.temp.lines )
  {
    
temp.i.addtemp.);
  }
  return 
temp.i;
}
function 
getPM()
{
  
temp.lines.loadLinesthis.pmFile );
  for ( 
temp.temp.lines )
  {
    
temp.@= temp."\n";
  }
  return 
temp.i;

Steps to Install the code:
1) Set this.logPlayer and this.announcePlayer to what you prefer. logPlayer logs when a player logs in or out. announcePlayer announces in RC when a player logs in or out.

2) Set all the different files. joinFile is the list of classes to be joined to the player. weaponsFile is a list of the weapons to be added to the player. notifyFile is a list of players that when logged in display a notice on RC, hence the name. Are also logged. pmFile is the pm that the NPC-server sends on logon. You can leave any one of these blank to disable it.

3) Set this.joinMessage. This is displayed in RC when a player logs on. You could do something like "STOP WATCHING RC! GO DEVELOP!". Leave blank to disable.

4) Set this.resetVars. This is handy for setting vars on login, such as clientr.frozen and clientr.disconnect. The format is { VAR, VALUE }. For player. vars, leave out the player., so it would be fullhearts, x, y, z, etc.

5) Leave everything alone until you get down to specialLogin() function.

6) Here put custom login things. For example, you may want to warp the player to a certain level when they login. Add that here. Maybe you need to do something special with a DB NPC when they log in. Add that here.

7) Add all of this in the DB-NPC Control-NPC. If you need help with that, ask me!


If you have any questions about any of this, please tell me and I will be happy to help! If I find bugs I will fix the code. Thank you!

Please, please, PLEASE, leave me feedback, this is my first useful script I've released since my return, so I'm wondering if it is any good.

Thank you!
Chris Zakuto

PS: Don't tell MiZZo (Jave), he'll freak out. He doesn't like me giving away scripts on [CENSORED UNTIL LATER NOTICE] that I make. Oh well.
__________________
Reply With Quote
 


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 02:47 PM.


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