[HELP]Redefine a native function -
xX_Simon_Xx - 25.04.2012
i want to redefine the SetPlayerAttachedObject, and when it used i want to call the function "OnSetPlayerAttachedObjectToPlayer(playerid,index) "
I'm not sure how to do this because I have a lot of dexterity with the define and undefine can you help me?
This is a small draft of what I tried to do but it is not correct:
PHP код:
stock N_SetPlayerAttachedObject(playerid, index, modelid, bone, Float:fOffsetX=0.0, Float:fOffsetY=0.0, Float:fOffsetZ=0.0, Float:fRotX=0.0, Float:fRotY=0.0, Float:fRotZ=0.0 Float:fScaleX=0.0, Float:fScaleY=0.0, Float:fScaleZ=0.0, materialcolor1=0, materialcolor2=0)
{
SetPlayerAttachedObject(playerid, index, modelid, bone, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ, materialcolor1, materialcolor2);
CallRemoteFunction("OnSetPlayerAttachedObjectToPlayer", "dd", playerid,index);
}
#if defined _ALS_SetPlayerAttachedObject
#undef SetPlayerAttachedObject
#else
#define _ALS_SetPlayerAttachedObject
#endif
#define SetPlayerAttachedObject N_SetPlayerAttachedObject
Re: [HELP]Redefine a native function -
MP2 - 25.04.2012
Looks okay to me. What is the problem?
I THINK function/callback/etc names are limited to 32 characters, but don't hold me to that. Try changing it to something shorter i.e. OnPlayerAttachObject(playerid, index).
Re: [HELP]Redefine a native function -
xX_Simon_Xx - 25.04.2012
I dont test but in this way not else is an infinite loop ??
N_SetPlayerAttachedObject call "SetPlayerAttachedObject"&"OnSetPlayerAttachedObje ctToPlayer"
"SetPlayerAttachedObject" call "N_SetPlayerAttachedObject" because i define it
N_SetPlayerAttachedObject recall "SetPlayerAttachedObject"&"OnSetPlayerAttachedObje ctToPlayer"
and so on
and so in theory it does not continue indefinitely?
Re: [HELP]Redefine a native function -
MP2 - 25.04.2012
No, it's not recursive. If it was your server would freeze.
Re: [HELP]Redefine a native function -
xX_Simon_Xx - 25.04.2012
Tanks it didn't work for me becouse i use ****** fixes.inc and it is been redefinited by it but now work
another little question
where are the default value for materialcolor1 and materialcolor2 ?
are 0 or -1
Re: [HELP]Redefine a native function -
MP2 - 25.04.2012
Look in a_samp.inc (or whatever include the 'native' line for it is).
Re: [HELP]Redefine a native function -
xX_Simon_Xx - 25.04.2012
ah right LOL I had not thought
however it's in a_players.inc and the value are 0
Tanks for you Help
REP+
Re: [HELP]Redefine a native function -
xX_Simon_Xx - 25.04.2012
Quote:
Originally Posted by ******
The idea of ALS is that it means that multiple includes can hook the same functions. If that isn't working then something has gone wrong somewhere...
Did you put that function at the top of your mode before all the places it is used in?
|
sure the error was in fact now works in the code that I entered when I insert this
both before and after your includes its compile perfectly
PHP код:
stock N_SetPlayerAttachedObject(playerid, index, modelid, bone, Float:fOffsetX = 0.0, Float:fOffsetY = 0.0, Float:fOffsetZ = 0.0, Float:fRotX = 0.0, Float:fRotY = 0.0, Float:fRotZ = 0.0, Float:fScaleX = 1.0, Float:fScaleY = 1.0, Float:fScaleZ = 1.0, materialcolor1=0, materialcolor2=0)
{
SetPlayerAttachedObject(playerid, index, modelid, bone, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ, materialcolor1, materialcolor2);
CallRemoteFunction("OnSetPlayerAttachedObjectToPlayer", "dd", playerid,index);
return 1;
}
#if defined _ALS_SetPlayerAttachedObject
#undef SetPlayerAttachedObject
#else
#define _ALS_SetPlayerAttachedObject
#endif
#define SetPlayerAttachedObject N_SetPlayerAttachedObject
But i prefer use your redefinition in fixes.ini
and now work perfectly