Introduction
I wrote a little script for Vesporia which does this:
1) When players are about to go on observer mode, warps them to a level
2) In that level, displays a rotating list of images
This removes observers from the main levels as to not disturb events, etc, and adds them to the level. They are then shown any images you have uploaded to a certain folder.
Creating the Folder
I created a folder called
PHP Code:
levels/images/observer/
You will need to add this to folder options:
PHP Code:
file images/observer/*
and you will need to add this folder right to your own account, and (npcserver)
PHP Code:
rw levels/images/observer/*
(note: You can give the NPC-Server just the read right if you want)
Now, upload as many image files as you want into the folder you created. You can upload PNGs, MNGs, GIFs, and JPGs. I added 10-20 'motivator' images to the folder.
These images will be shown to players on observer mode.
Remember, inappropriate images will most likely get you in trouble
-BANHAMMA-.
Script
Create a new database NPC called "GlobalShopControl". You
must name it this, because this is the npc that gets called.
In this database NPC, add this code.
PHP Code:
function onReceiveText( texttype, textoption, textlines )
{
if ( texttype == "lister" && textoption == "prepareobserver" )
{
temp.pl = findPlayer( textlines[0] );
if ( pl == NULL )
{
return;
}
pl.clientr.obs_level = pl.level.name;
pl.clientr.obs_x = pl.x;
pl.clientr.obs_y = pl.y;
pl.setlevel2( "myobserverlevel.nw", 0, 0 );
}
}
The only thing you need to change is 'myobserverlevel.nw'. Change this to the level you create which has the script. I'll explain this below.
Now, make a class called "class_observer" (or anything else you want). In that class, add this script:
PHP Code:
function onCreated()
{
setTimer( 1 );
}
function onTimeOut()
{
temp.folder.loadFolder( "levels/images/observer/*", false );
if ( folder.size() != this.lastSize )
{
this.currentImage = 0;
}
else
{
this.currentImage ++;
if ( this.currentImage > folder.size() - 1 )
{
this.currentImage = 0;
}
}
showimg( 1, folder[ this.currentImage ], this.x, this.y );
this.lastSize = folder.size();
setTimer( 7 );
}
In this script, you won't need to change anything unless you changed the folder, or want to change the speed.
To change the folder, change
PHP Code:
temp.folder.loadFolder( "levels/images/observer/*", false );
to
PHP Code:
temp.folder.loadFolder( "levels/myFolder/*", false );
Now, in the Control-NPC script, add this under the onActionPlayerOnline() function:
PHP Code:
if ( player.level.name == "vsp_observer.nw" )
{
if ( clientr.obs_level == null )
{
setlevel2( "myStartLevel.nw", startx, starty );
}
else
{
setlevel2( clientr.obs_level, clientr.obs_x, clientr.obs_y );
}
}
Make sure to change "myStartLevel", startx, and starty to your starting level, or your unstick level, or wherever you want the players to go if they don't have a saved starting location.
Now, you need to make a level. Name it whatever you named the level in the "GlobalShopControl" NPC. In this level, at ( 0, 0 ) put a level NPC with this code:
PHP Code:
join( "class_observer" );
Be sure to change 'class_observer' to whatever you named the class if it differs.
Demo
--
Comments and criticisms please!
