Hooking (ALS)
#1

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.
Reply
#2

bumpy
Reply
#3

Whats the issue with YSI?
Reply
#4

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.
Reply
#5

/bump
Reply
#6

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
Reply
#7

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.
Reply
#8

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.
Reply
#9

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)