This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Solved I want Drop This Weapons Only


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DOCTOR DT
Junior Member
Join Date: Jun 2024
Old 06-11-2024 , 02:00   I want Drop This Weapons Only
Reply With Quote #1

i want to drop this weapons If Client Have It without dropping other weapons i tried to do that but i couldnt :
new const all_weapons[][] = {
"weapon_p228",
"weapon_shield",
"weapon_scout",
"weapon_xm1014",
"weapon_mac10",
"weapon_aug",
"weapon_elite",
"weapon_fiveseven",
"weapon_ump45",
"weapon_sg550",
"weapon_galil",
"weapon_famas",
"weapon_usp",
"weapon_glock18",
"weapon_mp5navy",
"weapon_m249",
"weapon_m3",
"weapon_tmp",
"weapon_g3sg1",
"weapon_sg552",
"weapon_p90"
}

Last edited by DOCTOR DT; 06-12-2024 at 08:47.
DOCTOR DT is offline
DenisB29
Junior Member
Join Date: Mar 2024
Old 06-11-2024 , 07:28   Re: I want Drop This Weapons Only
Reply With Quote #2

Why don't you just restrict them using restweapons?

Open plugins.ini

Code:
 ;restmenu.amxx
to
Code:
 restmenu.amxx
Then amx_restmenu and select weapons
DenisB29 is offline
Tote
Senior Member
Join Date: Jul 2023
Old 06-11-2024 , 10:31   Re: I want Drop This Weapons Only
Reply With Quote #3

https://forums.alliedmods.net/showthread.php?t=89811

or use this method:

Code:
stock ham_strip_weapon(id,weapon[])
{
    if(!equal(weapon,"weapon_",7)) return 0;

    new wId = get_weaponid(weapon);
    if(!wId) return 0;

    new wEnt;
    while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
    if(!wEnt) return 0;

    if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);

    if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
    ExecuteHamB(Ham_Item_Kill,wEnt);

    set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));

    // this block should be used for Counter-Strike:
    /*if(wId == CSW_C4)
    {
        cs_set_user_plant(id,0,0);
        cs_set_user_bpammo(id,CSW_C4,0);
    }
    else if(wId == CSW_SMOKEGRENADE || wId == CSW_FLASHBANG || wId == CSW_HEGRENADE)
        cs_set_user_bpammo(id,wId,0);*/

    return 1;
}
Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Strip weapons Example"
#define VERSION "1.0"
#define AUTHOR "Tote"


new all_weapons[] = {
"weapon_p228",
"weapon_shield",
"weapon_scout",
"weapon_xm1014",
"weapon_mac10",
"weapon_aug",
"weapon_elite",
"weapon_fiveseven",
"weapon_ump45",
"weapon_sg550",
"weapon_galil",
"weapon_famas",
"weapon_usp",
"weapon_glock18",
"weapon_mp5navy",
"weapon_m249",
"weapon_m3",
"weapon_tmp",
"weapon_g3sg1",
"weapon_sg552",
"weapon_p90"
}

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd("say /strip", "cc")
}

public cc(id) {
	ham_strip_weapon(id, all_weapons)
}

stock ham_strip_weapon(id,weapon[]) // taken from other source (maybe connor)
{
    if(!equal(weapon,"weapon_",7)) return 0;

    new wId = get_weaponid(weapon);
    if(!wId) return 0;

    new wEnt;
    while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
    if(!wEnt) return 0;

    if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);

    if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
    ExecuteHamB(Ham_Item_Kill,wEnt);

    set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));

    // this block should be used for Counter-Strike:
    /*if(wId == CSW_C4)
    {
        cs_set_user_plant(id,0,0);
        cs_set_user_bpammo(id,CSW_C4,0);
    }
    else if(wId == CSW_SMOKEGRENADE || wId == CSW_FLASHBANG || wId == CSW_HEGRENADE)
        cs_set_user_bpammo(id,wId,0);*/

    return 1;
}

Last edited by Tote; 06-11-2024 at 10:46.
Tote is offline
Old 06-12-2024, 00:42
DOCTOR DT
This message has been deleted by DOCTOR DT.
DOCTOR DT
Junior Member
Join Date: Jun 2024
Old 06-12-2024 , 01:05   Re: or use this method
Reply With Quote #4

There Is A Problem If I have Two weapons from these weapons it strip one and let the other
DOCTOR DT is offline
DOCTOR DT
Junior Member
Join Date: Jun 2024
Old 06-12-2024 , 01:06   Re: I want Drop This Weapons Only
Reply With Quote #5

Quote:
Originally Posted by DenisB29 View Post
Why don't you just restrict them using restweapons?

Open plugins.ini

Code:
 ;restmenu.amxx
to
Code:
 restmenu.amxx
Then amx_restmenu and select weapons
Bro That Not What I Want
DOCTOR DT is offline
Tote
Senior Member
Join Date: Jul 2023
Old 06-12-2024 , 05:22   Re: or use this method
Reply With Quote #6

Quote:
Originally Posted by DOCTOR DT View Post
There Is A Problem If I have Two weapons from these weapons it strip one and let the other
do it defaultly maybe

1. ham_strip_weapon(id, "weapon_m4a1")
2. ham_strip_weapon(id, "weapon_ak47")

or make a CHECK if has any of those weapons and then strip i think
Tote is offline
DOCTOR DT
Junior Member
Join Date: Jun 2024
Old 06-12-2024 , 08:46   Re: or use this method
Reply With Quote #7

Quote:
Originally Posted by Tote View Post
do it defaultly maybe

1. ham_strip_weapon(id, "weapon_m4a1")
2. ham_strip_weapon(id, "weapon_ak47")

or make a CHECK if has any of those weapons and then strip i think
You Know Its Easiest To Do it "defaultly" thanks
DOCTOR DT 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 10:10.


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