Y_hooks
#1

I wanted to create an anticheat with Y_hooks but it seems you can't hook a function to GivePlayerMoney? Like this
pawn Код:
Hook:Money_GivePlayerMoney(player, money){
    return Money[playerid] = Money[playerid] + money;
}
Код:
NPP_SAVE: C:\Users\Antoine\Desktop\AnteinoServer\gamemodes\AnteinoServer.pwn
CD: C:\Users\Antoine\Desktop\AnteinoServer\gamemodes
Current directory: C:\Users\Antoine\Desktop\AnteinoServer\gamemodes
"C:\Users\Antoine\Desktop\AnteinoServer\pawno\pawncc.exe" "AnteinoServer.pwn" -; -(
Process started >>>
AnteinoServer.pwn(53) : warning 203: symbol is never used: "Money_GivePlayerMoney"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
<<< Process finished.
================ READY ================
Please don't tell me to use a standard antihack system :'D
Reply
#2

Anyone?
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
I would have seen this long ago had it been posted in the y_hooks topic.

Anyway, y_hooks only works on callbacks (and I'm trying to find a way to make it work on timers, but there's a technical issue yet to get past, but that's beside the point). If you want to hook functions you need to use the old ALS method, though it's a little easier for functions:

pawn Код:
stock Money_GivePlayerMoney(player, money)
{
    // This needs to be done or the original won't be called.
    GivePlayerMoney(playerid, money);
    // Do your own code.
    return Money[playerid] = Money[playerid] + money;
}

#if defined _ALS_GivePlayerMoney
    // Another script already hooked this function.
    #undef GivePlayerMoney
#else
    // You are the first library to hook this function - tell other libraries this.
    #define _ALS_GivePlayerMoney
#endif

// Now redefine the function name to call your function instead of the old one.
#define GivePlayerMoney Money_GivePlayerMoney
Yea I allready did that and got it working
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)