Graal Forums

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

TSAdmin 02-08-2008 08:04 AM

Callstack Problem
 
I'm trying to restrict functions in a player class using callstack, but when I try to do so, it returns

PHP Code:

temp.stack[0].scriptcallobject.name 

as the player's nick name when echoing, and not the weapon/class/npc it's being used from.

EG:
PHP Code:

<insert players nickuses the addItem function! 

echo's to NC instead of

PHP Code:

<insert name of weapon/class/npcuses the addItem function! 

The only way I can figure out how to avoid this was to move the function outside of the player class, but I really don't want to do that. Is there a way I can avoid this problem?

cbk1994 02-08-2008 03:51 PM

I don't understand (as usual).

Are you trying to find what called addItem? If addItem is in the player class, and you want the players nick, something like ...

PHP Code:

public function addItemitemamm )
{
  echo( 
format"[percent]s ([percent]s) added themselves a weapon"this.nickthis.account ) );


Edit: forgive the [percent] -- cannot post percent symbols

Dan 02-08-2008 05:36 PM

Maybe try findweapon(temp.stack[0].scriptcallobject).name

Inverness 02-08-2008 10:29 PM

PHP Code:

public function getcallingobject() {
  
temp.callstack getcallstack();
  return 
temp.callstack[temp.callstack.size() - 3].scriptcallobject;


That function would return the object that calls the function that is calling getcallingobject().

Admins 02-24-2008 04:33 PM

Not sure where the problem is, when its displaying the players name then its of course the player object which is calling the function. You can e.g. display the scriptcallobject.objecttype() to be sure it's the player, or the name of the function to know which function has called your function.

If it would be a weapon or npc then the name and objecttype() of the scriptcallobject wouldn't match the player.


All times are GMT +2. The time now is 08:06 AM.

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