• Getting Weapon's damage?
    6 replies, posted
I'm looking for a function call that will return the value of the weapon's damage that the current player is holding through [b][url=http://wiki.garrysmod.com/?title=Player.GetActiveWeapon]Player.GetActiveWeapon [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] but am unable to find one. Similar to SWEP.Primary.Damage, but I want it to work for non-sweps as well.
Mostly the damage is dynamic, you gotta hook into some damage hook and read the damage from the damage data.
[lua] Player:GetActiveWeapon().Primary.Damage [/lua] It's the only way I think.
[QUOTE=Loures;27283342][lua] Player:GetActiveWeapon().Primary.Damage [/lua] It's the only way I think.[/QUOTE] i think that only works for sweps. [gamemodes\gmodrpg\gamemode\shared.lua:131] attempt to index field 'Primary' (a nil value) oh and what about those console commands..you know the sk_plr_dmg_* commands, do they work in multiplayer? because unless garry hardcoded the dmg values at some point, they should work.
Try: [lua]Player:GetActiveWeapon().Primary().Damage()[/lua] Not 100% sure, but worth a try.
[QUOTE=wakeboarderCWB;27333286]Try: [lua]Player:GetActiveWeapon().Primary().Damage()[/lua] Not 100% sure, but worth a try.[/QUOTE] I can guarantee that will error. [editline]10th January 2011[/editline] [QUOTE=InstantDeath;27333163]i think that only works for sweps. [gamemodes\gmodrpg\gamemode\shared.lua:131] attempt to index field 'Primary' (a nil value) E[/QUOTE] Yes, it only works for SWEPs.
but what about the sk_plr_dmg_* commands? are they actually used for base dmg values? edit: it does not appear to be so, ar2 did 11 dmg per hit, and shogun did 8, while the value for ar2 was set to 8 and shotgun was set to 4. looks like i will have to pre-get the values before hand by testing each weapon [code] weapon_crowbar did 25 damage to npc_combine_s ! weapon_pistol did 12 damage to npc_combine_s ! weapon_357 did 75 damage to npc_combine_s ! weapon_smg1 did 12 damage to npc_combine_s ! weapon_ar2 did 11 damage to npc_combine_s ! weapon_shotgun did 4 damage to npc_combine_s ! weapon_shotgun did 4 damage to npc_combine_s ! weapon_shotgun did 4 damage to npc_combine_s ! weapon_shotgun did 4 damage to npc_combine_s ! weapon_shotgun did 4 damage to npc_combine_s ! weapon_shotgun did 4 damage to npc_combine_s ! crossbow_bolt did 100 damage to npc_combine_s ! npc_grenade_frag did 150 damage to npc_combine_s ! rpg_missile did 150 damage to npc_combine_s ! [/code]
Sorry, you need to Log In to post a reply to this thread.