Raised This Month: $51 Target: $400
 12% 

Hold Only Knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 08-31-2011 , 08:18   Hold Only Knife
Reply With Quote #1

I want to make a boolean variable (made it already), that if its true, it will check in the appropriate public which i dont of (you guys gonna tell me) to force a player hold a knife, if he tries to pick another weapon and/or buy a weapon, it drops it / switches it automatically to knife. How can I do that? can someone give me a code example? (with how to force someone to hold knife, or whats the event/forward)
Diegorkable is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 08-31-2011 , 09:18   Re: Hold Only Knife
Reply With Quote #2

register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
jimaway is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 08-31-2011 , 09:44   Re: Hold Only Knife
Reply With Quote #3

@ jimaway:
You should explain what that does so OP knows how to use it.

@ op:
Info about CurWeapon & other events can be found here.
http://wiki.amxmodx.org/Half-Life_1_...ents#CurWeapon

You can use jimaway's way & filter the results to be called only when the weapon isn't knife like this:
Code:
// 29 == CSW_KNIFE
register_event("CurWeapon", "EventCurWeapon", "be", "1=1", "2!29");
Check if the bool is true in that function & use engclient_cmd(id, "weapon_knife") when it's is.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 08-31-2011 at 11:26. Reason: Fixed code example.
drekes is offline
Send a message via MSN to drekes
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 08-31-2011 , 10:08   Re: Hold Only Knife
Reply With Quote #4

I did that:

PHP Code:
register_event("CurWeapon""KnifeRound""1=1""2!29");

// .......

public KnifeRound(id)
{
    if (
g_KnifeRound)
    {
        
engclient_cmd(id"weapon_knife")
        return 
PLUGIN_CONTINUE
    
}
    
    return 
PLUGIN_CONTINUE

and its not working, people can pick weapons, why is that?
Diegorkable is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 08-31-2011 , 10:22   Re: Hold Only Knife
Reply With Quote #5

try
register_event("CurWeapon", "KnifeRound", "be", "2!29");

Last edited by jimaway; 08-31-2011 at 10:25.
jimaway is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 08-31-2011 , 11:25   Re: Hold Only Knife
Reply With Quote #6

I forgot a part.
Should be:
PHP Code:
register_event("CurWeapon""EventCurWeapon""be""1=1""2!29"); 
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 08-31-2011 , 13:36   Re: Hold Only Knife
Reply With Quote #7

check if get_user_weapon != csw_knife so that it will flip to knife every time its not a knife.

if you want to strip peoples weapon and block weapon pickup use ham_touch weaponbox..

PHP Code:

    RegisterHam
(Ham_Touch"weaponbox""fwdPlayerTouch");
public 
fwdPlayerTouch(id ent)
{
    if(!
g_PistolsOnly)
        return 
HAM_IGNORED;
        
    if (!
IsPlayer(id) || !pev_valident ) || !( pevent pev_flags ) & FL_ONGROUND ) )
        return 
HAM_IGNORED;

    static 
szEntModel[32];
    
pevent pev_model szEntModel 31 );
    
    return 
equalszEntModel "models/w_backpack.mdl" ) ? HAM_IGNORED HAM_SUPERCEDE;

Doc-Holiday is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 08-31-2011 , 13:42   Re: Hold Only Knife
Reply With Quote #8

Quote:
Originally Posted by Doc-Holiday View Post
check if get_user_weapon != csw_knife so that it will flip to knife every time its not a knife.

if you want to strip peoples weapon and block weapon pickup use ham_touch weaponbox..

PHP Code:

    RegisterHam
(Ham_Touch"weaponbox""fwdPlayerTouch");
public 
fwdPlayerTouch(id ent)
{
    if(!
g_PistolsOnly)
        return 
HAM_IGNORED;
        
    if (!
IsPlayer(id) || !pev_valident ) || !( pevent pev_flags ) & FL_ONGROUND ) )
        return 
HAM_IGNORED;

    static 
szEntModel[32];
    
pevent pev_model szEntModel 31 );
    
    return 
equalszEntModel "models/w_backpack.mdl" ) ? HAM_IGNORED HAM_SUPERCEDE;

that event is registered with a condition so there is really no need to check for
get_user_weapon != csw_knife
jimaway 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 21:03.


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