[Include] OnPlayerScoreChange(playerid, newscore, oldscore);
#1

Hi, today i learned how to use this CallLocalFunction and Hooking

With this include you can do some cool things like this:

pawn Код:
public OnPlayerScoreChange(playerid, newscore, oldscore)
{
   if(newscore >= 100 && oldscore < 100) {
      GameTextForPlayer(playerid, "[]   Unlocked Rocket Luncher[]~n~Now you can use this weapon",4000,1);
   }
   return 1;
}
Include File:
well this is a small Include and i will not put in file and attach it... just copy paste it

just put this under of OnGameModeInit() or Main()
pawn Код:
forward OnPlayerChangeScore(playerid, newscore, oldscore);
new OldScore[MAX_PLAYERS];

stock SetPlayerScoreEx(playerid, score)
{
    OldScore[playerid] = GetPlayerScore(playerid);
    SetPlayerScore(playerid, score);
    return CallLocalFunction("OnPlayerChangeScore","iii",playerid, score, OldScore[playerid]);
}
   
#if defined _ALS_SetPlayerScore
    #undef SetPlayerScore
#else
    #define _ALS_SetPlayerScore
#endif

#define SetPlayerScore SetPlayerScoreEx
Now dont have your old SetPlayerScore Into SetPlayerScoreEx

it will automatically change by system

Код:
Thanks to() {
   ****** - Told me how to to hook and i learned using "is[128]" stuff from his sscanf function ( THANK YOU! )
   Dr.Lozer - for this include xD ;)
   return Rep++;
}
ENJOY!
Reply
#2

O.o wow i really suck :P
Reply
#3

You sure do.
Why do you need ALS when you aren't even making a use to it?
P.S: You don't put it under OnGameModeInit() OR main(). Try to go through the basics before going advanced. Read the PAWN language guide.
Reply
#4

Actually.
Why creating this?
a_state already have this kind of include.
However, different callback name but it works the same like this.

my a_state is created on December 22, 2012.
Yours is December 29, 2012.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)