Heres a working version of CodeCallback_FireGrenade for cod2 1.3:
Possible uses: nade explosion timer and preventing people from changing team after throwing a grenade (prevent those filthy teamkills)
libcod.cpp:
after
addCode:int codecallback_playercommand = 0; int codecallback_userinfochanged = 0;
afterCode:int codecallback_fire_grenade = 0;
addCode:#else codecallback_playercommand = codscript_load_function((char *)"maps/mp/gametypes/_callbacksetup", (char *)"CodeCallback_PlayerCommand", 0); codecallback_userinfochanged = codscript_load_function((char *)"maps/mp/gametypes/_callbacksetup", (char *)"CodeCallback_UserInfoChanged", 0);
Below that function, add:Code:codecallback_fire_grenade = codscript_load_function((char *)"maps/mp/gametypes/_callbacksetup", (char *)"CodeCallback_FireGrenade", 0);
Code:cHook *hook_fire_grenade; int fire_grenade(int player, int a2, int a3, int weapon, int a5) { hook_fire_grenade->unhook(); int (*sig)(int player, int a2, int a3, int a4, int a5); *(int *)&sig = hook_fire_grenade->from; int grenade = sig(player, a2, a3, weapon, a5); hook_fire_grenade->hook(); int (*sig2)(int weapon); *(int *)&sig2 = 0x80EB9A4; //cod2_1_3 int weaponname = sig2(weapon); char *wname2 = *(char**)weaponname; stackPushString(wname2); stackPushEntity(grenade); short ret = codscript_call_callback_entity(player, codecallback_fire_grenade, 2); codscript_callback_finish(ret); return grenade; }
and in an appropriate spot (somewhere in class cCallOfDuty2Pro) add
Values for other cod versions:Code:hook_fire_grenade = new cHook(0x810E68E, (int) fire_grenade); hook_fire_grenade->hook();
cod2_1_0:
hook_fire_grenade: 0x810C1F6
sig2:
0x80E9270
cod2_1_2:
hook_fire_grenade:
0x810E532
sig2:
0x80EB860
Inside your _callbacksetup add this:
This function will be called when a player throws a nade, on the player that is throwing the nade. The grenade-var will be the entity of the grenade, and the name will be a string, like "frag_grenade_american_mp"Code:CodeCallback_FireGrenade(grenade, name) { }
Have fun![]()

Reply With Quote