![]() |
Introducing Callstack Access
Introduction
This is possibly my most wanted feature in GScript for some time: callstack access. Callstack access allows you to see which objects and functions are calling other objects or functions. This means you can add better script security by, say, checking which NPCs are trying to call your bank functions, for example. It also can be used for script debugging. Does it work on all servers yet? Probably not. Try it, and if it doesn't work, you can request your NPC-Server to be updated with it. :) How callstack access works First, let's examine how to get the contents of the callstack. The getCallStack() function returns an array of links. The array that getCallStack() returns is a chronological list of the function call chain. The important thing to recognise about these links is that they are not direct links to the calling function or NPC themselves, but instead they are an object linking to the temp. scope of the calling functions. Yes, this means that you can access temp. variables of functions earlier in the call chain. (See section below) There is also a sub-object named "scriptcallobject", which is a link to the object that is calling the function. Finally, there is another variable called "name" which returns the name of the calling function. Code Example Now, just to make the example a bit more straight-forward, we'll demonstrate this with just two NPCs; TestNPC, and TestNPC2. Here is the code in TestNPC: PHP Code:
And then TestNPC2: PHP Code:
Quote:
Quote:
Accessing temp variables Instead of using scriptcallobject, you can access temp names directly, i.e.: PHP Code:
Quote:
|
A wicked way to secure scripts from pesky staff ^^. Although I wanted protected variables, this will definitely help ^^ <3 for Stefan!
Bank DBNPC PHP Code:
PHP Code:
PHP Code:
|
Oh, totally cool dude. I think there've been a few people awaiting the ability to view the callstack and script accordingly to improve script efficiencies. Though, I'm still with Twinny on protected/password protected variables, etc. this is an excellent addition!
|
I like this :) Great news. I'll start implementing into my MUDlib right away.
|
Nice :)
|
uhm, may i request that triggers are traced too? :p
|
Here are two functions, one to get the object that calls the function that calls it, and one to get the calling function in the same way.
PHP Code:
|
Quote:
|
well i just want to make sure that e.g. a onActionServerSide can only be called from the same weapon xD
|
Very nice feature.
|
Very nice, I love it.
Now I just want to be able to use it on Maloria :) |
I missed this completely, very nice function! :D
|
Quote:
|
Quote:
|
Couldn't have provided that first class bump without Dusty. :cool:
|
| All times are GMT +2. The time now is 10:16 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.