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

Solved M4A1 Silencer-Unsilencer Damage Plugin Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZombieTheMan01
Senior Member
Join Date: Aug 2015
Location: Turkey
Old 01-24-2017 , 03:42   M4A1 Silencer-Unsilencer Damage Plugin Problem
Reply With Quote #1

Hello guys. Previously I had such a problem. But no one answered.
I'm having the same problem again. I do not have a problem with only one set of damage, but I am constantly having trouble adding and adjusting with the 'silencer' ("cs_get_weapon_silen" or "cs_set_weapon_silen").
(OLD SCREENSHOT BUT SAME PROBLEM):

Codes:
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

/*#define sil 1.17
#define unsil 1.28
*/
new silunsil

new g_hamczbotscvar_botquota

public plugin_init() 
{
    
register_plugin("M4A1 Damage Controller Test""0.1""YunusReyiz")
    
RegisterHam(Ham_TakeDamage"player""fw_takedamage")
    
sil register_cvar("m4a1_silencer_damage""1.16")
    
unsil register_cvar("m4a1_damage""1.25")
    
    
cvar_botquota get_cvar_pointer("bot_quota")

}

public 
register_ham_czbots(Player)
{
    if (
g_hamczbots || !is_user_connected(Player) || !get_pcvar_num(cvar_botquota)) return
    
    
RegisterHamFromEntity(Ham_TakeDamagePlayer"fw_takedamage")
    
    
g_hamczbots true
    
}

public 
client_putinserver(Player)
{
    if(
is_user_bot(Player) && !g_hamczbots && cvar_botquotaset_task(0.1"register_ham_czbots"Player)
}

public 
fw_takedamage(victiminflictorattackerFloat:damage)
{
    if (
victim != attacker && is_user_connected(attacker))
    {
        if(
get_user_weapon(attacker) == CSW_M4A1)
        {
                
/*if(!cs_get_weapon_silen(attacker))SetHamParamFloat(4, damage * unsil)
                if(cs_get_weapon_silen(attacker))SetHamParamFloat(4, damage * sil)*/
                
if(!cs_set_weapon_silen(attacker))SetHamParamFloat(4damage get_pcvar_float(unsil))
                if(
cs_set_weapon_silen(attacker))SetHamParamFloat(4damage get_pcvar_float(sil))
                
        }
    }

Thanks in advance.
NOTE: I had to share it because I could not get a response before. Otherwise I do not share the same thing easily.
__________________
FREE PLUGINS:

2021 and before -> ALL PLUGIN LINK IS HERE <-

2022:
Zombie: The Original [%70 Completed]

Last edited by ZombieTheMan01; 06-16-2017 at 15:19.
ZombieTheMan01 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-24-2017 , 03:48   Re: M4A1 Silencer-Unsilencer Damage Plugin Problem
Reply With Quote #2

Obviously the person that made the code has no ideea how cs_set_weapon_silen works. Look here: http://amxmodx.org/api/cstrike/cs_set_weapon_silen

Pay attention to the error message, it clearly says it expects a NON PLAYER ENTITY but you provide a player index(attacker).
__________________

Last edited by HamletEagle; 01-24-2017 at 03:49.
HamletEagle is offline
ZombieTheMan01
Senior Member
Join Date: Aug 2015
Location: Turkey
Old 01-24-2017 , 04:25   Re: M4A1 Silencer-Unsilencer Damage Plugin Problem
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
Obviously the person that made the code has no ideea how cs_set_weapon_silen works. Look here: http://amxmodx.org/api/cstrike/cs_set_weapon_silen

Pay attention to the error message, it clearly says it expects a NON PLAYER ENTITY but you provide a player index(attacker).
Hmm. Now, how are we going to do this?
__________________
FREE PLUGINS:

2021 and before -> ALL PLUGIN LINK IS HERE <-

2022:
Zombie: The Original [%70 Completed]
ZombieTheMan01 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-24-2017 , 04:29   Re: M4A1 Silencer-Unsilencer Damage Plugin Problem
Reply With Quote #4

Get the weapon entity index and use that instead of the player index.
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-24-2017 , 08:19   Re: M4A1 Silencer-Unsilencer Damage Plugin Problem
Reply With Quote #5

Before cs_set_weapon_silen put this
PHP Code:
new ent find_ent_by_owner(-1"weapon_m4a1"attacker
Use ent as the index like cs_get_weapon_silen(ent) , btw you should use cs_get_weapon_silent not set.
__________________

Last edited by edon1337; 01-24-2017 at 08:19.
edon1337 is offline
ZombieTheMan01
Senior Member
Join Date: Aug 2015
Location: Turkey
Old 01-25-2017 , 05:18   Re: M4A1 Silencer-Unsilencer Damage Plugin Problem
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
Get the weapon entity index and use that instead of the player index.
OK. I wrote a code similar to the one given by EDON1337. But when I forgot to add "weapon_m4a1", I corrected it.

Quote:
Originally Posted by edon1337 View Post
Before cs_set_weapon_silen put this
PHP Code:
new ent find_ent_by_owner(-1"weapon_m4a1"attacker
Use ent as the index like cs_get_weapon_silen(ent) , btw you should use cs_get_weapon_silent not set.
Thanks. Before you write, I also wrote to similar. But when I forgot to add "weapon_m4a1", I fixed the error.
__________________
FREE PLUGINS:

2021 and before -> ALL PLUGIN LINK IS HERE <-

2022:
Zombie: The Original [%70 Completed]
ZombieTheMan01 is offline
Reply



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 10:21.


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