AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Death Pre (https://forums.alliedmods.net/showthread.php?t=135159)

GXLZPGX 08-13-2010 08:02

Death Pre
 
Alright, it creates the death message when a CT gets killed like its supposed to. But when a T gets killed, it wont show a death message. For example:

When a CT gets killed:

http://i34.tinypic.com/5jw6ya.jpg

But when the T dies, it doesn't display a message at all.

Here is the code I used to block/create a new death message:

PHP Code:

stock create_deathmsg(idvictimheadshotweapon_name[])
{
    
message_begin(MSG_ALL,get_user_msgid("DeathMsg"),{0,0,0},0);
    
write_byte(id);
    
write_byte(victim);
    
write_byte(headshot);
    
write_string(weapon_name);
    
message_end();


PHP Code:

RegisterHamHam_Killed"player""eDeathPre"

PHP Code:

public eDeathPreiVictimiAttackershouldgib )
{
    if( 
cs_get_user_team(iVictim) == CS_TEAM_CT && cs_get_user_team(iAttacker) == CS_TEAM_T )
    {
        new 
frags get_user_frags(iAttacker)
        
set_user_fragsiAttackerfrags )
        
        
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET);
        
create_deathmsg(0iVictim1"nothing");
        
        if( 
gInLR[iVictim] == true )
        {
            
gInLR[iVictim] = false;
            
gLastRequest false;
            
            return 
HAM_HANDLED;
        }
        
        return 
HAM_HANDLED;
    }
    
    return 
HAM_HANDLED;



drekes 08-13-2010 08:20

Re: Death Pre
 
Try this code by ConnorMcleod:
PHP Code:

/*    Formatright © 2009, ConnorMcLeod 

    Jail Hide Ts Kills is free software; 
    you can redistribute it and/or modify it under the terms of the 
    GNU General Public License as published by the Free Software Foundation. 

    This program is distributed in the hope that it will be useful, 
    but WITHOUT ANY WARRANTY; without even the implied warranty of 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    GNU General Public License for more details. 

    You should have received a copy of the GNU General Public License 
    along with Jail Hide Ts Kills; if not, write to the 
    Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
    Boston, MA 02111-1307, USA. 
*/ 

#include <amxmodx> 
#include <cstrike> 

#define VERSION "0.0.2" 

#define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers ) 

new g_iMaxPlayers 

public plugin_init() 

    
register_plugin("Jail Hide Ts Kills"VERSION"ConnorMcLeod"

    
register_message(get_user_msgid("DeathMsg"), "Message_DeathMsg"

    
g_iMaxPlayers get_maxplayers() 


public 
Message_DeathMsg() 

    new 
iKiller get_msg_arg_int(1
    if( 
IsPlayer(iKiller) && cs_get_user_team(iKiller) == CS_TEAM_T 
    { 
        
set_msg_arg_int(1ARG_BYTEget_msg_arg_int(2)) 
    } 



Kreation 08-13-2010 19:39

Re: Death Pre
 
Also, the code you have will keep the attacker in Last Request if he is in it.

ConnorMcLeod 08-13-2010 21:45

Re: Death Pre
 
Last version has more features.

PHP Code:

/*    Formatright © 2009, ConnorMcLeod

    Hide T Frags is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Hide T Frags; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <cstrike>

new const VERSION[] = "0.1.0"

const MAX_PLAYERS 32

enum 
/*_:DeathMsg_Structure*/
{    
    
DeathMsg_KillerID 1// byte
    
DeathMsg_VictimID// byte
    
DeathMsg_IsHeadshot// byte
    
DeathMsg_TruncatedWeaponName // string
}

new 
g_iMaxPlayers
#define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers )

new g_pCvarHideType
new g_iDeathMsg

public plugin_init()
{
    
register_plugin("Hide T Frags"VERSION"ConnorMcLeod")

    
g_pCvarHideType register_cvar("jb_hide_te_frags""1"// 0:inactive, 1:hide killer, 2:hide frag

    
g_iDeathMsg get_user_msgid("DeathMsg")
    
register_message(g_iDeathMsg"Message_DeathMsg")

    
g_iMaxPlayers get_maxplayers()
}

public 
Message_DeathMsg()
{
    new 
KillerID get_msg_arg_intDeathMsg_KillerID )
    if( 
IsPlayerKillerID ) && cs_get_user_teamKillerID ) == CS_TEAM_T )
    {
        switch( 
get_pcvar_numg_pCvarHideType ) )
        {
            case 
1:
            {
                
set_msg_arg_int(DeathMsg_KillerIDARG_BYTEget_msg_arg_intDeathMsg_VictimID ))
            }
            case 
2:
            {
                return 
PLUGIN_HANDLED
            
}
            case 
3:
            {
                new 
iPlayers[MAX_PLAYERS], iNumidszTruncatedWeaponName[16]
                
get_players(iPlayersiNum"h")
                
get_msg_arg_string(DeathMsg_TruncatedWeaponNameszTruncatedWeaponNamecharsmax(szTruncatedWeaponName))
                for(new 
ii<iNumi++)
                {
                    
id iPlayers[i]
                    if( 
cs_get_user_team(id) == CS_TEAM_T )
                    {
                        
emessage_begin(MSG_ONEg_iDeathMsg, .player=id)
                        {
                            
ewrite_byte(KillerID)
                            
ewrite_byteget_msg_arg_intDeathMsg_VictimID ) )
                            
ewrite_byteget_msg_arg_intDeathMsg_IsHeadshot ) )
                            
ewrite_string(szTruncatedWeaponName)
                        }
                        
emessage_end()
                    }
                }
                return 
PLUGIN_HANDLED
            
}
        }
    }
    return 
PLUGIN_CONTINUE




All times are GMT -4. The time now is 22:03.

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