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

Solved Prevent knife to be switched to grenade


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 05-01-2019 , 14:30   Prevent knife to be switched to grenade
Reply With Quote #1

I use this code to give zombies grenade at spawn.
That works fine.
But what would like to change is this: when zombie gets a grenade, knife is immediately switched to grenade. How can I prevent this?
I do not want to immediately switch to the grenade.

PHP Code:
public fw_PlayerSpawn_Post(id)
{
    if(!
is_user_alive(id) || !is_user_zombie(id) || !g_firstZombieReward[id])
        return

        
set_task(5.0"give_grenade"id)
}

public 
give_grenade(id)
{    
     if(!
is_user_zombie(id) || !is_user_alive(id) || !g_firstZombieReward[id])
         return

     if(!
user_has_weapon(idCSW_SMOKEGRENADE))
     {
         
give_item(id"weapon_smokegrenade")
     }
     if(!
user_has_weapon(idCSW_FLASHBANG))
     {
         
give_item(id"weapon_flashbang")
     }

__________________
Check my original plugins for cs 1.6 and subscribe on channel
Look at the video below to see blind grenade for zombies

https://www.youtube.com/watch?v=ORC7ZmoaipQ

Look at the video below to see Zombie Hide And Seek mode

https://www.youtube.com/watch?v=xpyYb65EgGs

Last edited by Krtola; 06-11-2019 at 04:27. Reason: Problem is solved
Krtola is offline
Send a message via Skype™ to Krtola
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-01-2019 , 18:27   Re: Prevent knife to be switched to grenade
Reply With Quote #2

There's probably a more elegant way to do this, but this works:
PHP Code:
public give_grenadeid )
{    
    if(!
is_user_zombie(id) || !is_user_alive(id) || !g_firstZombieReward[id])
        return
    
    new 
bool:bSetToKnife;
    
    if( !
user_has_weaponid CSW_SMOKEGRENADE ) )
    {
        
give_itemid "weapon_smokegrenade")
        
bSetToKnife true;
    }
    if ( !
user_has_weaponid CSW_FLASHBANG ) )
    {
        
give_itemid "weapon_flashbang")
        
bSetToKnife true;
    }
    
    if ( 
bSetToKnife )
        
client_cmdid "use weapon_knife" );

__________________
Bugsy is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 05-01-2019 , 18:49   Re: Prevent knife to be switched to grenade
Reply With Quote #3

In ReGame exists:
m_iAutoWepSwitch
https://github.com/s1lentq/ReGameDLL...ules.cpp#L3142

In ConnorMcLeod's thread: https://forums.alliedmods.net/showpo...01#post1712101
it's defined as 509:
Quote:
#define m_fAutoWeaponSwitch 509
For AMXX 190 it's:
PHP Code:
"m_iAutoWepSwitch"  // int
{
    
"type"      "integer"

    "windows"   "2036"
    "linux"     "2056"
    "mac"       "2056"

__________________
My English is A0

Last edited by E1_531G; 05-01-2019 at 18:52.
E1_531G is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-02-2019 , 04:39   Re: Prevent knife to be switched to grenade
Reply With Quote #4

E1_531G, both Connor's thread and amxx 1.9 have the same value. Divide the full offset from gamedata by 4 and you'll see.
__________________
HamletEagle is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 05-02-2019 , 09:10   Re: Prevent knife to be switched to grenade
Reply With Quote #5

Yes, it's right.
But in 1.9 offsets are used as a string (with new natives ofc):
Quote:
set_ent_data( entity, "CBasePlayer", "m_iAutoWepSwitch", 1 )
__________________
My English is A0
E1_531G is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 05-02-2019 , 16:26   Re: Prevent knife to be switched to grenade
Reply With Quote #6

For now I will use Bugsy method, because I do not understand how to use Connor's.
__________________
Check my original plugins for cs 1.6 and subscribe on channel
Look at the video below to see blind grenade for zombies

https://www.youtube.com/watch?v=ORC7ZmoaipQ

Look at the video below to see Zombie Hide And Seek mode

https://www.youtube.com/watch?v=xpyYb65EgGs
Krtola is offline
Send a message via Skype™ to Krtola
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 06-11-2019 , 04:26   Re: Prevent knife to be switched to grenade
Reply With Quote #7

This is actually client side console command
PHP Code:
_cl_autowepswitch 
// Automatically switch to most powerful gun.
// (When set to 1, when you buy a new gun or run over a gun to pick it up this will automatically switch to that gun)
// If 0, then your current choice of weaponry will stay selected.
__________________
Check my original plugins for cs 1.6 and subscribe on channel
Look at the video below to see blind grenade for zombies

https://www.youtube.com/watch?v=ORC7ZmoaipQ

Look at the video below to see Zombie Hide And Seek mode

https://www.youtube.com/watch?v=xpyYb65EgGs
Krtola is offline
Send a message via Skype™ to Krtola
Reply


Thread Tools
Display Modes

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 11:52.


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