AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved [HELP] attack 250 hp = 1 ap (https://forums.alliedmods.net/showthread.php?t=306174)

spooky HL15 03-19-2018 15:10

[HELP] attack 250 hp = 1 ap
 
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

instinctpt1 03-20-2018 03:58

Re: [HELP] attack 250 hp = 1 ap
 
Where is definition of bb_get_ap1 ?

spooky HL15 03-20-2018 16:18

Re: [HELP] attack 250 hp = 1 ap
 
Quote:

Originally Posted by instinctpt1 (Post 2583763)
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 ....

Relaxing 03-20-2018 17:04

Re: [HELP] attack 250 hp = 1 ap
 
Store damage somewhere and check if the "somewhere" has reached >= , in order to do stuff.

spooky HL15 03-20-2018 17:15

Re: [HELP] attack 250 hp = 1 ap
 
Quote:

Originally Posted by Relaxing (Post 2583897)
Store damage somewhere and check if the "somewhere" has reached >= , in order to do stuff.

i do not understande you :V

Relaxing 03-20-2018 19:00

Re: [HELP] attack 250 hp = 1 ap
 
Add me on steam, we can create a group called No clue on what I'm doing on AM.

marcelowzd 03-27-2018 10:31

Re: [HELP] attack 250 hp = 1 ap
 
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;
}


edon1337 03-27-2018 17:05

Re: [HELP] attack 250 hp = 1 ap
 
Quote:

Originally Posted by marcelowzd (Post 2584902)
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.

marcelowzd 03-27-2018 17:43

Re: [HELP] attack 250 hp = 1 ap
 
Quote:

Originally Posted by edon1337 (Post 2584944)
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.

OciXCrom 03-27-2018 20:26

Re: [HELP] attack 250 hp = 1 ap
 
Quote:

Originally Posted by Relaxing (Post 2583913)
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)).


All times are GMT -4. The time now is 00:50.

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