21.08.2014, 17:07
Код:
static void _sampgdk_amxhooks_hook_native(AMX *amx, const char *name, AMX_NATIVE address) { int index; AMX_HEADER *hdr = (AMX_HEADER *)amx->base; AMX_FUNCSTUBNT *natives = (AMX_FUNCSTUBNT *)(amx->base + hdr->natives); if (amx_FindNative(amx, name, &index) == AMX_ERR_NONE) { natives[index].address = (ucell)address; } }
Also if you need to store the original address you can use my modification to zeex's function:
Код:
void _streamer_native_hook(AMX *amx, const char *name, AMX_NATIVE address, AMX_NATIVE *store) { int index; AMX_HEADER *hdr = (AMX_HEADER *)amx->base; AMX_FUNCSTUBNT *natives = (AMX_FUNCSTUBNT *)(amx->base + hdr->natives); if (amx_FindNative(amx, name, &index) == AMX_ERR_NONE) { if (store) { *store = (AMX_NATIVE)natives[index].address; } natives[index].address = (ucell)address; } }