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

API Scripting Help [Tut] Creating Item With Limit


Post New Thread Reply   
 
Thread Tools Display Modes
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 01-24-2013 , 10:00   Re: [Tut] Creating Item With Limit
Reply With Quote #11

Well Function Again !
TheDS1337 is offline
gamestar110
Member
Join Date: Sep 2011
Location: india
Old 02-09-2013 , 10:58   Re: [Tut] Creating Item With Limit
Reply With Quote #12

Quote:
Originally Posted by H.RED.ZONE View Post
I will make some more tutorials when i get time.
If possible plz make TUT for making human classes with special skills
__________________
Trying to learn coding for amxx plugins
gamestar110 is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 11-29-2013 , 03:25   Re: [Tut] Creating Item With Limit
Reply With Quote #13

Sorry to revive but can u block extra item for rounds? for example if a player buy a extra item he need to wait two rounds (with cvar) to buy again..

Last edited by wicho; 11-29-2013 at 03:28.
wicho is offline
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 11-29-2013 , 09:42   Re: [Tut] Creating Item With Limit
Reply With Quote #14

yes.... just make a variable and in event_newround check
PHP Code:
if(variable && variable 4)
{
variable++
}

else 
{
variable 0

and in zp_item_post selected
PHP Code:
if(variable == 0)
  {
  
//Make him buy the item (i mean put the buying code here...
  
variable++
  }
else
 {
 return
 } 
__________________
You will find everything u need :-

Last edited by Catastrophe; 11-29-2013 at 09:43.
Catastrophe is offline
StrawberryTart
BANNED
Join Date: Dec 2013
Location: i'm your Special TART!
Old 12-07-2013 , 20:41   Re: [Tut] Creating Item With Limit
Reply With Quote #15

Awesome! sure with this tutorial people will take things lightly (maybe )


P.S: if this post is dead or Etc. srry to revive then

Last edited by StrawberryTart; 12-07-2013 at 20:42. Reason: Srry for revive
StrawberryTart is offline
hosimosi
Senior Member
Join Date: Apr 2013
Old 12-30-2013 , 16:35   Re: [Tut] Creating Item With Limit
Reply With Quote #16

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;

Thank you

Last edited by hosimosi; 12-30-2013 at 16:36.
hosimosi is offline
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 12-31-2013 , 00:28   Re: [Tut] Creating Item With Limit
Reply With Quote #17

@hosimosi
Wrong thread...
__________________
You will find everything u need :-
Catastrophe is offline
mohsen9010
Senior Member
Join Date: Jun 2011
Location: Iran
Old 07-11-2014 , 14:06   Re: [Tut] Creating Item With Limit
Reply With Quote #18

I want a plugin work only for zombies
Is this true way ?
Code:
public zp_fw_items_select_pre(player, itemid, ig)
{
    if (itemid == g_itemid_blink)
    {
        if (zp_core_is_zombie(player))
        {
		return ZP_ITEM_AVAILABLE
        }
        else
        {
		return ZP_ITEM_DONT_SHOW
        }
    }
    return ZP_ITEM_AVAILABLE
}
Or maybe i need to add ZP_ITEM_NOT_AVAILABLE for more secure ?
__________________
Iman in Allah
mohsen9010 is offline
Send a message via Yahoo to mohsen9010 Send a message via Skype™ to mohsen9010
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 07-11-2014 , 16:36   Re: [Tut] Creating Item With Limit
Reply With Quote #19

PHP Code:
public zp_fw_items_select_pre(playeritemidig)
{
    if (
itemid == g_itemid_blink)
    {
       if (!
zp_core_is_zombie(player))   
            return 
ZP_ITEM_DONT_SHOW
    }
    return 
ZP_ITEM_AVAILABLE


Last edited by wicho; 07-11-2014 at 20:06.
wicho is offline
C00LSH33P
Member
Join Date: Apr 2013
Location: Meow City
Old 08-28-2014 , 06:07   Re: [Tut] Creating Item With Limit
Reply With Quote #20

Sorry for hijacking this thread, but can anybody add limit for single player on original zp508 fire, frost and flare grenade? I tried but failed so hard

fire:
Spoiler

frost:
Spoiler

flare:
Spoiler
C00LSH33P 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 06:32.


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