Raised This Month: $ Target: $400
 0% 

Solved [HELP] attack 250 hp = 1 ap


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
spooky HL15
Member
Join Date: Oct 2015
Old 03-19-2018 , 16:10   [HELP] attack 250 hp = 1 ap
Reply With Quote #1

hi, everone i have problem with this scripting
i want make plugin for mod base builder for CT
when CT attack zombie every 250 damage CT will win 1 ap

i try to make it but not working
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "attack 250 hp = 1 ap"
#define VERSION "1.0"
#define AUTHOR "test"

native bb_get_ap1(id)

new 
pg_dmg

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
pg_dmg=register_cvar("bb_hpap","250"
    
register_event("Damage""Damage""b""2!=0")
}
public 
Damage(id)
{
    new 
damage read_data(2)
    new 
tid get_user_attacker(id)    // Gracz atakujacy
    
if(tid==id || !tid || !is_user_alive(tid)) return PLUGIN_HANDLED
    
while(damage>=get_pcvar_num(pg_dmg)){
        
damage-=get_pcvar_num(pg_dmg)
        
        
bb_get_ap1(id)
    }
    return 
PLUGIN_CONTINUE
    



sorry for my bad english

Last edited by spooky HL15; 04-02-2018 at 16:58.
spooky HL15 is offline
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 03-20-2018 , 04:58   Re: [HELP] attack 250 hp = 1 ap
Reply With Quote #2

Where is definition of bb_get_ap1 ?
instinctpt1 is offline
spooky HL15
Member
Join Date: Oct 2015
Old 03-20-2018 , 17:18   Re: [HELP] attack 250 hp = 1 ap
Reply With Quote #3

Quote:
Originally Posted by instinctpt1 View Post
Where is definition of bb_get_ap1 ?
i have it en other scriping point_system ... you just show me how to make scriping for every damage 250 ....
spooky HL15 is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 03-20-2018 , 18:04   Re: [HELP] attack 250 hp = 1 ap
Reply With Quote #4

Store damage somewhere and check if the "somewhere" has reached >= , in order to do stuff.
__________________
Relaxing is offline
spooky HL15
Member
Join Date: Oct 2015
Old 03-20-2018 , 18:15   Re: [HELP] attack 250 hp = 1 ap
Reply With Quote #5

Quote:
Originally Posted by Relaxing View Post
Store damage somewhere and check if the "somewhere" has reached >= , in order to do stuff.
i do not understande you :V

Last edited by spooky HL15; 05-09-2018 at 17:29.
spooky HL15 is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 03-20-2018 , 20:00   Re: [HELP] attack 250 hp = 1 ap
Reply With Quote #6

Add me on steam, we can create a group called No clue on what I'm doing on AM.
__________________
Relaxing is offline
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 03-27-2018 , 11:31   Re: [HELP] attack 250 hp = 1 ap
Reply With Quote #7

Code:
#include < amxmodx >
#include < hamsandwich >
#include < basebuilder >
#include < fun >

new Float:fClientDamage[ 33 ];

public plugin_init( )
{
    RegisterHam( Ham_TakeDamage, "player", "OnTakeDamage", 1 );
}

public client_putinserver( iClient )
{
    fClientDamage[ iClient ] = 0.0;
}

public OnTakeDamage( iVictim, iInflictor, iAttacker, Float:fDamage, biDamage )
{
    if( !IsPlayer( iAttacker ) || !IsPlayer( iVictim ) ) // Both must be players
        return HAM_IGNORED;

    if( !is_user_alive( iAttacker ) ) // Only alive
        return HAM_IGNORED;

    if( bb_is_user_zombie( iAttacker ) ) // Skip zombies
        return HAM_IGNORED;

    fClientDamage[ iAttacker ] += fDamage; // Add damage (AFTER ALREADY CALCULATED BY ENGINE)

    if( fClientDamage[ iAttacker ] >= 250.0 ) // If damage is higher than the value you want
    {
        fClientDamage[ iAttacker ] -= 250.0;

        //set_user_armor( iAttacker, get_user_armor( iAttacker ) + 1 );
        bb_set_user_ammo_packs( iAttacker, bb_get_user_ammo_packs( iAttacker ) + 1 ); // Or whatever the ammo pack system is called
    }

    return HAM_IGNORED;
}

stock IsPlayer( iEnt )
{
    if( iEnt >= 1 && iEnt <= 32 )
        return true;

    return false;
}

Last edited by marcelowzd; 03-27-2018 at 21:42.
marcelowzd is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 03-27-2018 , 18:05   Re: [HELP] attack 250 hp = 1 ap
Reply With Quote #8

Quote:
Originally Posted by marcelowzd View Post
Code:
#include < amxmodx >
#include < hamsandwich >
#include < basebuilder >
#include < fun >

new Float:fClientDamage[ 33 ];

public plugin_init( )
{
    RegisterHam( Ham_TakeDamage, "player", "OnTakeDamage", 1 );
}

public client_putinserver( iClient )
{
    fClientDamage[ iClient ] = 0.0;
}

public OnTakeDamage( iVictim, iInflictor, iAttacker, Float:fDamage, biDamage )
{
    if( !IsPlayer( iAttacker ) || !IsPlayer( iVictim ) ) // Both must be players
        return HAM_IGNORED;

    if( !is_user_alive( iAttacker ) ) // Only alive
        return HAM_IGNORED;

    if( bb_is_user_zombie( iAttacker ) ) // Skip zombies
        return HAM_IGNORED;

    fClientDamage[ iAttacker ] += fDamage; // Add damage (AFTER ALREADY CALCULATED BY ENGINE)

    if( fClientDamage[ iAttacker ] >= 250.0 ) // If damage is higher than the value you want
    {
        fClientDamage[ iAttacker ] = 0.0;

        set_user_armor( iAttacker, get_user_armor( iAttacker ) + 1 );
    }

    return HAM_IGNORED;
}

stock IsPlayer( iEnt )
{
    if( iEnt >= 1 && iEnt <= 32 )
        return true;

    return false;
}
I think you have to use while() instead of if(). And he wants +1 Ammo Packs not Armor.
__________________
edon1337 is offline
Send a message via Skype™ to edon1337
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 03-27-2018 , 18:43   Re: [HELP] attack 250 hp = 1 ap
Reply With Quote #9

Quote:
Originally Posted by edon1337 View Post
I think you have to use while() instead of if(). And he wants +1 Ammo Packs not Armor.
No, each shot that hits someone calls TakeDamage, so if i use a while() what is the point of the variable "fDamage"? It must increase with each hit.

About AP, i thought AP was about Armor? Base builder doesn't have ammo packs by default, so if he wants to increase AmmoPacks instead of Armor, than he needs to provide the needed natives.
__________________

Last edited by marcelowzd; 03-27-2018 at 21:22.
marcelowzd is offline
Old 03-27-2018, 21:18
OciXCrom
This message has been deleted by OciXCrom.
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-27-2018 , 21:26   Re: [HELP] attack 250 hp = 1 ap
Reply With Quote #10

Quote:
Originally Posted by Relaxing View Post
Add me on steam, we can create a group called No clue on what I'm doing on AM.
You should also create one called "I can't read section names and I have no clue what the difference between each section is".

@marcelowzd - the counter you made isn't very accurate. If for example you have 249 damage stored in the variable and you need 1 more to get the reward, and then you deal 100 more damage with a single hit, 99 of the damage won't be counted because the counter resets to 0 when 250 is reached.

Instead of setting the counter to 0, you should set it to (damage_made - (250 - stored_damage)).

Last edited by OciXCrom; 03-27-2018 at 21:32.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply


Thread Tools
Display Modes

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 14:49.


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