Raised This Month: $ Target: $400
 0% 

Custom Weapon Drop & Pickup


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 06-04-2013 , 18:53   Custom Weapon Drop & Pickup
Reply With Quote #1

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 ...
__________________

Last edited by Blizzard_87; 06-04-2013 at 18:55.
Blizzard_87 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-04-2013 , 19:47   Re: Custom Weapon Drop
Reply With Quote #2

Take a look at GHW Weapon Replacement.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 06-04-2013 , 20:12   Re: Custom Weapon Drop
Reply With Quote #3

Quote:
Originally Posted by hornet View Post
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... ?
__________________

Last edited by Blizzard_87; 06-04-2013 at 20:21.
Blizzard_87 is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-05-2013 , 03:40   Re: Custom Weapon Drop
Reply With Quote #4

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
TheDS1337 is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 06-05-2013 , 03:58   Re: Custom Weapon Drop
Reply With Quote #5

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?
__________________
Blizzard_87 is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-05-2013 , 04:02   Re: Custom Weapon Drop
Reply With Quote #6

Quote:
Originally Posted by Blizzard_87 View Post
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...
TheDS1337 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-05-2013 , 05:38   Re: Custom Weapon Drop & Pickup
Reply With Quote #7

Can be done by hooking Touch and then check the model.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 06-05-2013 , 06:05   Re: Custom Weapon Drop & Pickup
Reply With Quote #8

Quote:
Originally Posted by hornet View Post
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.
__________________
Blizzard_87 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-05-2013 , 06:10   Re: Custom Weapon Drop & Pickup
Reply With Quote #9

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
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 06-05-2013 , 06:14   Re: Custom Weapon Drop & Pickup
Reply With Quote #10

Quote:
Originally Posted by hornet View Post
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
__________________
Blizzard_87 is offline
Reply



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 16:27.


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