Raised This Month: $ Target: $400
 0% 

Crossbow Help meh!


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-05-2006 , 23:16   Re: Crossbow Help meh!
Reply With Quote #2

You had a couple functions that were supposed to be called but weren't because you added your own event hooks and didn't merge them with the old ones.

For your no recoil (or no cone of fire)... I put the code into the fw_traceline function (merging the old with the new), and modified it a bit. It sets your end position at straight ahead (like before), but also checks if you are aiming at someone straight ahead, and sets those values for the traceline as well.

I cleaned up the hitgroup changing code a bit, and changed the punchangle prethink code so that it should work (maybe it did before).

Code:
#include <amxmodx> #include <fakemeta> #include <engine> #include <cstrike>   new PLUGIN_NAME[] =     "Crossbow" new PLUGIN_VERSION[] =  "2.9" new PLUGIN_AUTHOR[] =   "10 $74|2$"   new g_cvarEnabled new g_msgCrosshair new bool:g_crossbow[33] new crosshair [33] public plugin_init() {         register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)         register_cvar("amx_cost","800")         register_cvar("mp_noscoutrecoil", "1");         register_event("ResetHUD","Event_ResetHUD","b")         register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")         register_event("DeathMsg", "Event_Death", "a")         register_clcmd("say /buycrossbow", "cmdBuy")         register_forward(FM_TraceLine,"fw_traceline",1)           g_cvarEnabled = register_cvar("sc_enabled","1",FCVAR_SERVER)         g_msgCrosshair = get_user_msgid("Crosshair") }   public plugin_precache() {         precache_model("models/v_crossbow.mdl") } // merged? public client_connect(id) {         g_crossbow[id] = false         set_crosshair(id,0); } // merged public Event_Death() {         new victim = read_data(2)         g_crossbow[victim] = false         set_crosshair(victim,0); }   public cmdBuy(id) {         new Cost = get_cvar_num("amx_cost");         new Money = cs_get_user_money(id);         if(!is_user_alive(id))                 client_print(id, print_chat, "Sorry, You need to be alive")         else if(Money < Cost)                 client_print(id, print_chat, "Sorry, You need %d to buy", Cost)         else if(g_crossbow[id])                 client_print(id, print_chat, "Gordon already sold you a crossbow")         else         {                 g_crossbow[id] = true                 cs_set_user_money(id, Money - Cost)                 client_print(id, print_chat, "Gordon sold you a Crossbow")         }         return PLUGIN_HANDLED } // renamed and repositioned to fit your coding style public Event_ResetHUD(id) {         if(is_user_alive(id)) set_crosshair(id,0); } // merged public Event_CurWeapon(id) {         if(!is_user_alive(id) || !is_user_connected(id))                 return PLUGIN_CONTINUE         if(read_data(2) != CSW_SCOUT)         {                 set_crosshair(id,0);         }         else if(g_crossbow[id] && crosshair[id])         {                 set_crosshair(id,1);                 entity_set_string(id, EV_SZ_viewmodel, "models/v_crossbow.mdl")         }         return PLUGIN_CONTINUE } // merged public fw_traceline(Float:v1[3],Float:v2[3],noMonsters,id) {         if(!is_user_connected(id) || !is_user_alive(id))         {                 return FMRES_IGNORED;         }         new clip, ammo, weapon = get_user_weapon(id,clip,ammo);           if(weapon != CSW_SCOUT || clip <= 0)         {                 return FMRES_IGNORED;         }         new victim = get_tr(TR_pHit);         new hitplace = get_tr(TR_iHitgroup);         // merged/redone         if(get_cvar_num("mp_noscoutrecoil"))         {                 // set aim to straight ahead                 new hit[3], Float:fHit[3];                 get_user_origin(id,hit,4);                 IVecFVec(hit, fHit);                 set_tr(TR_vecEndPos,fHit);                 // test if we hit someone                 new target, body;                 get_user_aiming(id,target,body);                 set_tr(TR_pHit,target);                 set_tr(TR_iHitgroup,body);                 // override values for calculations below                 victim = target;                 hitplace = body;         }           if(!is_user_connected(victim) || !is_user_alive(victim))         {                 return FMRES_IGNORED;         }         // cleaned up         if(hitplace == HIT_LEFTARM || hitplace == HIT_RIGHTARM         || hitplace == HIT_RIGHTLEG || hitplace == HIT_LEFTLEG         || hitplace == HIT_STOMACH)         {                 set_tr(TR_iHitgroup,HIT_CHEST);         }                 return FMRES_IGNORED;   } public client_PreThink(id) {         if(!get_pcvar_num(g_cvarEnabled)) return PLUGIN_CONTINUE;           new clip, ammo, weapon = get_user_weapon(id,clip,ammo);           if(weapon != CSW_SCOUT) return PLUGIN_CONTINUE;           new button = entity_get_int(id,EV_INT_button);           if(button & IN_ATTACK2)         {                 // did he just press it?                 if(!(entity_get_int(id,EV_INT_oldbuttons) & IN_ATTACK2))                 {                         // toggle effect                         set_crosshair(id,!crosshair[id]);                 }                   entity_set_int(id,EV_INT_button,button & ~IN_ATTACK2);         }         // cleaned up... we couldn't be here if weapon wasn't CSW_SCOUT         if(get_cvar_num("mp_noscoutrecoil"))         {                 if(button & IN_ATTACK)                         entity_set_vector(id, EV_VEC_punchangle, Float:{0.0, 0.0, 0.0});         }           return PLUGIN_CONTINUE; }   public set_crosshair(id,enabled) {         crosshair[id] = enabled;           message_begin(MSG_ONE_UNRELIABLE,g_msgCrosshair,_,id);         write_byte(enabled);         message_end(); }

Cheers!
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS

Last edited by XxAvalanchexX; 10-05-2006 at 23:34.
XxAvalanchexX is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:52.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode