possible "Get Calling Function Name/ idx"? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: possible "Get Calling Function Name/ idx"? (
/showthread.php?tid=353862)
possible "Get Calling Function Name/ idx"? -
Jonny5 - 24.06.2012
is it possible to get the name/idx of the function
that calls into another function?
example
pawn Код:
forward func1();
public func1()
{
otherFunc();
}
forward func2();
public func2()
{
otherFunc();
}
otherFunc()
{
//some code to get func1's or func2's name or idx
printf("Called from function Name %s",funcName);
}
im sure it wont look like that but that was my poor excuse for the example.
I also assume these will have to be public functions.
even if i can get the funcidx like this then i could use a list of function names to check against.
Re: possible "Get Calling Function Name/ idx"? -
Makaveli93 - 24.06.2012
Maybe something like this:
pawn Код:
forward func1();
public func1()
{
otherFunc(1);
}
forward func2();
public func2()
{
otherFunc(2);
}
otherFunc(functionID)
{
//some code to get func1's or func2's name or idx
if(functionID == 1) print("Called from function Name func1");
if(functionID == 2) print("Called from function Name func2");
}
I don't think it's possible any other way.
Re: possible "Get Calling Function Name/ idx"? -
Jonny5 - 24.06.2012
yeah not really what i was looking for.
im digging in the pawn ref and implementer's guide to see what i find.
Re: possible "Get Calling Function Name/ idx"? -
Jonny5 - 24.06.2012
first off thanks for the response.
The reason behind this is a logging system,
My goal
WAS to add the calling functions name within the log.
I wanted the log function to be generic for use across the mode but I do think
it will end up to complex and i could just pass the func name to the log manually when its called.
So instead of being lazy....
I have already began to rethink this hole process.
~j5