Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   catch player leaving level (https://forums.graalonline.com/forums/showthread.php?t=134260131)

sssssssssss 08-09-2010 06:14 PM

catch player leaving level
 
is there some type of if command or work around to catch if a player is going into a link, or leaving a lv? Need the opposite of onPlayerEnters basically.

Mark Sir Link 08-09-2010 06:21 PM

onPlayerLeaves(), serverside only

sssssssssss 08-09-2010 06:23 PM

Not seein what I'm doin wrong, but player.chat ="fadeout" and echo will not happen


PHP Code:

function onCreated() {
  
this.levelfade "armageddon-spar-main";
}
function 
onPlayerLeaves() {
  if (
player.level.starts(this.levelfade)) {
    
triggerClient("gui"name"leftScreen");
    echo(
"fade out");
  }
}
//#CLIENTSIDE
function onCreated() {
  
this.levelfade "armageddon-spar-main";
}
function 
onActionClientSide() {
  if (
params[0] == "leftScreen") {
    
player.chat "fade out";
  }
}
function 
onPlayerEnters() {
  if (
player.level.starts(this.levelfade)) {
    
player.chat "fade in";
  }



xXziroXx 08-09-2010 07:24 PM

player is not an accessible object in that function.

PHP Code:

function onPlayerLeaves(temp.pl)
  echo(
temp.pl.account SPC "just left level" SPC this.level.name "!"); 


sssssssssss 08-09-2010 07:40 PM

ah, duh! xD thanks.

xXziroXx 08-09-2010 07:43 PM

Quote:

Originally Posted by sssssssssss (Post 1592422)
ah, duh! xD thanks.

Actually, I'm wrong. The function isn't called for wNPCs, and from the looks of things, that's what you're trying to use.

Switch 08-09-2010 07:46 PM

From what I heard from Axel, onPlayerLeaves gets called after the player actually left. You'd need to make custom level links to do the fade effect.

WhiteDragon 08-09-2010 08:10 PM

Wouldn't it be nice if we could do something like

PHP Code:

player.onLevelSwitch = function (e) {
  
e.stop();
  
  
blackness.tween('opacity'0.201);

  
schedule(0.2, function () {
    
player.level e.link.newLevel;
    
player.e.link.newX;
    
player.e.link.newY;
    
blackness.tween('opacity'0.210);
  });
}; 

Yes, that was a weird mesh of JavaScript and GS2.

Liberated 08-09-2010 08:18 PM

Tig should know right? He made a similar system for GK didn't he?

cbk1994 08-09-2010 08:21 PM

Kingdoms has custom level links, e.g. levels won't fade out when using actual level links on Kingdoms.

Tigairius 08-09-2010 09:21 PM

Quote:

Originally Posted by Liberated (Post 1592431)
Tig should know right? He made a similar system for GK didn't he?

Quote:

Originally Posted by cbk1994 (Post 1592434)
Kingdoms has custom level links, e.g. levels won't fade out when using actual level links on Kingdoms.

Yep, I actually refuse to use default linking in any of my projects because I find that it's insecure, glitchy, and difficult to manage.

I always use custom linking joined to a class. That way if I want to edit the linking process later, I can do so. Also, it prevents several glitches.

An example of a custom link on one of my most recent projects:
PHP Code:

function onCreated() {
  
this.setShape(16432);
  
this.warplevel "newlevel.nw";
  
this.warpcoordinates = {3020};
  
this.dir 2;
}
join("warpfield"); 

When the player touches the warp field facing this.dir's direction, it schedules an event to warp the player in 0.125 seconds and sends a trigger to a clientside weapon that triggers a fading of the screen for 0.1 seconds. Then, also in the clientside weapon, onPlayerEnters() un-fades the screen.

sssssssssss 08-10-2010 05:58 AM

So if I use that function, I should script it all in a dbnpc or something?

Also, is there any threads on custom level links, didn't see them, although I'm tired and could have skipped right though it I suppose. Wouldnt know where to start to make custom level links, but would like to! :)


All times are GMT +2. The time now is 08:01 AM.

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