Raised This Month: $ Target: $400
 0% 

[Solved] PrimaryAttack/SecondaryAttack


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 03-28-2014 , 19:00   [Solved] PrimaryAttack/SecondaryAttack
Reply With Quote #1

Hello, I need some help. When I write 'pri' I must use 'attack2' once and then PrimaryAttack for knife is blocked, and it's the same with SecondaryAttack. Question, what I need to do, that when I write 'pri' PrimaryAttack should be [un]blocked at the time, and when I write 'sec' SecondaryAttack should be [un]blocked at the time too?


PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
 
new boolblocked[33]
 
public 
plugin_init()
{
    
register_clcmd("say toggle""toggle")
 
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_knife""Fwd_PrimaryAttack"1)
    
RegisterHam(Ham_Item_Deploy"weapon_knife""Fwd_PrimaryAttack"1)
 
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""Fwd_SecondaryAttack"1)
    
RegisterHam(Ham_Item_Deploy"weapon_knife""Fwd_SecondaryAttack"1)
}
 
public 
toggle(id)
        
blocked[id] = !blocked[id]
 
public 
Fwd_PrimaryAttack(Ent)
{
    new 
id get_pdata_cbase(Ent414)
 
    if (
blocked[id])
        
set_pdata_float(Ent479999.04)
 
    return 
HAM_IGNORED
}
 
public 
Fwd_SecondaryAttack(Ent)
{
    new 
id get_pdata_cbase(Ent414)
 
    if (!
blocked[id])
        
set_pdata_float(Ent469999.04)
 
    return 
HAM_IGNORED


Last edited by ~Ice*shOt; 03-29-2014 at 02:41.
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-28-2014 , 19:11   Re: PrimaryAttack/SecondaryAttack
Reply With Quote #2

You basically want to switch between only allowing primary or secondary?
If so, you only need one variable, making two when they always have the opposite function is useless.

Code:
public pri(id)         pblocked[id] = ! pblocked[id];

Code:
public Fwd_PrimaryAttack(Ent) {     new id = get_pdata_cbase(Ent, 41, 4)     if (pblocked[id])         set_pdata_float(Ent, 47, 9999.0, 4)     return HAM_IGNORED } public Fwd_SecondaryAttack(Ent) {     new id = get_pdata_cbase(Ent, 41, 4)     if (!pblocked[id])         set_pdata_float(Ent, 46, 9999.0, 4)     return HAM_IGNORED }
__________________
Black Rose is offline
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 03-28-2014 , 19:18   Re: PrimaryAttack/SecondaryAttack
Reply With Quote #3

Thanks for explaining , now waiting for my real problem solution, because it still works bad.

Last edited by ~Ice*shOt; 03-28-2014 at 19:18.
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-28-2014 , 19:19   Re: PrimaryAttack/SecondaryAttack
Reply With Quote #4

Quote:
Originally Posted by ~Ice*shOt View Post
Thanks for explaining , now waiting for my real problem solution, because it still works bad.
What's your real problem?
__________________
Black Rose is offline
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 03-28-2014 , 19:24   Re: PrimaryAttack/SecondaryAttack
Reply With Quote #5

I tried to explain it in first post, anyway.. Look when I write toggle now, it should toggle one of attacks, but when I write toggle it's still blocked, untill I used opposite button. Idk how to explain that really, it should be tested and you could see it..

Last edited by ~Ice*shOt; 03-28-2014 at 19:25.
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-28-2014 , 20:23   Re: PrimaryAttack/SecondaryAttack
Reply With Quote #6

I have no idea what I did, but it seems to be working.

Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> new bool: blocked[33] new gWeaponEntIndex[33]; public plugin_init() {     register_clcmd("say toggle", "toggle")     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "Fwd_PrimaryAttack", 1)     RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "Fwd_SecondaryAttack", 1)         RegisterHam(Ham_Item_Deploy, "weapon_knife", "Fwd_Item_Deploy") } public Fwd_Item_Deploy(Ent) {     new id = get_pdata_cbase(Ent, 41, 4);     ResetAttack(id, Ent)     gWeaponEntIndex[id] = Ent; } public toggle(id) {     blocked[id] = ! blocked[id];     ResetAttack(id, gWeaponEntIndex[id]) } public Fwd_PrimaryAttack(Ent)     set_pdata_float(Ent, 47, 9999.0, 4); public Fwd_SecondaryAttack(Ent)     set_pdata_float(Ent, 46, 9999.0, 4) ResetAttack(id, Ent) {     if ( blocked[id] ) {         set_pdata_float(Ent, 46, 0.0, 4);         set_pdata_float(Ent, 47, 9999.0, 4)     }     else {         set_pdata_float(Ent, 47, 0.0, 4);         set_pdata_float(Ent, 46, 9999.0, 4)     } }
__________________
Black Rose is offline
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 03-29-2014 , 02:39   Re: PrimaryAttack/SecondaryAttack
Reply With Quote #7

Black Rose, thank you a lot!

Last edited by ~Ice*shOt; 03-29-2014 at 02:40.
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
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 06:03.


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