PDA

View Full Version : Observer Mode - Occupy Players


cbk1994
06-21-2008, 10:07 AM
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


levels/images/observer/


You will need to add this to folder options:


file images/observer/*


and you will need to add this folder right to your own account, and (npcserver)

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.


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:


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


temp.folder.loadFolder( "levels/images/observer/*", false );


to


temp.folder.loadFolder( "levels/myFolder/*", false );


Now, in the Control-NPC script, add this under the onActionPlayerOnline() function:


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:


join( "class_observer" );


Be sure to change 'class_observer' to whatever you named the class if it differs.


Demo

ZoOCcrfTFe8

--

Comments and criticisms please! :)

xXziroXx
06-21-2008, 03:20 PM
I'd rather have server related stuff (i.e rules, commands, background story etc) displayed in the level then 4chan stuff...

Not a huge fan of your styling, it differs too much from my own (personal opinion ftw), but the idea behind it is quite nice. Rep ++!

Chompy
06-21-2008, 05:22 PM
Hmm, what does this script do when a player enters the server in observer mode? (Ie they are in observer mode when they logon)

Will the script still keep them in the level? :o

PS: TServerPlayer.isobserver

Just a small suggestion to your script :)

cbk1994
06-25-2008, 03:52 AM
I'd rather have server related stuff (i.e rules, commands, background story etc) displayed in the level then 4chan stuff...

But the players wouldn't :P

Sorry it took a while to respond, completely forgot about this thread ;o

xXziroXx
06-25-2008, 03:53 AM
But the players wouldn't :P

In this case, screw the players. x_x