AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Custom Weapon Drop & Pickup (https://forums.alliedmods.net/showthread.php?t=217610)

Blizzard_87 06-04-2013 18:53

Custom Weapon Drop & Pickup
 
im trying to make it so if you have a custom gun and you drop it or you die the custom model shows on floor and also when picked up that player gets the custom weapon..

this is my code so far.. but i have NO idea howto even start... if someone could point me in the right direction id be very thankful..

Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #define PLUGIN "Golden Weapons" #define VERSION "1.0" #define AUTHOR "Blizzard" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_event("CurWeapon","event_curweapon","be", "1=1");     } public plugin_precache() {         precache_model("models/golden/v_ak47.mdl");     precache_model("models/golden/p_ak47.mdl");     precache_model("models/golden/v_m4a1.mdl");     precache_model("models/golden/p_m4a1.mdl");     precache_model("models/golden/v_deagle.mdl");     precache_model("models/golden/p_deagle.mdl"); } public event_curweapon(id) {     new clip, ammo, weapon = get_user_weapon(id, clip, ammo);         if(weapon == CSW_AK47) {         set_pev(id, pev_viewmodel2, "models/golden/v_ak47.mdl");         set_pev(id, pev_weaponmodel2, "models/golden/p_ak47.mdl");                 if(pev(id, pev_button) & IN_ATTACK) {             set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0});         }     }     if(weapon == CSW_M4A1) {         set_pev(id, pev_viewmodel2, "models/golden/v_m4a1.mdl");         set_pev(id, pev_weaponmodel2, "models/golden/p_m4a1.mdl");                 if(pev(id, pev_button) & IN_ATTACK)  {               set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0});         }     }     if(weapon == CSW_DEAGLE) {         set_pev(id, pev_viewmodel2, "models/golden/v_deagle.mdl");         set_pev(id, pev_weaponmodel2, "models/golden/p_deagle.mdl");                 if(pev(id, pev_button) & IN_ATTACK) {               set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0});         }     }     return PLUGIN_CONTINUE; }

i do have the w_ models also ...

hornet 06-04-2013 19:47

Re: Custom Weapon Drop
 
Take a look at GHW Weapon Replacement.

Blizzard_87 06-04-2013 20:12

Re: Custom Weapon Drop
 
Quote:

Originally Posted by hornet (Post 1964774)
Take a look at GHW Weapon Replacement.

thanks... got the droped weapon showing as custom model now ...

im assuming i can do same way with weapon pickup? detect is picked up weapon is custom model if it is then set weapon to custom weapon...

EDIT: ok no luck.. is it possible to detect the weapons model when pickup?

so if the model on w_ is custom and you pick it up... is it possible to check

if( equal( pickedupgun, "model/custom/custom.mdl" ) ) {
set_pev( etc etc etc... ?

TheDS1337 06-05-2013 03:40

Re: Custom Weapon Drop
 
Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN "Golden Weapons"
#define VERSION "1.0"
#define AUTHOR "Blizzard"

new g_weaponModels[][] = {
        "w_ak47.mdl",
        "w_m4a1.mdl",
        "w_deagle.mdl"
};

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
   
    register_event("CurWeapon","event_curweapon","be", "1=1");
       
        register_forward(FM_SetModel, "fw_SetModel" );   
}

public plugin_precache() {   
    precache_model("models/golden/v_ak47.mdl");
    precache_model("models/golden/p_ak47.mdl");
    precache_model("models/golden/v_m4a1.mdl");
    precache_model("models/golden/p_m4a1.mdl");
    precache_model("models/golden/v_deagle.mdl");
    precache_model("models/golden/p_deagle.mdl");
       
        for(new i = 0; i < sizeof g_weaponModels; i++)
        {
                static modelPatch[124];
                formatex(modelPatch, charsmax(modelPatch), "models/golden/%s", g_weaponModels[i]);
                precache_model(modelPatch);
        }
}

public event_curweapon(id) {
    new clip, ammo, weapon = get_user_weapon(id, clip, ammo);
   
    if(weapon == CSW_AK47) {
        set_pev(id, pev_viewmodel2, "models/golden/v_ak47.mdl");
        set_pev(id, pev_weaponmodel2, "models/golden/p_ak47.mdl");
       
        if(pev(id, pev_button) & IN_ATTACK) {
            set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0});
        }
    }
    if(weapon == CSW_M4A1) {
        set_pev(id, pev_viewmodel2, "models/golden/v_m4a1.mdl");
        set_pev(id, pev_weaponmodel2, "models/golden/p_m4a1.mdl");
       
        if(pev(id, pev_button) & IN_ATTACK)  { 
            set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0});
        }
    }
    if(weapon == CSW_DEAGLE) {
        set_pev(id, pev_viewmodel2, "models/golden/v_deagle.mdl");
        set_pev(id, pev_weaponmodel2, "models/golden/p_deagle.mdl");
       
        if(pev(id, pev_button) & IN_ATTACK) { 
            set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0});
        }
    }
    return PLUGIN_CONTINUE;
}

public fw_SetModel(ent, const model[]) {
        for(new i = 0; i < sizeof g_weaponModels; i++) {
                if(equal(model[7], g_weaponModels[i])) {
                        static newModel[32];
                        formatex(newModel, charsmax(newModel), "models/golden/%s", g_weaponModels[i]);
                        engfunc(EngFunc_SetModel, ent, newModel);
                        return FMRES_SUPERCEDE;
                }
        }
        return FMRES_IGNORED;
}

btw, you can check any w model :)

Blizzard_87 06-05-2013 03:58

Re: Custom Weapon Drop
 
ive made a slight edit so i can use the const g_weaponModels[][] in more then one way..

Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #define PLUGIN "Golden Weapons" #define VERSION "1.0" #define AUTHOR "Blizzard" new g_weaponModels[][] = {     "ak47",     "m4a1",     "deagle" }; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_event("CurWeapon","event_curweapon","be", "1=1");         register_forward(FM_SetModel, "fw_SetModel" );     } public plugin_precache() {         for(new i = 0; i < sizeof g_weaponModels; i++)     {         static modelPatch[124];         formatex(modelPatch, charsmax(modelPatch), "models/golden/v_%s.mdl", g_weaponModels[i]);         precache_model(modelPatch);         formatex(modelPatch, charsmax(modelPatch), "models/golden/p_%s.mdl", g_weaponModels[i]);         precache_model(modelPatch);         formatex(modelPatch, charsmax(modelPatch), "models/golden/w_%s.mdl", g_weaponModels[i]);         precache_model(modelPatch);     } } public event_curweapon(id) {     new clip, ammo, weapon = get_user_weapon(id, clip, ammo);         if(weapon == CSW_AK47) {         set_pev(id, pev_viewmodel2, "models/golden/v_ak47.mdl");         set_pev(id, pev_weaponmodel2, "models/golden/p_ak47.mdl");                 if(pev(id, pev_button) & IN_ATTACK) {             set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0});         }     }     if(weapon == CSW_M4A1) {         set_pev(id, pev_viewmodel2, "models/golden/v_m4a1.mdl");         set_pev(id, pev_weaponmodel2, "models/golden/p_m4a1.mdl");                 if(pev(id, pev_button) & IN_ATTACK)  {               set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0});         }     }     if(weapon == CSW_DEAGLE) {         set_pev(id, pev_viewmodel2, "models/golden/v_deagle.mdl");         set_pev(id, pev_weaponmodel2, "models/golden/p_deagle.mdl");                 if(pev(id, pev_button) & IN_ATTACK) {               set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0});         }     }     return PLUGIN_CONTINUE; } public fw_SetModel(ent, const model[]) {     for(new i = 0; i < sizeof g_weaponModels; i++) {         static w_model[ 32 ];         formatex( w_model, charsmax( w_model ), "w_%s.mdl", g_weaponModels[ i ] );         if(equal(model[7], w_model)) {             static newModel[32];             formatex(newModel, charsmax(newModel), "models/golden/%s", w_model);             engfunc(EngFunc_SetModel, ent, newModel);             return FMRES_SUPERCEDE;         }     }     return FMRES_IGNORED; }

is there anyway when you pickup a weapon in WeapPickup event to check the modelname? and match it to a custom one? to then auto set true on a bool on that player?

TheDS1337 06-05-2013 04:02

Re: Custom Weapon Drop
 
Quote:

Originally Posted by Blizzard_87 (Post 1964941)
is there anyway when you pickup a weapon in WeapPickup event to check the modelname? and match it to a custom one? to then auto set true on a bool on that player?

I don't think so...

hornet 06-05-2013 05:38

Re: Custom Weapon Drop & Pickup
 
Can be done by hooking Touch and then check the model.

Blizzard_87 06-05-2013 06:05

Re: Custom Weapon Drop & Pickup
 
Quote:

Originally Posted by hornet (Post 1964976)
Can be done by hooking Touch and then check the model.

like this ?

Code:
register_forward(FM_Touch, "fwd_Touch")

Code:
public fw_touch( ent, id ) {     new g_modelname[32];     pev(ent, pev_model, g_modelname, 31 );         if( equal( g_modelname, "w_deagle.mdl" ) ) {         g_iGoldWeap[ id ] = 3;     } }

this is totally wrong cos its totally not working.

hornet 06-05-2013 06:10

Re: Custom Weapon Drop & Pickup
 
You should hook it with engine so you can specify the classnames. Also modelname will be the full directory from game directory eg. models/w_deagle.mdl

Blizzard_87 06-05-2013 06:14

Re: Custom Weapon Drop & Pickup
 
Quote:

Originally Posted by hornet (Post 1964986)
You should hook it with engine so you can specify the classnames. Also modelname will be the full directory from game directory eg. models/w_deagle.mdl

ive been searching the forums. and cant find anything that i understand :(


All times are GMT -4. The time now is 16:27.

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