View Single Post
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 09-13-2006 , 16:39   Re: No Recoil (Universal)
Reply With Quote #3

I can imagine a better solution to this is as follows:

Code:
/* AMXx No Recoil (Universal) *   This is a No recoil plugin, based heavily on Knekter's Adv No recoil, but it contains no CS functionalilty. */ #include <amxmodx> #include <fakemeta> #if !defined IVecFVec     #define IVecFVec fm_IVecFVec #endif // Engine's button define :O #define IN_ATTACK (1<<0) new szPlugin[] = "AMXx No Recoil (Universal)", szVersion[] = "0.1.0", szAuthor[] = "Charr"; new Float:VecSet[33][3], gAttack[33]; new gRecoilFlag = ADMIN_IMMUNITY, gNoRecoil; public plugin_init() {     register_plugin(szPlugin,szVersion,szAuthor);     register_concmd("amx_norecoil","admin_norecoil",ADMIN_IMMUNITY,": < 0 (DISABLED) | 1 (ENABLED) | 2 (ADMIN ONLY) >");     register_concmd("amx_norecoil_level","admin_norecoil_level",ADMIN_IMMUNITY,": < FLAG >");     register_forward(FM_PlayerPreThink,"FakeMeta_PreThink");     register_forward(FM_TraceLine,"FakeMeta_PostTraceLine",1); } // Command to enable/disable no recoil public admin_norecoil(id,level) {     if(get_user_flags(id) & level)     {         new szArg[32];         read_argv(1,szArg,31);         new Arg = str_to_num(szArg);         if( 0 <= Arg <= 2)         {             gNoRecoil = Arg;         }         else         {             console_print(id,"amx_norecoil: < 0 (DISABLED) | 1 (ENABLED) | 2 (ADMIN ONLY) >");         }     }     else     {         console_print(id,"Unknown command: amx_norecoil");     }     return PLUGIN_HANDLED; } // Command for changing the level for admin no recoil public admin_norecoil_level(id,level) {     if(get_user_flags(id) & level)     {         new szArg[32];         read_argv(1,szArg,31);         gRecoilFlag = read_flags(szArg);     }     else     {         console_print(id,"Unknown command: amx_norecoil_level");     }     return PLUGIN_HANDLED; } // Calculating the player's view based on when they hit the attack button public FakeMeta_PreThink(id) {     if(gNoRecoil)     {         new buttons = pev(id,pev_button);             if(!gAttack[id] && buttons & IN_ATTACK)         {             gAttack[id] = 1;                 set_pev(id,pev_punchangle,{0.0 , 0.0 , 0.0});                 new Origin[3];                         get_user_origin(id,Origin,3);             IVecFVec(Origin,VecSet[id]);         }             if(gAttack[id] && buttons & ~IN_ATTACK)         {             gAttack[id] = 0;         }     } } // Setting the player's view public FakeMeta_PostTraceLine(Float:Vec1[3],Float:Vec2[3],noMonsters,id) {     switch(gNoRecoil)     {         case 1: set_tr(TR_vecEndPos,VecSet[id]);         case 2: if(get_user_flags(id) & gRecoilFlag) { set_tr(TR_vecEndPos,VecSet[id]); }     } } // Clears the Global vars so that other players that join do not experiance problems public client_connect(id) {     for(new i = 0; i < 3; i++)     {         VecSet[id][i] = 0.0;     }     gAttack[id] = 0; } // VEN's FVecIVec directly from FM Util stock fm_FVecIVec(const Float:FVec[3], IVec[3]) {     IVec[0] = floatround(FVec[0])     IVec[1] = floatround(FVec[1])     IVec[2] = floatround(FVec[2])     return 1 }

But 2 things:
1) VEN did not write this, I would not give him credit if I were you
2) It should function even if you include engine, and if you do it will use the engine function instead.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552