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", 0 },
{ "client.frozen", false }
};
}
// Nothing you need to change here.
function onActionPlayerOnline()
{
if ( this.joinFile != NULL )
{
for ( temp.a : getJoin() )
{
player.join( temp.a );
}
}
if ( this.joinMessage != NULL )
{
echo( this.joinMessage );
}
if ( this.logPlayer )
{
savelog2( "login.txt", "Player" SPC player.account SPC "logged in!" );
}
if ( this.announcePlayer )
{
sendToRC( player.account SPC "logged in!" );
}
if ( this.resetVars != NULL )
{
for ( temp.a : this.resetVars )
{
makevar( "player." @ temp.a[0] ) = temp.a[1];
}
}
if ( this.weaponsFile != NULL )
{
for ( temp.a : getWeapons() )
{
player.addweapon( temp.a );
}
}
temp.n = getNotify();
if ( temp.n.index( @ player.account ) > -1 )
{
echo( "Notify:" SPC player.account SPC "has logged on!" );
savelog2( "notify.txt", "Player" SPC player.account SPC "logged on." );
}
if ( this.pmFile != NULL )
{
sendPM( getPM() );
}
specialLogin();
}
function onPlayerLogOut( pl )
{
if ( pl.level.name == NULL )
{
return;
}
if ( this.logPlayer )
{
savelog2( "login.txt", "Player" SPC pl.account SPC "logged out!" );
}
if ( this.announcePlayer )
{
sendToRC( pl.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.loadLines( this.weaponsFile );
for ( temp.a : temp.lines )
{
temp.i.add( temp.a );
}
return temp.i;
}
function getNotify()
{
temp.lines.loadLines( this.notifyFile );
for ( temp.a : temp.lines )
{
temp.i.add( temp.a );
}
return temp.i;
}
function getJoin()
{
temp.lines.loadLines( this.joinFile );
for ( temp.a : temp.lines )
{
temp.i.add( temp.a );
}
return temp.i;
}
function getPM()
{
temp.lines.loadLines( this.pmFile );
for ( temp.a : temp.lines )
{
temp.i @= temp.a @ "\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.