SA-MP Forums Archive
Redefining functions - 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: Redefining functions (/showthread.php?tid=280855)



Redefining functions - gamer931215 - 03.09.2011

Hey, im wondering... is it possible to redefine functions ?
Something like this:

pawn Код:
#include <a_samp>

//Renaming Ban to _INCLUDE_ban
#define _INCLUDE_ban Ban
//redefining Ban to another function
#define Ban(%0) CallLocalFunction("OnPlayerGetBanned","i",%0);_INCLUDE_ban(%0)

public OnPlayerConnect(playerid)
{
    Ban(playerid); //testing
    return 1;
}

forward OnPlayerGetBanned(playerid);
public OnPlayerGetBanned(playerid)
{
    return 1;
}
Only this seems to freeze the pawn compiler since it is doing a infinite loop (_INCLUDE_ban probably calls the function Ban again instead of the real one making it calling himself infinite times...)


Re: Redefining functions - Stylock - 03.09.2011

It's possible to hook functions. Take a look at this post.


Re: Redefining functions - gamer931215 - 03.09.2011

Quote:
Originally Posted by YJIET
Посмотреть сообщение
It's possible to hook functions. Take a look at this post.
Hmm never knew that trick was also possible with functions... thanks!