SA-MP Forums Archive
Hooking (ALS) - 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: Hooking (ALS) (/showthread.php?tid=440636)



Hooking (ALS) - CreativityLacker - 30.05.2013

Well, I'm trying to hook up 2 callbacks for an include I'm writing, and it'd be really nice if someone can hook these 2 callbacks

http://pastebin.com/FFCjPdGb

and tell me how exactly do I do, because I've been trying to read tutorials, but it's just that I don't seem to understand any

And I'm not using Y_hooks as I don't want the scripter to be forced to use the YSI library.


Re: Hooking (ALS) - CreativityLacker - 31.05.2013

bumpy


Re: Hooking (ALS) - DobbysGamertag - 31.05.2013

Whats the issue with YSI?


Re: Hooking (ALS) - CreativityLacker - 31.05.2013

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
Whats the issue with YSI?
I'm writing an include, and I don't want the scripter to be forced to have the YSI library, I want to give him the freedom of choice, I'll also include a YSI version but I want the user to have an ALS version too.


Re: Hooking (ALS) - CreativityLacker - 02.06.2013

/bump


Re: Hooking (ALS) - OrMisicL - 02.06.2013

I think the easiest way for you is to use the y_hooks include, otherwise u'll need to write your own hooking system, or you could use old school techniques by calling an include function from a callback, something like

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
        Include_OnTakeDamage(playerid, issuerid, ammount, weaponid);
        return 1;
}
which i assume u dont want to use,
take a look at this thread ( https://sampforum.blast.hk/showthread.php?tid=85907 ), it may help you


Re: Hooking (ALS) - MP2 - 02.06.2013

If you use y_hooks, you simply change 'public' to 'hook' - it's that easy. If people don't want to spend 5 seconds downloading YSI that's their problem. You could even include it with your package.


Re: Hooking (ALS) - MP2 - 02.06.2013

What exactly do you mean by 'fragments the downloads'? As in they'll be out of date? Then he can update them. Not sure you mean that though. Clarify please.


Re: Hooking (ALS) - Lordzy - 02.06.2013

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
        if(IsWeaponGun(weaponid) && issuerid != INVALID_PLAYER_ID) eB[issuerid][BulletsHit]++;
        CallLocalFunction("Hooked_OPTD", "iifi", playerid, issuerid, amount, weaponid);
        return 1;
}

public OnPlayerConnect(playerid)
{
        eB[playerid][BulletsHit] = 0;
        eB[playerid][BulletsShot] = 0;
        CallLocalFunction("Hooked_OPC", "i", playerid);
        return 1;
}

#if defined _ALS_OnPlayerTakeDamage
 #undef OnPlayerTakeDamage
#else
 #define _ALS_OnPlayerTakeDamage
#endif

#if defined _ALS_OnPlayerConnect
 #undef OnPlayerConnect
#else
 #define _ALS_OnPlayerConnect
#endif

#define OnPlayerTakeDamage Hooked_OPTD
#define OnPlayerConnect Hooked_OPC

forward Hooked_OPTD(playerid, issuerid, Float:amount, weaponid);
forward Hooked_OPC(playerid);
Hooked using the _ALS_ method which is was the commonly used hooking methods. I generally use the _ALS_ method of hooking.

http://forum.sa-mp.com/search.php?searchid=6384931
Some of the hook tutorials.


Re: Hooking (ALS) - MP2 - 02.06.2013

Quote:
Originally Posted by ******
Посмотреть сообщение
As in there will be multiple download locations each with different versions - I'd rather keep everything to a single central download so I can update it as required.
Well he could update it in his package.