AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   event_round_start dont work (?) (https://forums.alliedmods.net/showthread.php?t=88444)

AlejandroSk 03-24-2009 18:48

event_round_start dont work (?)
 
hello , i made this code [credits to connormcleod]
but when round end i still have fast attack rate whit knife
please someone fix it

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>

#define PLUGIN "[ZP] Extra Item: Carnicero!"
#define VERSION "1.0"
#define AUTHOR "AlejandroSk & alan_el_more credits ConnorMcLeod"

#define    m_flNextPrimaryAttack    46 
#define    m_flNextSecondaryAttack    47 
#define    m_flTimeWeaponIdle        48 

new g_itemid1bool:g_HasCarnicero[33]
new 
cvar_attack1ratecvar_attack2ratecvar_costcvar_togglecvar_message

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
cvar_cost register_cvar("zp_carnicero_cost""15")
    
cvar_toggle register_cvar("zp_carnicero_enabled""1")
    
cvar_attack1rate register_cvar("zp_carnicero_attack1_rate""0.1")
    
cvar_attack2rate register_cvar("zp_carnicero_attack2_rate""0.8")
    
cvar_message register_cvar("zp_carnicero_hudmessage""1")
    
g_itemid1 zp_register_extra_item("Carnicero"get_pcvar_num(cvar_cost), ZP_TEAM_HUMAN)
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_knife""Knife_PrimaryAttack"1
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""Knife_SecondaryAttack"1)
}

public 
client_connect(id)
{
    
g_HasCarnicero[id] = false
}

public 
zp_extra_item_selected(iditemid)
{
    if (
itemid == g_itemid1)
    {
        if (
get_pcvar_num(cvar_toggle))
        {
            
        
g_HasCarnicero[id] = true
        client_print
(id,print_chat"Te Convertiste En Un Carnicero!")
        
fm_set_user_armor(id500)
        new 
name[32]
        
get_user_name(idname31)
        if (
get_pcvar_num(cvar_message))
        {
        
set_hudmessage(255000.030.4306.012.0)
        
show_hudmessage(id":: %s Se Ha Comprado Un Carnicero ::"name)
        }
        
        }
    }
}

public 
Knife_PrimaryAttackiEnt 

    static 
Float:flRate flRate get_pcvar_float(cvar_attack1rate)
    static 
id id peviEnt pev_owner );
    
    if (!
g_HasCarnicero[id] == true)
    {
    
set_pdata_float(iEntm_flNextPrimaryAttack1.04
    
set_pdata_float(iEntm_flNextSecondaryAttack1.04
    
set_pdata_float(iEntm_flTimeWeaponIdle1.04
    }
    else {
        
set_pdata_float(iEntm_flNextPrimaryAttackflRate4
        
set_pdata_float(iEntm_flNextSecondaryAttackflRate4
        
set_pdata_float(iEntm_flTimeWeaponIdleflRate4
    }


public 
Knife_SecondaryAttackiEnt )

    static 
Float:flRate flRate get_pcvar_float(cvar_attack2rate)
    static 
id id peviEnt pev_owner )
    
    if (!
g_HasCarnicero[id] == true)
    {
    
set_pdata_float(iEntm_flNextPrimaryAttack1.04
    
set_pdata_float(iEntm_flNextSecondaryAttack1.04
    
set_pdata_float(iEntm_flTimeWeaponIdle1.04)
    }
    else {
        
set_pdata_float(iEntm_flNextPrimaryAttackflRate4
        
set_pdata_float(iEntm_flNextSecondaryAttackflRate4
        
set_pdata_float(iEntm_flTimeWeaponIdleflRate4)
    }
}
    
public 
event_round_start(id)
{
    
g_HasCarnicero[id] = false
}
        
stock fm_set_user_armor(indexarmor
{
    
set_pev(indexpev_armorvaluefloat(armor));



AntiBots 03-24-2009 18:59

Re: event_round_start dont work (?)
 
PHP Code:

public event_round_start() 

       for(new 
1<= 32i++)
               
g_HasCarnicero[i] = false 



ot_207 03-24-2009 19:03

Re: event_round_start dont work (?)
 
Quote:

Originally Posted by AntiBots (Post 788398)
PHP Code:

public event_round_start() 

       for(new 
1<= 32i++)
               
g_HasCarnicero[i] = false 



Yes! That is the right way to do it because the round_start event is global.
That means that it is only one general event! It isn't called on every player.
So that is why you need to use the for cycle and set g_HasCarnicero[i] to false

AlejandroSk 03-24-2009 20:20

Re: event_round_start dont work (?)
 
thank you all guys!

SnoW 03-25-2009 10:58

Re: event_round_start dont work (?)
 
Or then you can use Ham_Spawn.


All times are GMT -4. The time now is 08:52.

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