Raised This Month: $9 Target: $400
 2% 

Whats Wrong I had Done :(


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
soumyadip77
Senior Member
Join Date: Jul 2017
Location: INDIA,KOLKATA
Old 10-18-2021 , 16:05   Whats Wrong I had Done :(
Reply With Quote #1

PHP Code:
public plugin_init()
{
   
register_plugin(PLUGINVERSIONAUTHOR);
   
RegisterHookChain(RG_CBasePlayer_Killed"CBasePlayer_Killed", .post 1)
}

public 
CBasePlayer_Killed(pevVictimpevAttacker)
{
    if(
is_user_connected(pevAttacker) || is_user_connected(pevVictim) || pevAttacker != pevVictim || get_member(pevAttackerm_iTeam) != get_member(pevVictimm_iTeam))
    {
        if(
rg_get_weaponbox_id(pevAttacker) == WEAPON_KNIFE)
        {
            new 
nAttackerMAX_NAME_LENGTH ], nVictimMAX_NAME_LENGTH ];
            
get_user_name(pevAttackernAttackercharsmax(nAttacker));
            
get_user_name(pevVictimnVictimcharsmax(nVictim));

            
client_print_color(00"%s ^3%s ^1Knifed ^3%s ^1LOL ^4Sharam Kar Le ^3:p"PREFIXnAttackernVictim);
        }
    }

__________________
Let's Help Each Other
soumyadip77 is offline
Send a message via Skype™ to soumyadip77
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-18-2021 , 17:28   Re: Whats Wrong I had Done :(
Reply With Quote #2

Your ||'s should be &&'s since if your attacker is connected, no further conditions are being checked. You want all to be true to advance to the next code block.
__________________
Bugsy is offline
soumyadip77
Senior Member
Join Date: Jul 2017
Location: INDIA,KOLKATA
Old 10-19-2021 , 02:56   Re: Whats Wrong I had Done :(
Reply With Quote #3

Ohk, Anything wrong in get weapon id as server crash while I am killing some one.

Quote:
Originally Posted by Bugsy View Post
Your ||'s should be &&'s since if your attacker is connected, no further conditions are being checked. You want all to be true to advance to the next code block.
__________________
Let's Help Each Other
soumyadip77 is offline
Send a message via Skype™ to soumyadip77
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-19-2021 , 03:28   Re: Whats Wrong I had Done :(
Reply With Quote #4

The following might fix ur problem. Check if the attacker is actually a valid player.

PHP Code:
if(iAttacker != 0)
{
    
// Valid id.

or this would be even better:

PHP Code:
if(<= MAX_PLAYERS <= 32)
{
    
// Valid id.

__________________
My Plugins:


Accepting private projects.

Last edited by Napoleon_be; 10-19-2021 at 03:29.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-19-2021 , 04:54   Re: Whats Wrong I had Done :(
Reply With Quote #5

Quote:
Originally Posted by soumyadip77 View Post
Ohk, Anything wrong in get weapon id as server crash while I am killing some one.

Yeah that's because rg_get_weaponbox_id(pevAttacker) is expecting a valid weapon entity index and not a player index.
__________________
@Jailbreak Main Mod v2.6.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-19-2021 , 09:46   Re: Whats Wrong I had Done :(
Reply With Quote #6

Replace rg_get_weaponbox_id(pevAttacker) with get_user_weapon(pevAttacker).

You should probably hook DeathMsg instead, because it may happen that the victim dies to a grenade while the attacker is holding a knife.

Quote:
Originally Posted by Bugsy View Post
I've never scripted or know anything about WC3. Do some testing for yourself to see what happens in the DeathMsg event.

DeathMsg
PHP Code:
register_event"DeathMsg" "DeathMsgEvent" "a" );

public 
DeathMsgEvent()
{
     new 
iKiller read_data);
     new 
iVictim read_data);
     new 
iIsHeadshot read_data);
     new 
szWeapon20 ]; read_dataszWeapon charsmaxszWeapon ) );
     
     
client_printprint_chat "%d %d %d %s" iKiller iVictim iIsHeadshot szWeapon );

__________________




CrazY. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-19-2021 , 11:27   Re: Whats Wrong I had Done :(
Reply With Quote #7

You can use get_user_attacker(victim, CSW_WPNID); to catch the weapon.
__________________
@Jailbreak Main Mod v2.6.6 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
soumyadip77
Senior Member
Join Date: Jul 2017
Location: INDIA,KOLKATA
Old 10-19-2021 , 14:20   Re: Whats Wrong I had Done :(
Reply With Quote #8

ohk. I know this method as I am rearning and exploring Reapi more so trying to with Reapi do take it wrong way please.
__________________
Let's Help Each Other
soumyadip77 is offline
Send a message via Skype™ to soumyadip77
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 20:19.


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