SA-MP Forums Archive
How to hook ? - 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: How to hook ? (/showthread.php?tid=349364)



How to hook ? - Saad_ - 08.06.2012

Hello guys i want to create an include that has OnPlayerConnect and my GM already has it so how do i hook eachother


Re: How to hook ? - MP2 - 08.06.2012

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
What?Every gamemode has OnPlayerConnect,even the filterscripts,what you're trying to do?
..? Read the topic - he wants to HOOK it in an INCLUDE.

You can either use y_hooks (part of YSI) which makes it extremely easy to hook, i.e.
pawn Код:
Hook:blahblahyoucanputwhateveryoulikehere_OnPlayerConnect(playerid)
{
    // Your shit
    return 1;
}
But that will require people to download YSI. If you wanted, you can just use ALS code, like so:

pawn Код:
public blahblah_OnPlayerConnect(playerid)
{
    // Your shit
    return CallLocalFunction("blahblah_OnPlayerConnect", "i", playerid); // Hooking method
}
#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect blahblah_OnPlayerConnect
forward blahblah_OnPlayerConnect(playerid);
A bit more 'complex' as it were, but it will save people have to download YSI.


Re: How to hook ? - Saad_ - 08.06.2012

yes man thx


Re: How to hook ? - MP2 - 08.06.2012

Made an error - re-check my post.


Re: How to hook ? - Saad_ - 08.06.2012

i think i will go with y hooks and save all the hassle anyways thx again