Raised This Month: $ Target: $400
 0% 

Suggestion / Subplugin Request [Help] Problem with extra items


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hosimosi
Senior Member
Join Date: Apr 2013
Old 12-30-2013 , 16:48   [Help] Problem with extra items
Reply With Quote #1

I'm using Assassin in my server, how to block this extra item for Assassin and nemesis?
PHP Code:
/*================================================================================
    
    -------------------------------------------
    -*- [ZP] Extra Item: Knife Blink 1.2 -*-
    -------------------------------------------
    
    ~~~~~~~~~~~~~~~
    - Description -
    ~~~~~~~~~~~~~~~
    
    This item/upgrade gives zombies the possibility to move rapidly towards a human over a short distance, when aiming at him and holding down the attack button.
    
================================================================================*/

#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#include <chr_engine>

#define MIN_DISTANCE 50

/*================================================================================
 [Plugin Customization]
=================================================================================*/

new const g_item_name[] = { "Knife Blink (once)" }
const 
g_item_cost 5
const g_iMaxDistance 300;
new 
g_limit[33], cvar_limit_kb

/*============================================================================*/

new Float:g_fSpeed 1000.0;
new 
Float:g_fDelay 1.0;

new 
g_iMaxPlayers;
new 
g_iEnemy[33];
new 
g_iInBlink[33];
new 
Float:g_fLastSlash[33];
new 
g_iCanceled[33];
new 
g_iSlash[33];
new 
g_iBlinks[33];
new 
g_itemid_blink;

public 
plugin_init(){
    
    
register_plugin("[ZP] Extra Item: Knife Blink""1.2""pharse");
    
    
g_iMaxPlayers get_maxplayers();
    
    
g_itemid_blink zp_register_extra_item(g_item_nameg_item_costZP_TEAM_ZOMBIE);

    
cvar_limit_kb register_cvar("zp_limit_kb","10")  
    
    
register_forward(FM_TraceLine"FW_TraceLine_Post"1);
    
register_forward(FM_PlayerPreThink"FW_PlayerPreThink");
    
    
register_event("HLTV""EVENT_round_start""a""1=0""2=0")
}

// ================================================== //
//             FORWARDS / EVENTS
// ================================================== //

public FW_TraceLine_Post(Float:start[3], Float:end[3], conditionsidtrace){
    
    if (!
CHECK_ValidPlayer(id))
        return 
FMRES_IGNORED;
    
    new 
iWeaponID get_user_weapon(id);
    
    if ( 
iWeaponID != CSW_KNIFE ){
        
        
OP_Cancel(id);
        return 
FMRES_IGNORED;
    }
    
    new 
enemy g_iEnemy[id];
    
    if (!
enemy){
        
        
enemy get_tr2(traceTR_pHit);
        
        if ( !
CHECK_ValidPlayer(enemy) || zp_get_user_zombie(enemy) ){
            
            
OP_Cancel(id);
            return 
FMRES_IGNORED;
        }
        
        
g_iEnemy[id] = enemy;
    }
    
    return 
FMRES_IGNORED;
}

public 
FW_PlayerPreThink(id){
    
    if (!
CHECK_ValidPlayer(id))
        return 
FMRES_IGNORED;
    
    new 
iWeaponID get_user_weapon(id);
    
    if ( 
iWeaponID != CSW_KNIFE || !zp_get_user_zombie(id) ){
        
        
OP_Cancel(id);
        return 
FMRES_IGNORED;
    }
    
    if ( 
g_iBlinks[id] == )
        return 
FMRES_IGNORED;
    
    new 
button pev(id,pev_button);
    
    if ( !(
button IN_ATTACK) && !(button IN_ATTACK2) ){
        
        
OP_Cancel(id)
        return 
FMRES_IGNORED;
    }
    
    if (
g_iSlash[id])
        
g_iSlash[id] = 0;
    
    
OP_NearEnemy(id);
    
    if( 
g_iInBlink[id] ){
        
        
OP_SetBlink(id);
        
OP_Blink(id);
        
g_iCanceled[id] = 0;
    }

    return 
FMRES_IGNORED;
}

// Player buys our upgrade, add one blink
public zp_extra_item_selected(playeritemid)
{
    if (
itemid == g_itemid_blink )
        {
 
          if (
g_limit[player] <= get_pcvar_num(cvar_limit_kb))
          {
        
          
g_iBlinks[player] += 1;
          
g_limit[player] += 1
          
client_print(playerprint_chat"[ZP] You have now %d Knife Blinks"g_iBlinks[player]);
          }

          else
          {
        
          
client_print(playerprint_chat"[ZP] Max Knife Blinks Reached !!!")



          } 



    }

        

}

// Reset blinks for all players on newround
public EVENT_round_start()
{
    for (new 
idid <= 32id++)
        {
        
g_iBlinks[id] = 0
        g_limit
[id] = 
        
}
}

// ================================================== //
//             OPERATIONS
// ================================================== //

public OP_NearEnemy(id){
    
    new 
enemy g_iEnemy[id];
    new 
Float:time get_gametime();
    
    if (!
enemy || g_fLastSlash[id]+g_fDelay>time){
        
        
g_iInBlink[id] = 0;
        return;
    }
    
    new 
origin[3], origin_enemy[3];
    
    
get_user_origin(idorigin0);
    
get_user_origin(enemyorigin_enemy0);
    
    new 
distance get_distance(originorigin_enemy);
    
    if ( 
MIN_DISTANCE<=distance<=g_iMaxDistance){
        
        
g_iInBlink[id] = 1;
        return;
        
    }else if (
MIN_DISTANCE>distance && g_iInBlink[id])
    {
        
OP_Slash(id);
    }
    
OP_Cancel(id);
}

public 
OP_Blink(id){
    
    new 
Float:new_velocity[3];
    new 
enemy g_iEnemy[id];
    new 
Float:origin_enemy[3];
    
    
pev(enemypev_originorigin_enemy);
    
entity_set_aim(idorigin_enemy);
    
    
get_speed_vector2(idenemyg_fSpeednew_velocity)
    
set_pev(idpev_velocitynew_velocity);
}

public 
OP_Cancel(id){
    
    
g_iInBlink[id] = 0;
    
g_iEnemy[id] = 0;
    if (!
g_iCanceled[id]){
        
        
OP_SetBlink(id);
        
g_iCanceled[id] = 1;
    }
}

public 
OP_Slash(id){
    
    
set_pev(idpev_velocity, {0.0,0.0,0.0});        // stop player's blink
    
    
new weaponID get_user_weapon(id__);
    
    if(
weaponID == CSW_KNIFE){
        
        new 
weapon[32]
        
        
get_weaponname(weaponID,weapon,31)
        
        new 
ent fm_find_ent_by_owner(-1,weapon,id)
        
        if(
ent){
            
            
set_pdata_float(ent,460.0);
            
set_pdata_float(ent,470.0);
            
g_iSlash[id] = 1;
            
g_fLastSlash[id] = get_gametime();
            
g_iBlinks[id] -= 1;
            new 
name[32];
            
get_user_name(id,name,31)
            
client_print(0print_chat"[ZP] %s just used a Knife Blink!"name);
            
client_print(idprint_chat"[ZP] %d Knife Blinks remaining"g_iBlinks[id]);
        }
    }  
}

public 
OP_SetBlink(id){
    
    new 
blink g_iInBlink[id];
    
    if (
blink>1)
        return;
    
    if (
blink)
        
g_iInBlink[id] += 1;
}

// ================================================== //
//             CHECKS
// ================================================== //

public CHECK_ValidPlayer(id){
    
    if (
1<=id<=g_iMaxPlayers && is_user_alive(id))
        return 
1;
    
    return 
0;
}

// from fakemeta_util.inc
stock fm_find_ent_by_owner(index, const classname[], ownerjghgtype 0) {
    new 
strtype[11] = "classname"ent index;
    switch (
jghgtype) {
        case 
1strtype "target";
        case 
2strtype "targetname";
    }

    while ((
ent engfunc(EngFunc_FindEntityByStringentstrtypeclassname)) && pev(entpev_owner) != owner) {}

    return 
ent;

with this script

PHP Code:
public zp_fw_items_select_pre(iditemidignorecost

    
// This is not our item 
    
if (itemid != g_ItemID
        return 
ZP_ITEM_AVAILABLE
     
    
// Jetpack+Bazooka only available to humans 
    
if (zp_core_is_zombie(id) || zp_get_user_nemesis(id) || zp_get_user_assassin(id)) 
        return 
ZP_ITEM_DONT_SHOW
     
    return 
ZP_ITEM_AVAILABLE

i trying but got some error

Thank you

Last edited by hosimosi; 12-30-2013 at 16:53.
hosimosi is offline
Gasa
Senior Member
Join Date: Sep 2013
Old 12-30-2013 , 16:56   Re: Probelm with extra items
Reply With Quote #2

PHP Code:
public zp_fw_items_select_pre(iditemidignorecost

    
// This is not our item 
    
if (itemid != g_itemid_blink
        return 
ZP_ITEM_AVAILABLE
     
    
// Jetpack+Bazooka only available to humans 
    
if (zp_core_is_zombie(id) || zp_get_user_nemesis(id) || zp_get_user_assassin(id)) 
        return 
ZP_ITEM_DONT_SHOW
     
    return 
ZP_ITEM_AVAILABLE

Gasa is offline
hosimosi
Senior Member
Join Date: Apr 2013
Old 12-30-2013 , 17:06   Re: Probelm with extra items
Reply With Quote #3

Quote:
Originally Posted by Gasa View Post
PHP Code:
public zp_fw_items_select_pre(iditemidignorecost

    
// This is not our item 
    
if (itemid != g_itemid_blink
        return 
ZP_ITEM_AVAILABLE
     
    
// Jetpack+Bazooka only available to humans 
    
if (zp_core_is_zombie(id) || zp_get_user_nemesis(id) || zp_get_user_assassin(id)) 
        return 
ZP_ITEM_DONT_SHOW
     
    return 
ZP_ITEM_AVAILABLE

yeah i know !
when put it to this plugin get some error
hosimosi is offline
hosimosi
Senior Member
Join Date: Apr 2013
Old 12-31-2013 , 04:20   Re: [Help] Problem with extra items
Reply With Quote #4

np i fix it

closed.
hosimosi 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 00:40.


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