AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Zombie Plague Mod (https://forums.alliedmods.net/forumdisplay.php?f=126)
-   -   Suggestion / Subplugin Request [REQ] Item Limiter Plugin (https://forums.alliedmods.net/showthread.php?t=215897)

M@RSH@L 05-13-2013 16:12

[REQ] Item Limiter Plugin
 
Hello
I need a plugin that can add limit to some extra items like knife blink , armor ...
anyone can create this ?

Catastrophe 05-14-2013 01:11

Re: [REQ] Item Limiter Plugin
 
Plzz dont post half info .... For wichever items u want limit just post their sma here... i'll try to do it.... :)

M@RSH@L 05-15-2013 14:30

Re: [REQ] Item Limiter Plugin
 
4 Attachment(s)
Sorry :D

For this time these 4 plugins is enough

Tanks for your reply. :oops:

Catastrophe 05-16-2013 01:00

Re: [REQ] Item Limiter Plugin
 
Try and tell if this works..... Then i'll also make others.....

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","3")  
    
    
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;



M@RSH@L 05-16-2013 13:42

Re: [REQ] Item Limiter Plugin
 
yes it works fine , but when compiling sma give 4 warnings .

Catastrophe 05-17-2013 00:40

Re: [REQ] Item Limiter Plugin
 
Post the warnings plzzz..

M@RSH@L 05-17-2013 05:26

Re: [REQ] Item Limiter Plugin
 
<53> : Warning 217: Loose indentation
<55> : Warning 217: Loose indentation
<145> : Warning 217: Loose indentation
<146> : Warning 217: Loose indentation

Catastrophe 05-17-2013 10:59

Re: [REQ] Item Limiter Plugin
 
Ohk lol that .... i thoought whtever warnings u were getting xD.... W8 i'll allso convert other plugins and fix this one ....

Catastrophe 05-17-2013 12:28

Re: [REQ] Item Limiter Plugin
 
4 Attachment(s)
All done ... :)

M@RSH@L 05-17-2013 12:56

Re: [REQ] Item Limiter Plugin
 
GJ Catastrophe :D

it's Great :D

can u make a main plugin that can add limit to extra items ?


All times are GMT -4. The time now is 14:40.

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