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

[Help needed]Exclusive damage rate


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RaZ_HU
Senior Member
Join Date: May 2015
Location: Hungary
Old 11-01-2015 , 17:33   [Help needed]Exclusive damage rate
Reply With Quote #1

Hi, I am trying to make a VIP/ADMINS exclusive plugin for our fun server and it does work but meanwhile it generates errorlogs about get_user_weapon() function.

Can someone take a look at the code about what's wrong?

Code:
#include <amxmodx> #include <amxmisc> #include <hamsandwich> #define ACCESS ADMIN_CFG #define VERSION "0.2" new damageMultiplier new Float:dmgRate new clip, ammo public plugin_init() {     register_plugin("VIP Sebzes Bonusz", VERSION, "RaZ")     damageMultiplier = register_cvar("vipbonus_dmgrate", "1.3")     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage") } public fw_TakeDamage(victim, inflictor, attacker, Float:damage) {     dmgRate = get_pcvar_float(damageMultiplier)     new iWeapon = get_user_weapon(attacker, clip, ammo)     new playerCount = get_maxplayers()         if(attacker > playerCount)         return PLUGIN_CONTINUE     if(attacker < 1)         return PLUGIN_CONTINUE     if(!attacker)         return PLUGIN_CONTINUE         if (is_user_connected(attacker) && is_user_alive(attacker) && get_user_flags(attacker) & ACCESS)     {         new iWeaponUsed = get_user_weapon(inflictor)         if(iWeapon == CSW_KNIFE || iWeapon == CSW_AWP || iWeapon == CSW_SCOUT || iWeaponUsed == CSW_HEGRENADE)             return PLUGIN_CONTINUE                 SetHamParamFloat(4, damage * dmgRate)     }         return HAM_HANDLED }

Detailed error log:
Quote:
L 11/01/2015 - 19:25:15: Start of error session.
L 11/01/2015 - 19:25:15: Info (map "cs_iraq") (file "addons/amxmodx/logs/error_20151101.log")
L 11/01/2015 - 19:25:15: Invalid player id 154
L 11/01/2015 - 19:25:15: [AMXX] Displaying debug trace (plugin "vipdmgbonus.amxx", version "0.2")
L 11/01/2015 - 19:25:15: [AMXX] Run time error 10: native error (native "get_user_weapon")
L 11/01/2015 - 19:25:15: [AMXX] [0] vipdmgbonus.sma::fw_TakeDamage (line 23)
L 11/01/2015 - 19:25:15: Invalid player id 155
L 11/01/2015 - 19:25:15: [AMXX] Displaying debug trace (plugin "vipdmgbonus.amxx", version "0.2")
L 11/01/2015 - 19:25:15: [AMXX] Run time error 10: native error (native "get_user_weapon")
L 11/01/2015 - 19:25:15: [AMXX] [0] vipdmgbonus.sma::fw_TakeDamage (line 23)
L 11/01/2015 - 19:25:15: Invalid player id 156
L 11/01/2015 - 19:25:15: [AMXX] Displaying debug trace (plugin "vipdmgbonus.amxx", version "0.2")
L 11/01/2015 - 19:25:15: [AMXX] Run time error 10: native error (native "get_user_weapon")
L 11/01/2015 - 19:25:15: [AMXX] [0] vipdmgbonus.sma::fw_TakeDamage (line 23)
L 11/01/2015 - 19:25:15: Invalid player id 329
L 11/01/2015 - 19:25:15: [AMXX] Displaying debug trace (plugin "vipdmgbonus.amxx", version "0.2")
L 11/01/2015 - 19:25:15: [AMXX] Run time error 10: native error (native "get_user_weapon")
L 11/01/2015 - 19:25:15: [AMXX] [0] vipdmgbonus.sma::fw_TakeDamage (line 23)
L 11/01/2015 - 19:25:28: Invalid player id -1
L 11/01/2015 - 19:25:28: [AMXX] Displaying debug trace (plugin "vipdmgbonus.amxx", version "0.2")
L 11/01/2015 - 19:25:28: [AMXX] Run time error 10: native error (native "get_user_weapon")
L 11/01/2015 - 19:25:28: [AMXX] [0] vipdmgbonus.sma::fw_TakeDamage (line 23)
RaZ_HU is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-01-2015 , 17:54   Re: [Help needed]Exclusive damage rate
Reply With Quote #2

You should use attacker here, not inflictor. Inflictor is not always the same as attacker, in the case of grenade damage, and possibly C4, it is the entity index of the grenade. I also fixed and improved other things that were done incorrectly.
Code:
if (is_user_connected(attacker) && is_user_alive(attacker) && get_user_flags(attacker) & ACCESS) {
    new iWeaponUsed = get_user_weapon(inflictor)
    if(iWeapon == CSW_KNIFE || iWeapon == CSW_AWP || iWeapon == CSW_SCOUT || iWeaponUsed == CSW_HEGRENADE)         return PLUGIN_CONTINUE             SetHamParamFloat(4, damage * dmgRate) }
Untested
PHP Code:

#include <amxmodx>
#include <hamsandwich>

#define VERSION "0.2"

#define MAX_PLAYERS 32
#define ACCESS ADMIN_CFG

new const DMG_GRENADE = ( << 24 );
new const 
IGNORE_WEAPONS = ( << CSW_KNIFE ) | ( << CSW_AWP ) | ( << CSW_SCOUT );

new 
pCVar_DamageRate;

public 
plugin_init()
{
    
register_plugin"VIP Sebzes Bonusz" VERSION "RaZ" );
    
    
pCVar_DamageRate register_cvar"vipbonus_dmgrate" "1.3" );

    
RegisterHamHam_TakeDamage "player" "fw_TakeDamage" ); 
}

public 
fw_TakeDamageiVictim iInflictor iAttacker Float:fDamage DamageBits )
{
    if( !( 
<= iAttacker <= MAX_PLAYERS ) || 
        ( 
DamageBits DMG_GRENADE ) ||
        !( 
get_user_flagsiAttacker ) & ACCESS ) ||
        ( ( 
<< get_user_weaponiAttacker ) ) & IGNORE_WEAPONS ) )
        return 
HAM_IGNORED;
        
    
SetHamParamFloatfDamage get_pcvar_floatpCVar_DamageRate ) )
    
    return 
HAM_HANDLED;

__________________

Last edited by Bugsy; 11-01-2015 at 18:30.
Bugsy is offline
RaZ_HU
Senior Member
Join Date: May 2015
Location: Hungary
Old 11-02-2015 , 14:41   Re: [Help needed]Exclusive damage rate
Reply With Quote #3

Tested and works perfectly without any errors, thank you sir for the help
RaZ_HU is offline
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 04:09.


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