Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   another array question (https://forums.graalonline.com/forums/showthread.php?t=31311)

darkriders_p2p 06-10-2002 10:32 AM

another array question
 
k, I made my hat NPC, no one helped me :(
But I have it so when you pick up the NPC it sets an array.It uses client.hats for the variable.
question:
why is it when I make a variable like client.hats[0]=1; it only stays true for that level, and goes false for any other level?

darkriders_p2p 06-10-2002 09:30 PM

bump
I need help someone :(
plz

Projectshifter 06-10-2002 09:34 PM

LOL. I h8 arrays. Otherwise I would help. Arrays are one of the few things I'd prefer not to script unless I have to, they annoy me. Maybe soon I'll take the time to understand them more fully. Beg the great Kai and he may help, he he.
---Shifter

darkriders_p2p 06-10-2002 10:26 PM

Quote:

Originally posted by Projectshifter
LOL. I h8 arrays. Otherwise I would help. Arrays are one of the few things I'd prefer not to script unless I have to, they annoy me. Maybe soon I'll take the time to understand them more fully. Beg the great Kai and he may help, he he.
---Shifter

:O
I beg apon the almighty Kai, I need your supirior(sp?) knowledge about scripting arrays :megaeek:

GrowlZ1010 06-10-2002 11:20 PM

If you're using VARIABLES, as opposed to strings, and it's offline, then you won't have much luck. Unless a NPC weapon sets a this. var, variables are attatched to the level, not the player. Anyway, I seem to recall Kaimetsu saying there is no such thing as a client. variable; it will work, but it's no different to calling a variable anything else. Diagram is below.

http://members.aol.com/irnet22350/diagram.png

Note: to save hats, it's probably better to use strings. Variables have a nasty habit of clearing whenever you reconnect, or at least they do in my experience.

Projectshifter 06-11-2002 01:11 AM

Ah, the almighty Growlz has come to aid you, heh. GrowlZ and I worked back on Sans, he's smart, maybe rivaling Kai? He he.
---Shifter

GrowlZ1010 06-11-2002 01:59 AM

Quote:

Originally posted by Projectshifter
Ah, the almighty Growlz has come to aid you, heh. GrowlZ and I worked back on Sans, he's smart, maybe rivaling Kai? He he.
---Shifter

Rivaling Kaimetsu? Two words: "I" and "wish". But thank you for that, Shifter. I like to think my work is occasionally appreciated.

darkriders_p2p 06-11-2002 02:08 AM

Quote:

Originally posted by GrowlZ1010
If you're using VARIABLES, as opposed to strings, and it's offline, then you won't have much luck. Unless a NPC weapon sets a this. var, variables are attatched to the level, not the player. Anyway, I seem to recall Kaimetsu saying there is no such thing as a client. variable; it will work, but it's no different to calling a variable anything else. Diagram is below.

http://members.aol.com/irnet22350/diagram.png

Note: to save hats, it's probably better to use strings. Variables have a nasty habit of clearing whenever you reconnect, or at least they do in my experience.

ok I get that, so is there a thing like stringarrays?

GrowlZ1010 06-11-2002 02:18 AM

Quote:

Originally posted by darkriders_p2p

ok I get that, so is there a thing like stringarrays?

String arrays. Murky waters. *shudder*

Umm.. I don't know of any such thing as string arrays. Maybe they exist, but I've never come across one. You can probably simulate something like 'em, but if you're using strings now, why don't you just have a piece of code that, when the player picks up a hat, checks whether or not the player already has that hat (doing strcontains on a string), and adds it to their list? If, as I presumed, you're using the array to track what hats the player has, rather than the mode of the weapon, configuration, etc., this would probably work better. It'd be my choice, anyway. (Unless, of course, you want the player to be able to carry more than one of a hat. Then we could potentially get into the confusing world of string indexes which I don't exactly want to go over unless I really, really, really have to.)

darkriders_p2p 06-11-2002 02:22 AM

Quote:

Originally posted by GrowlZ1010


String arrays. Murky waters. *shudder*

Umm.. I don't know of any such thing as string arrays. Maybe they exist, but I've never come across one. You can probably simulate something like 'em, but if you're using strings now, why don't you just have a piece of code that, when the player picks up a hat, checks whether or not the player already has that hat (doing strcontains on a string), and adds it to their list? If, as I presumed, you're using the array to track what hats the player has, rather than the mode of the weapon, configuration, etc., this would probably work better. It'd be my choice, anyway. (Unless, of course, you want the player to be able to carry more than one of a hat. Then we get into the confusing world of string indexes which I don't exactly want to go over unless I really, really, really have to.)

I don't want to get complicated.
NPC Code:
if (strequals(#v(this.hats[i]),1)) {


I use that to check if the player has the the hat, so how could I replace this to check for a string.
If you would like to see the script, my MSN email is [email protected]

GrowlZ1010 06-11-2002 02:28 AM

Quote:

Originally posted by darkriders_p2p

I don't want to get complicated.
NPC Code:
if (strequals(#v(this.hats[i]),1)) {


I use that to check if the player has the the hat, so how could I replace this to check for a string.
If you would like to see the script, my MSN email is [email protected]

Presuming the number of the hat is 1:

NPC Code:
if (strcontains(#s(client.hats),1)) {



... will check if the number 1 (the hat's number) is in the client.hats string, so basically, will have the effect of checking if the player has a certain hat (in this case, hat 1).

darkriders_p2p 06-11-2002 02:45 AM

Quote:

Originally posted by GrowlZ1010


Presuming the number of the hat is 1:

NPC Code:
if (strcontains(#s(client.hats),1)) {



... will check if the number 1 (the hat's number) is in the client.hats string, so basically, will have the effect of checking if the player has a certain hat (in this case, hat 1).

ya I fixed it, It was pretty easy :P
NPC Code:
if (strequals(#s(hats[#v(i)]),1)) {


GrowlZ1010 06-11-2002 02:51 AM

Quote:

Originally posted by darkriders_p2p

ya I fixed it, It was pretty easy :P
NPC Code:
if (strequals(#s(hats[#v(i)]),1)) {


Well, you're simulating an array well enough. :P But why one string for every hat? Are you measuring the number of hats in those, or whether or not the player has the hat? If it's the latter, use one string. More efficient, less space, same effect!

darkriders_p2p 06-11-2002 07:04 AM

Quote:

Originally posted by GrowlZ1010


Well, you're simulating an array well enough. :P But why one string for every hat? Are you measuring the number of hats in those, or whether or not the player has the hat? If it's the latter, use one string. More efficient, less space, same effect!

because I have no clue what ur talking about :(

Saga2001 06-11-2002 09:53 PM

-FooL-

Quote:

Umm.. I don't know of any such thing as string arrays. Maybe they exist, but I've never come across one.
addstring
insertstring
removestring
replacestring
deletestring
#I()
For()
[edit] sarraylen() [/edit]

Need I say more?


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

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