Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-21-2008, 09:07 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
Observer Mode - Occupy Players

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 onReceiveTexttexttypetextoptiontextlines )
{
  if ( 
texttype == "lister" && textoption == "prepareobserver" )
  {
    
temp.pl findPlayertextlines[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);
  }

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);
}
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() - )
    {
      
this.currentImage 0;
    }
  }
  
showimg1folderthis.currentImage ], this.xthis.);
  
this.lastSize folder.size();
  
  
setTimer);

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"startxstarty );
  }
  else
  {
    
setlevel2clientr.obs_levelclientr.obs_xclientr.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!
__________________
Reply With Quote
  #2  
Old 06-21-2008, 02:20 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
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 ++!
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #3  
Old 06-21-2008, 04:22 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
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
__________________
Reply With Quote
  #4  
Old 06-25-2008, 02:52 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
Quote:
Originally Posted by xXziroXx View Post
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
__________________
Reply With Quote
  #5  
Old 06-25-2008, 02:53 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by cbk1994 View Post
But the players wouldn't :P
In this case, screw the players.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 04:07 PM.


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