Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Setting variables when a player enters a level (https://forums.graalonline.com/forums/showthread.php?t=65439)

Yen 04-16-2006 10:14 PM

Setting variables when a player enters a level
 
Alright.. I have a ladder NPC.
When the player enters the level, I want each ladder to tell the player where it is. A system handles climbing, based on this information.

When the player enters the level, it adds the ladder's ID to one array (ladders) and it adds the ladder's area to another array (ladder#).

When the player enters, the system clears the ladders, so old ladder placements aren't carried into the level.


However, the ladder ID array is randomly being erased. I'm guessing it's by the clearing of ladders when the player enters.
I tried making it set the ladder ID array after .5 seconds, but it still doesn't work.
The ladders array just randomly clears itself; if I update the level or relog, it works. However, like I said, after a while it clears itself for no reason.

Any ideas?

Riot 04-16-2006 11:44 PM

Try using a level. variable so you don't have to clear it when they enter a new level?

Yen 04-17-2006 12:05 AM

Quote:

Originally Posted by Riot
Try using a level. variable so you don't have to clear it when they enter a new level?

I think I tried that, but I'll try again.

Yen 04-17-2006 12:09 AM

Yeah, it doesn't work at all as level.

jake13jake 04-19-2006 02:50 AM

Try making the ladders NPCs, and then having the system detect the NPCs.

ex.
ladder
PHP Code:

function onCreated() {
  
setshape(1,16*width,16*height);
  
this.isLadder true;
}

-----
system NPC function for testing ladders
function testLadder() {
  
temp.tnpcs findareanpcs(x,y,w,h);
  for (
i=0i<temp.tnpcs.size(); i++)
    if (
temp.tnpcs[i].isladder)
      return 
true;
  return 
false;



ApothiX 04-19-2006 02:27 PM

To access level. variables clientside, you have to set them clientside.
This would probably be your best method of doing this, something like:

PHP Code:

//#CLIENTSIDE
if(created) {
  
level.ladders.add({ this.xthis.ywhateverelse });



Yen 04-19-2006 05:12 PM

Quote:

Originally Posted by ApothiX
To access level. variables clientside, you have to set them clientside.
This would probably be your best method of doing this, something like:

PHP Code:

//#CLIENTSIDE
if(created) {
  
level.ladders.add({ this.xthis.ywhateverelse });



It treats them the same as un-prefix'd variables. :(

I can't really make the system detect them, because the player could be on a gmap with 1000s of NPCs.
You know how laggy that is. :P

jake13jake 04-19-2006 06:59 PM

Quote:

Originally Posted by Yen
It treats them the same as un-prefix'd variables. :(

I can't really make the system detect them, because the player could be on a gmap with 1000s of NPCs.
You know how laggy that is. :P

Well, that's what was a problem with my movement system, and then stefan made findareanpcs(x,y,w,h) work for weapons so that I could detect NPCs. It's probably one of the most useful functions that stefan has made.
findareanpcs(x,y,w,h) returns an array of npc objects on x,y,w,h. Therefore you don't have to cycle through thousands of NPCs. He's been talking about doing a findareaplayers function, that will also be quite helpful.

Yen 04-19-2006 11:45 PM

Do you know if PlayerEnters is called when the player enters a new section of the gmap?

jake13jake 04-20-2006 05:30 AM

I generally treat the gmap as if it were one level, though I'm sure it does in some senses, just not trustworthy senses.

ApothiX 04-20-2006 02:14 PM

Quote:

Originally Posted by Yen
Do you know if PlayerEnters is called when the player enters a new section of the gmap?

It is. Clientside it doesn't show the level being the gmap, it shows the individual sections.

jake13jake 04-20-2006 07:44 PM

Quote:

Originally Posted by ApothiX
It is. Clientside it doesn't show the level being the gmap, it shows the individual sections.

yes, but I believe it may call the playerenters event on multiple levels.

Skyld 04-20-2006 07:50 PM

Quote:

Originally Posted by jake13jake
yes, but I believe it may call the playerenters event on multiple levels.

I will reiterate what Okiesmokie said.

The clientside does not see the GMAP as one giant level, like the serverside does. Therefore, function onPlayerEnters() will be called clientside as you enter each level in the GMAP, not on every level as you enter the GMAP.

jake13jake 04-20-2006 07:53 PM

Quote:

Originally Posted by Skyld
I will reiterate what Okiesmokie said.

The clientside does not see the GMAP as one giant level, like the serverside does. Therefore, function onPlayerEnters() will be called clientside as you enter each level in the GMAP, not on every level as you enter the GMAP.

No, I mean for every level that is visible, but I haven't tested it in a long time.

Yen 04-20-2006 08:24 PM

Quote:

Originally Posted by Skyld
I will reiterate what Okiesmokie said.

The clientside does not see the GMAP as one giant level, like the serverside does. Therefore, function onPlayerEnters() will be called clientside as you enter each level in the GMAP, not on every level as you enter the GMAP.

This creates a problem. :(

Ganis will fix it, though! YAY GANI!

ApothiX 04-24-2006 02:30 PM

Quote:

Originally Posted by jake13jake
No, I mean for every level that is visible, but I haven't tested it in a long time.

.. read what both me and Skyld said, and then reply <_<


All times are GMT +2. The time now is 12:31 PM.

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