How to hook a function?

BBB

Active member
Joined
Apr 5, 2013
Messages
62
Reaction score
1
Can someone give me an example of hooking the "GameTextForPlayer"-function? I would like to get the content of its pushed parameters.
 

StyleRxd

Well-known member
Joined
Mar 13, 2013
Messages
292
Reaction score
0
[youtube:1nxdt089]http://www.youtube.com/watch?v=ORYACPiTBXw[/youtube:1nxdt089]

|GameTextForPlayer|onspawn,ondeath and more examples

Code:
public OnPlayerSpawn(playerid)
{ GameTextForPlayer(playerid,"~k~Have a nice game",3000,4);
return 1;
}


-------------
public OnPlayerDeath(playerid, killerid, reason)
{ GameTextForPlayer(playerid,"~k~Haha you die",3000,4);
return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new string[128];
    format(string, sizeof(string), "You are entering vehicle %i",vehicleid);
    SendClientMessage(playerid, 0xFFFFFFFF, string);
    return 1;
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new string[128];
    format(string, sizeof(string), "You are entering vehicle %i",vehicleid);
    SendClientMessage(playerid, 0xFFFFFFFF, string);
    return 1;


Link for hook the function: http://wiki.sa-mp.com/wiki/OnPlayerEnterVehicle

Link for more Styles: http://wiki.sa-mp.com/wiki/GameTextStyle
 

BBB

Active member
Joined
Apr 5, 2013
Messages
62
Reaction score
1
@StyleRxd I didn't mean that..

@0x688
I have found a tutorial about hooking by using the detours 1.5 lib but I don't get it howto include that into my project, plz help
 

Dem0n

Active member
Joined
Apr 1, 2013
Messages
82
Reaction score
0
Location
Winland ^^
@StyleRxd I didn't mean that..

@0x688
I have found a tutorial about hooking by using the detours 1.5 lib but I don't get it howto include that into my project, plz help
Maybe add link and "we" can help you?
 

25GHz

Active member
Joined
Feb 19, 2013
Messages
167
Reaction score
0
Can someone give me an example of hooking the "GameTextForPlayer"-function? I would like to get the content of its pushed parameters.

you can easily do that with or without sobeit....

Code:
char *text; //set your text.... like: "~r~imma 1337 nigger~w~!" 
int time; //time to show the text(in ms)... like: 1000ms(1sec)
int textsize; //size... like: 5 for example

uint32_t DoneAddr = g_dwSAMP_Addr/*BaseAddress*/ + 0x63F00/*0.3xR1*/;
__asm 
{
push textsize
push time
push text
call DoneAddr
}
in case you don't do it in sobeit, you just gonna have to set the base address of samp dll module by yourself(easy stuff).

...and in case you need such thing for other game(not GTA:SA:MP), its totaly different(i'm saying that because i'm sure that someone gonna try it :D :D:D ).
 

BBB

Active member
Joined
Apr 5, 2013
Messages
62
Reaction score
1
@25ghz:
nonetheless I solved this problem 2 months ago, this has nothing to do with hooking? ^^
 

25GHz

Active member
Joined
Feb 19, 2013
Messages
167
Reaction score
0
@25ghz:
nonetheless I solved this problem 2 months ago, this has nothing to do with hooking? ^^

Can someone give me an example of hooking the "GameTextForPlayer"-function? I would like to get the content of its pushed parameters.

thats what you asked? ^^
yes it does? ^^
 

BBB

Active member
Joined
Apr 5, 2013
Messages
62
Reaction score
1
maybe I wasn't clear enough
by hooking I mean intercepting the function call and change it's behavior
using this I can change the parameters, or just do nothing etc.
 

25GHz

Active member
Joined
Feb 19, 2013
Messages
167
Reaction score
0
maybe I wasn't clear enough
by hooking I mean intercepting the function call and change it's behavior
using this I can change the parameters, or just do nothing etc.

i'm sure you wasn't clear enough(at least to me)... :| :|:|

this function basically is going to add the "game text" in your screen(according to the custom params that you gonna use before call it).
(you can trace the memory address in debuger to see by yourself... ;) ;);) ).
here... look:

look at the address:
3dE1L.png

now going to the second call("01DC3BA1"):
3dE3w.png

the function(as a sample):
3dEf8.png

P.S.:
here is my base address: http://puu.sh/3dG2o.png

anyway... you said that you already solved.
(so nvm, just forget that this thread existed). :p :p:p
 
Top