ReDefining native functions
#1

This seems to compile fine (haven't yet had time to test), but was wondering if this is valid to do. Basically, instead of making a whole new function, I thought, why not just redefine the current one so it is still compatible with my script. I've seen it done with callbacks, but have yet to see it done with native functions.

pawn Код:
#define IsPlayerAdmin Stock_IsPlayerAdmin
#define My_IsPlayerAdmin IsPlayerAdmin
stock My_IsPlayerAdmin(playerid) return (PlayerInfo[playerid][pAdmin] > 0 || CallLocalFunction("Stock_IsPlayerAdmin", "i", playerid));
forward Stock_IsPlayerAdmin(playerid);
This way it checks if they are an admin according to the script, or if they are logged into RCON.
Reply
#2

Quote:
Originally Posted by Calix
This seems to compile fine (haven't yet had time to test), but was wondering if this is valid to do. Basically, instead of making a whole new function, I thought, why not just redefine the current one so it is still compatible with my script. I've seen it done with callbacks, but have yet to see it done with native functions.

pawn Код:
#define IsPlayerAdmin Stock_IsPlayerAdmin
#define My_IsPlayerAdmin IsPlayerAdmin
stock My_IsPlayerAdmin(playerid) return (PlayerInfo[playerid][pAdmin] > 0 || CallLocalFunction("Stock_IsPlayerAdmin", "i", playerid));
forward Stock_IsPlayerAdmin(playerid);
This way it checks if they are an admin according to the script, or if they are logged into RCON.
You don't forward stocks and next time try it before posting, really a waste of thread space.
Reply
#3

Sorry. This is the scripting discussion forum, I figured it would be ok to ask a simple question. Though I'm unsure what you mean by wasting thread space, I'm sure the forum can handle a few extra topics. Thank you for responding though I guess...I've removed the forward and it still compiles fine, so I guess I'll wait till I get home so I can actually test it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)