Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Array problem... (https://forums.graalonline.com/forums/showthread.php?t=80188)

wild8900 06-22-2008 02:53 AM

Array problem...
 
Im trying to make a script that records if youve been in a room or not and only records the room when you open a chest with a key in it. Im detecting this using a client.visitedroom (It wont always be client. just for testing) array but I cant change it from the script. I tried using client.visitedkeys[2]=#L; but that wouldnt work.

xXziroXx 06-22-2008 02:58 AM

DO NOT MIX GS1 WITH GS2, please!


Does client.visitedkeys exist? client.visitedkeys[2] should be client.visitedkeys[2] = player.level.name; though.

wild8900 06-22-2008 03:03 AM

yes it exists o_o

xXziroXx 06-22-2008 03:24 AM

Can you show us the script please?

cbk1994 06-22-2008 03:24 AM

PHP Code:

function onPlayerTouchsMe()
{
  if ( 
clientr.chestsOpened.index( @ this.level.name ) == -)
  {
    
clientr.chestsOpened.addthis.level.name );
    
// Stuff to do e.g. add a weapon
  
}


There's your chest script. Just need to use "clientr.chestsOpened.index( @ level ) == -1" to make sure they haven't been in it.

DustyPorViva 06-22-2008 03:37 AM

That script would only work if there was a one chest limit per level. It needs to have coordinates as well.

cbk1994 06-22-2008 05:43 AM

Quote:

Originally Posted by DustyPorViva (Post 1398590)
That script would only work if there was a one chest limit per level. It needs to have coordinates as well.

!pissed!!pissed!!pissed!

PHP Code:

function onPlayerTouchsMe()
{
  if ( 
clientr.chestsOpened.index( @ this.level.name "_" this."_" this.) == -)
  {
    
clientr.chestsOpened.addthis.level.name "_" this."_" this.);
    
// Stuff to do e.g. add a weapon
  
}



Admins 06-22-2008 01:17 PM

Stuff like

PHP Code:

clientr.("chestopened_" level.name) = true

would be best, because such arrays can become quite huge and each modification of a client/clientr variable needs to be sent to the client.

Crow 06-22-2008 02:28 PM

Quote:

Originally Posted by Stefan (Post 1398626)
Stuff like

PHP Code:

clientr.("chestopened_" level.name) = true

would be best, because such arrays can become quite huge and each modification of a client/clientr variable needs to be sent to the client.

Textfiles for the win.

xXziroXx 06-22-2008 05:15 PM

Quote:

Originally Posted by Crow (Post 1398628)
Textfiles for the win.

Loading data once per session/update ftw. :cool:

cbk1994 06-22-2008 08:02 PM

Quote:

Originally Posted by Stefan (Post 1398626)
Stuff like

PHP Code:

clientr.("chestopened_" level.name) = true

would be best, because such arrays can become quite huge and each modification of a client/clientr variable needs to be sent to the client.

!pissed!!pissed!!pissed!!pissed!!pissed!

PHP Code:

function onPlayerTouchsMe()
{
  if ( ! 
clientr.( @ "chestsOpened_" this.level.name "_" this."_" this.) )
  {
    
clientr.( @ "chestsOpened_" this.level.name "_" this."_" this.) = true;
    
// Stuff to do e.g. add a weapon
  
}




All times are GMT +2. The time now is 11:50 AM.

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