AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Damage and Money (https://forums.alliedmods.net/showthread.php?t=106855)

OneMoreLevel 10-19-2009 17:40

Damage and Money
 
Is there a way I can make people get money each time they DMG someone? I want to be able to make it so that people get 2 dollars each HP they kill. Like if they hit 30 DMG against someone, they would get 60 dollars

EDIT: Is there a way to hook round start with hamsandwich too?

alan_el_more 10-19-2009 17:55

Re: Damage and Money
 
Try this
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN "Money DMG"
#define VERSION "1.0"
#define AUTHOR "alan_el_more"

#define DAMAGE 2
#define MONEY 300

new g_maxplayers
new g_damage_done[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_maxplayers get_maxplayers()
    
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    if((
<= attacker <= g_maxplayers) && attacker != victim)
    {
        
g_damage_done[attacker] += floatround(damage)
        
        while(
g_damage_done[attacker] >= DAMAGE)
        {
            
cs_set_user_money(attackercs_get_user_money(attacker) + MONEY)
            
g_damage_done[attacker] -= DAMAGE
        
}
    }



OneMoreLevel 10-19-2009 17:59

Re: Damage and Money
 
Thanks Ill test it out, so far it compiles, Ill try to test it on my server real quick.

Exolent[jNr] 10-19-2009 18:04

Re: Damage and Money
 
Code:
#include < amxmodx > #include < amxmisc > #include < cstrike > #include < engine > #include < hamsandwich > const Float:MONEY_PER_HP = 2.0; // $2 / 1HP new g_iMaxPlayers; public plugin_init( ) {     register_plugin( "Damage for Money", "0.0.1", "Exolent" );         RegisterHam( Ham_TakeDamage, "player", "FwdPlayerDamage", 1 );         g_iMaxPlayers = get_maxplayers( ); } public FwdPlayerDamage( iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits ) {     if( !( 1 <= iAttacker <= g_iMaxPlayers ) ) {         return;     }         new Float:fRealDamage = entity_get_float( iVictim, EV_FL_dmg_take );     if( cs_get_user_team( iVictim ) == cs_get_user_team( iAttacker ) ) {         fRealDamage *= -1.0;     }         cs_set_user_money( iAttacker, cs_get_user_money( iAttacker ) + floatround( MONEY_PER_HP * fRealDamage ) ); }

OneMoreLevel 10-19-2009 19:07

Re: Damage and Money
 
Thanks guys :D

I hope you dont mind me asking another quick thing.

How can I play a sound so that everyone in the server can hear it, not just the surrounding area or the client.


All times are GMT -4. The time now is 17:43.

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