#emit Discussion - 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)
+---- Forum: Discussion (
https://sampforum.blast.hk/forumdisplay.php?fid=84)
+---- Thread: #emit Discussion (
/showthread.php?tid=578587)
Re: #emit Discussion -
Y_Less - 29.12.2017
There are some functions in amx_assembly for that. They aren't perfect, since it is not possible to always get a function's name, but if it is a public then there's no problem.
PHP код:
new dest[32];
GetPublicNameFromAddress(GetCurrentFrameFunction(), dest);
You can wrap that in a function, but it gets more complex, because those functions depend on their location in the stack:
PHP код:
GetCurrentFrameFunctionName()
{
new name[32];
GetPublicNameFromAddress(GetFrameFunction(GetCurrentFramePreviousFrame()), name);
return name;
}
However, I'm not 100% sure if that will even work. There are three types of address - relative, absolute, and resolved. Relative addresses are things like "jump 4 bytes forward", absolute addresses are "jump to code at pawn address 128", resolved addresses are "jump to code at real memory address 0x40248238". I don't know which of those "GetPublicNameFromAddress" takes, and which of those "GetFrameFunction" returns - they might not be compatible by default, but there are various conversion functions about.
Re: #emit Discussion -
Dutheil - 29.12.2017
@Y_Less: Yes it's good, I'm going to look the codes to understand the logic.
PHP код:
#include "amx\frame_info"
forward FirstCustomFunction();
forward SecondCustomFunction();
main()
{
FirstCustomFunction();
}
public FirstCustomFunction()
{
SecondCustomFunction();
}
public SecondCustomFunction()
{
new dest[32];
GetPublicNameFromAddress(GetFrameFunction(GetCurrentFramePreviousFrame()), dest);
print(dest); // FirstCustomFunction
GetPublicNameFromAddress(GetCurrentFrameFunction(), dest);
print(dest); // SecondCustomFunction
}