SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 29/12/2017, 04:00 PM   #21
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,677
Reputation: 3062
Default Re: #emit Discussion

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 Code:
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 Code:
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.
Y_Less is offline   Reply With Quote
Old 29/12/2017, 07:56 PM   #22
Dutheil
Godfather
 
Dutheil's Avatar
 
Join Date: Jul 2014
Location: France
Posts: 5,135
Reputation: 220
Default Re: #emit Discussion

@Y_Less: Yes it's good, I'm going to look the codes to understand the logic.
PHP Code:
#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

__________________
#PrayForFrenchForum
GitHub

Code:
print({1466458484, 543452960, 2037347616, 1952999790, 1797286260, 544694643, 543649646, 1851859053, 1634428192, 1056964608});
Dutheil is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
when should #emit be used sammp Scripting Help 3 15/11/2014 09:49 AM
@emit Slice Discussion 7 16/04/2013 06:30 PM
Emit Help Snir_sofer Scripting Help 2 25/09/2012 05:54 PM
#emit rVar Scripting Help 3 08/09/2012 06:26 PM
Help with #emit _Petrol_ Scripting Help 0 23/08/2012 03:54 PM


All times are GMT. The time now is 09:37 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.