Raised This Month: $ Target: $400
 0% 

Crossbow Help meh!


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
10Stars
Senior Member
Join Date: Mar 2006
Location: New Jersey
Old 10-05-2006 , 20:21   Crossbow Help meh!
Reply With Quote #1

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")
}
 
public client_connect(id) g_crossbow[id] = false
public Event_Death() g_crossbow[read_data(2)] = false
 
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
}
 
public Event_CurWeapon(id)
{
        if(!is_user_alive(id) || !is_user_connected(id)) 
                return PLUGIN_CONTINUE
                
        new temp[2], weapon = get_user_weapon(id, temp[0], temp[1])
        if(weapon == CSW_SCOUT)
        {
                if(g_crossbow[id])
                {
                        entity_set_string(id, EV_SZ_viewmodel, "models/v_crossbow.mdl")
                }
        }
        return PLUGIN_CONTINUE
}
 
public fw_traceline(Float:v1[3],Float:v2[3],noMonsters,id) 
{
        if(!is_user_connected(id) || !is_user_alive(id)) 
        {
                return FMRES_IGNORED;
        }
 
        new victim = get_tr(TR_pHit);
 
        if(!is_user_connected(victim) || !is_user_alive(victim)) 
        {
                return FMRES_IGNORED;
        }
 
        new clip, ammo, weapon = get_user_weapon(id,clip,ammo);
 
        if(weapon != CSW_SCOUT || clip <= 0) 
        {
                return FMRES_IGNORED;
        }
 
        new hitplace = get_tr(TR_iHitgroup);
 
        if(hitplace == HIT_LEFTARM) 
        {
                set_tr(TR_iHitgroup,random_num(HIT_STOMACH,HIT_CHEST));
        }
        else if(hitplace == HIT_RIGHTARM) 
        {
                set_tr(TR_iHitgroup,random_num(HIT_STOMACH,HIT_CHEST));
        }
        else if(hitplace == HIT_RIGHTLEG)
        {
                set_tr(TR_iHitgroup,random_num(HIT_STOMACH,HIT_CHEST));
        }
        else if(hitplace == HIT_STOMACH) 
        {
                set_tr(TR_iHitgroup,random_num(HIT_CHEST,HIT_CHEST));
        }
        else if(hitplace == HIT_LEFTLEG) 
        {
                set_tr(TR_iHitgroup,random_num(HIT_STOMACH,HIT_CHEST));
        }
        
        return FMRES_IGNORED;   
}
 
public event_resethud(id)
{
        if(is_user_alive(id)) set_crosshair(id,0);
}
 
public event_curweapon(id)
{
        if(read_data(2) != CSW_SCOUT)
        {
                set_crosshair(id,0);
        }
 
        else if(crosshair[id])
        {
                set_crosshair(id,1);
        }
}
 
public event_deathmsg()
{
        set_crosshair(read_data(2),0);
}
 
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);
        }
        if(weapon == CSW_SCOUT)
        if(!get_cvar_num("mp_noscoutrecoil"))
 
        if(get_user_button(id) & 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();
}
 
public forward_traceline(Float:v1[3], Float:v2[3], noMonsters, id)
{
        if(!get_cvar_num("mp_noscoutrecoil") || !is_user_connected(id) || !is_user_alive(id))
                return FMRES_IGNORED;
 
        new hit[3], Float:fHit[3];
        get_user_origin(id, hit, 4);
        IVecFVec(hit, fHit);
 
        set_tr(TR_vecEndPos, fHit);
 
        return FMRES_IGNORED;
}
OK, now, im having a problem with the following things:::

1. With this plugin enabled it is suppossed to redirect the hits from leg/stomache/arms to chest hits for higher damage, but it does the extra damage wether you have the crossbow or not, a fix plzzz?

2. Also, the crosshair too (Thanks avalanche for making the crosshair) It unfortunately works wether you have the crossbow or not.

3. The No recoil thing, when you have the crossbow only your suppossed to have no recoil (So you can be running withthe crosshair up and shoot and hit someone) But this doesnt seem to work at all -.-

4. This isnt in the plugin at all, but i want it so that when you have the crossbow you move faster (Kinda like a speed up to about 330 or even set it to a cvar).

5. When someone says /buycrossbow i want it so that it actually gives them a scout, instead of just the upgrade so they dont have to buy the scout seperately.

Im relatively new to coding, and still pretty bad at it, can anyone help?

Current credits for help on the plugin::

Cheap_Suit-->Set up the buying of the crossbow
Avalanche--->Is the crosshair pimp
__________________
www.6o9clan.com

Im 10 $74|2$.
10Stars is offline
Send a message via AIM to 10Stars Send a message via MSN to 10Stars
 



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