Quote:
Originally Posted by Emmet_
For hooking functions, you can just do:
pawn Код:
#define <native> <hooked function>
In this case:
pawn Код:
#define SetPlayerScore SetPlayerScoreEx
|
Funny, I can't find that to be working, though, I haven't tried it out. The pre-processor also agrees with me on this one. Here is a little test I did:
Original code:
pawn Код:
#include <a_samp>
#define SetPlayerScore SetPlayerScoreEx
new playerScore[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
SetPlayerScore(playerid, 1);
return 1;
}
SetPlayerScoreEx(playerid, value)
{
playerScore[playerid] = value;
SetPlayerScore(playerid, value);
return 1;
}
Pre-processed code:
pawn Код:
#include <a_samp>
#define SetPlayerScore SetPlayerScoreEx
new playerScore[(500)];
public OnPlayerConnect(playerid)
{
SetPlayerScoreEx(playerid, 1);
return 1;
}
SetPlayerScoreEx(playerid, value)
{
playerScore[playerid] = value;
SetPlayerScoreEx(playerid, value);
return 1;
}
I mean SetPlayerScore under the SetPlayerScoreEx function was also defined to SetPlayerScoreEx, won't that create a loop without a loop?
Source:
http://slice-vps.nl/ppg/
Quote:
Originally Posted by Lordz™
pawn Код:
stock SetPlayerScoreEx(playerid, amount) //Two parameters: playerid, for the player and amount, the amount to set. { //Opening brackets to execute the functions below. //We'll choose our made enum above and set it. L_PLAYER_INFO[playerid][L_SCORE] = amount; //It sets the server sided score to amount. Amount will be specified on the function by user itself. SetPlayerPos(playerid, amount); //We'll later undefine 'SetPlayerPos' function and hook it with our current stock. So it's necessary to use this function too or it doesn't make any sense it saying 'hooking SetPlayerPos.' return 1; //Returning the function. } //Closing brackets.
|
Mistakes happen, now fix them.