AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Whats Wrong I had Done :( (https://forums.alliedmods.net/showthread.php?t=334773)

soumyadip77 10-18-2021 15:05

Whats Wrong I had Done :(
 
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);
        }
    }



Bugsy 10-18-2021 16:28

Re: Whats Wrong I had Done :(
 
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.

soumyadip77 10-19-2021 01:56

Re: Whats Wrong I had Done :(
 
Ohk, Anything wrong in get weapon id as server crash while I am killing some one.

Quote:

Originally Posted by Bugsy (Post 2760946)
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.


Napoleon_be 10-19-2021 02:28

Re: Whats Wrong I had Done :(
 
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.



Natsheh 10-19-2021 03:54

Re: Whats Wrong I had Done :(
 
Quote:

Originally Posted by soumyadip77 (Post 2760979)
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.

CrazY. 10-19-2021 08:46

Re: Whats Wrong I had Done :(
 
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 (Post 1160958)
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 );




Natsheh 10-19-2021 10:27

Re: Whats Wrong I had Done :(
 
You can use get_user_attacker(victim, CSW_WPNID); to catch the weapon.

soumyadip77 10-19-2021 13:20

Re: Whats Wrong I had Done :(
 
ohk. I know this method as I am rearning and exploring Reapi more so trying to with Reapi do take it wrong way please.


All times are GMT -4. The time now is 11:37.

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