Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Problem with obj.index() (https://forums.graalonline.com/forums/showthread.php?t=66268)

xXziroXx 05-27-2006 04:33 PM

Problem with obj.index()
 
Can anyone tell me why the index gets returned as -1 all the time?


List of my warp rings:

PHP Code:

Warp Rings/Bearnt Warp Ring
Warp Rings
/Clatton Warp
Warp Rings
/Cloud City
Warp Rings
/Ethereal Lobby
Warp Rings
/Europa Warp
Warp Rings
/Events Island
Warp Rings
/Everton Warp Ring
Warp Rings
/Freenand Warp
Warp Rings
/Kendee Warp
Warp Rings
/MainTown
Warp Rings
/Pennix Warp Ring
Warp Rings
/Phantasma Warp
Warp Rings
/Spenn Warp
Warp Rings
/test
Warp Rings
/Touran Warp
Warp Rings
/Triton Warp
Warp Rings
/Warper3 


The script.

NPC Code:

this.warpingrings = {
"Warp Rings/Bearnt Warp Ring",
"Warp Rings/Clatton Warp",
"Warp Rings/Cloud City",
"Warp Rings/Ethereal Lobby",
"Warp Rings/Europa Warp",
"Warp Rings/Events Island",
"Warp Rings/Everton Warp Ring",
"Warp Rings/Freenand Warp",
"Warp Rings/Kendee Warp",
"Warp Rings/MainTown",
"Warp Rings/MoInt Warp",
"Warp Rings/Pennix Warp Ring",
"Warp Rings/Phantasma Warp",
"Warp Rings/Spenn Warp",
"Warp Rings/test",
"Warp Rings/Touran Warp",
"Warp Rings/Triton Warp",
"Warp Rings/Warper3",
};

for (i = 0; i < this.warpingrings.size(); i ++) {
echo( "[" @ this.warpingrings[i] @ "] [" @ player.weapons.index(this.warpingrings[i]) @ "]");
}





RC.

PHP Code:

[Warp Rings/Bearnt Warp Ring] [-1]
[
Warp Rings/Clatton Warp] [-1]
[
Warp Rings/Cloud City] [-1]
[
Warp Rings/Ethereal Lobby] [-1]
[
Warp Rings/Europa Warp] [-1]
[
Warp Rings/Events Island] [-1]
[
Warp Rings/Everton Warp Ring] [-1]
[
Warp Rings/Freenand Warp] [-1]
[
Warp Rings/Kendee Warp] [-1]
[
Warp Rings/MainTown] [-1]
[
Warp Rings/MoInt Warp] [-1]
[
Warp Rings/Pennix Warp Ring] [-1]
[
Warp Rings/Phantasma Warp] [-1]
[
Warp Rings/Spenn Warp] [-1]
[
Warp Rings/test] [-1]
[
Warp Rings/Touran Warp] [-1]
[
Warp Rings/Triton Warp] [-1]
[
Warp Rings/Warper3] [-1



ADD: Any why doesnt if (hasweapon(weaponname)) work anymore?

Skyld 05-27-2006 05:20 PM

player.weapons is a list of objects I think, not names.

xXziroXx 05-27-2006 07:10 PM

Wrong. I tried echo ( player.weapons); and it displayed all my Weapons + some global Weapons.


And I also tried something like this.var = player.weapons; and to use index on that, didnt work either.

Snakeandy7 05-27-2006 07:13 PM

findweapon("name") == value [1/NULL]

Very weird... I've just tried this too, same error. Although it works on other things... [not players.weapons]

Admins 05-27-2006 07:52 PM

player.weapons is an array. When you output an array then it's outputing its content as string, most objects print their name when you just print the object. I can check this though, to make sure its working correctly.

The function hasweapon(oldstring) is still working, in new scripting it would be findweapon(string)!=NULL. findweapon(string) is searching for a weapon with the specified name in the players inventory. There is also findweaponnpc(string) for finding any existing weapon, although you can also just access the weapons by name, you need to use the correct case though.

xXziroXx 05-28-2006 12:29 AM

Is

NPC Code:
echo( this.warpingrings[i] @ ": " @ findweapon(this.warpingrings[i]));



supposed to show i.e.

PHP Code:

Warp Rings/Clatton WarpWarp Rings/Clatton Warp 

?


Shouldnt it show this instead:

PHP Code:

Warp Rings/Clatton Warp1/null 



All times are GMT +2. The time now is 10:34 PM.

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