Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   the NPC's name (https://forums.graalonline.com/forums/showthread.php?t=84376)

Tyhm 02-24-2009 05:44 PM

the NPC's name
 
The wiki has failed me again.

with(findnpc("turret"))

that's great, but how do I get the NPC's name? I mean, how do I know which NPC to find? Does it even work with putnpc2sies?

Here's the problem:
I've made a script that, clientside, comes up with a list of targets, then sends these targets to the serverside. The serverside checks the list of targets to make sure the player isn't being cheeky, then applies damage. Currently I've got the clientside triggering with a list of npc.id s, and the server's catching it no problem, but I can't seem to go from a list of npc.ids to a list of actual NPCs, short of running a very large findareanpcs and comparing their IDs...I'd much rather either send a list of npc.names (or whatever the mysterious property is, the wiki's no help) or look them up by id directly. temp.npc=npc.id(param1)? =findnpcbyid(param1)?

Crow 02-24-2009 06:27 PM

The only NPCs having names you can assign yourself are the database NPCs. The others either have no name, or they have a generated name (putnpc2()). Either way, you can't change the name yourself. Though, putnpc2() returns the name of the newly created NPC when it is called. Maybe you will find this useful.

cbk1994 02-24-2009 10:38 PM

Try using npc.name instead of the ID, then using findNPC(name) on serverside.

Quote:

Originally Posted by Crow (Post 1469082)
Though, putnpc2() returns the name of the newly created NPC when it is called. Maybe you will find this useful.

No, putnpc2() returns the actual NPC object, hence why you can do this:

PHP Code:

temp.npc putnpc2(3232"");
npc.var = "foo";
npc.join("meow"); 


Tyhm 02-25-2009 02:58 AM

npc.name doesn't return the #n of the NPC?

cbk1994 02-25-2009 03:53 AM

Quote:

Originally Posted by Tyhm (Post 1469214)
npc.name doesn't return the #n of the NPC?

#n is nick. That's npc.nick. npc.name is the actual name given to the NPC (something like localnpc_level.nw_30_30_1).

Tyhm 02-25-2009 05:31 AM

Sweet! Now if I can just get that to work...right now
PHP Code:

echo("Name="@npc.name); 

returns
PHP Code:

Name

. It returns a value for npc.id (usually in the 300s), but no name. -_-
In fact,
PHP Code:

        echo("Name="@npc.name@" ID="@npc.id); 

returns
PHP Code:

NameID=300 


Tyhm 02-25-2009 05:51 AM

So there IS such a command as findNPCByKD? You"wouldn't know by reading the wiki...OH, THERE IT IS. "findnpcby" brings nothing, "findnpc" has 0 hits, but "findnpcbyid" has a hit. SO YOU JUST HAVE TO SEARCH FOR THE EXMCT TERM. YOU JUST HAVE TO KNOW`EXACTLY WHAT YOU'RE LOO[ING FOR BEFORE YOU LOOK2FOR!IT.

Right now K got it passing ID from client to server (it stays the same), and the server does a gigantic findareanpcs, checks which one{ match IDs, and kills 'em.

However - findnpcbyid is apparently clientside only. -_-

salesman 02-25-2009 06:22 AM

Yea, I'm having the same problem right now actually...

It'd be nice if that worked serverside :(

Crow 02-25-2009 05:32 PM

Quote:

Originally Posted by cbk1994 (Post 1469131)
No, putnpc2() returns the actual NPC object, hence why you can do this:

PHP Code:

temp.npc putnpc2(3232"");
npc.var = "foo";
npc.join("meow"); 


Ah, well, I always get confused about this, since Graal handles it in a very weird way..


All times are GMT +2. The time now is 04:19 AM.

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