AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   make_deathmsg usage (https://forums.alliedmods.net/showthread.php?t=134588)

GXLZPGX 08-06-2010 18:27

make_deathmsg usage
 
Alright so I'm using make_deathmsg but there is an argument.
Since the fourth param has to be const, can I do this:

PHP Code:

public eDeathiVictimiAttacker )
{
     new 
iWeapon[33];
     
     if( 
cs_get_user_team(iVictim) == CS_TEAM_T )
     {
          
iWeapon[iAttacker] = get_user_weaponiAttacker )
          
make_deathmsgiAttackeriVictim0iWeapon )
          return 
PLUGIN_HANDLED;
     }



RedRobster 08-06-2010 18:39

Re: make_deathmsg usage
 
No, get_user_weapon( id ) returns the weapon id of the currently carried weapon. You must do this:
PHP Code:

new iWeapon[32]
new 
wepid get_user_weaponid )
get_weaponnamewepidiWeapon31 

Even then, I think that will return something like "weapon_" so, do actually get the weapon name that is normally used, you are going to have to make a constant or something with the names the same as the weapon id. Which are these:
Code:

/* Id of weapons in CS */
#define CSW_P228        1
#define CSW_SCOUT        3
#define CSW_HEGRENADE        4
#define CSW_XM1014        5
#define CSW_C4            6
#define CSW_MAC10        7
#define CSW_AUG            8
#define CSW_SMOKEGRENADE    9
#define CSW_ELITE        10
#define CSW_FIVESEVEN        11
#define CSW_UMP45        12
#define CSW_SG550        13
#define CSW_GALI        14
#define CSW_GALIL        14
#define CSW_FAMAS        15
#define CSW_USP            16
#define CSW_GLOCK18        17
#define CSW_AWP            18
#define CSW_MP5NAVY        19
#define CSW_M249        20
#define CSW_M3            21
#define CSW_M4A1        22
#define CSW_TMP            23
#define CSW_G3SG1        24
#define CSW_FLASHBANG        25
#define CSW_DEAGLE        26
#define CSW_SG552        27
#define CSW_AK47        28
#define CSW_KNIFE        29
#define CSW_P90            30


GXLZPGX 08-06-2010 18:45

Re: make_deathmsg usage
 
Quote:

Originally Posted by RedRobster (Post 1263685)
No, get_user_weapon( id ) returns the weapon id of the currently carried weapon. You must do this:
PHP Code:

new iWeapon[32]
new 
wepid get_user_weaponid )
get_weaponnamewepidiWeapon31 

Even then, I think that will return something like "weapon_" so, do actually get the weapon name that is normally used, you are going to have to make a constant or something with the names the same as the weapon id. Which are these:
Code:

/* Id of weapons in CS */
#define CSW_P228        1
#define CSW_SCOUT        3
#define CSW_HEGRENADE        4
#define CSW_XM1014        5
#define CSW_C4            6
#define CSW_MAC10        7
#define CSW_AUG            8
#define CSW_SMOKEGRENADE    9
#define CSW_ELITE        10
#define CSW_FIVESEVEN        11
#define CSW_UMP45        12
#define CSW_SG550        13
#define CSW_GALI        14
#define CSW_GALIL        14
#define CSW_FAMAS        15
#define CSW_USP            16
#define CSW_GLOCK18        17
#define CSW_AWP            18
#define CSW_MP5NAVY        19
#define CSW_M249        20
#define CSW_M3            21
#define CSW_M4A1        22
#define CSW_TMP            23
#define CSW_G3SG1        24
#define CSW_FLASHBANG        25
#define CSW_DEAGLE        26
#define CSW_SG552        27
#define CSW_AK47        28
#define CSW_KNIFE        29
#define CSW_P90            30


Well can you possibly post a fix for this that I could use? :D <3

wrecked_ 08-06-2010 18:45

Re: make_deathmsg usage
 
Code:
new name[20] get_weaponname( cs_get_weapon_id( get_user_weapon( id ) ), name, 19 ) make_deathmsg( iAttacker, iVictim, 0, name )

DarkGod 08-06-2010 18:49

Re: make_deathmsg usage
 
Quote:

Originally Posted by wrecked_ (Post 1263690)
Code:
new name[20] get_weaponname( cs_get_weapon_id( get_user_weapon( id ) ), name, 19 ) make_deathmsg( iAttacker, iVictim, 0, name )

Does it automatically truncate it? As deathmsg uses truncated weapon name.
Or isn't it required at all?

Also... don't you need the actual entity index for cs_get_weapon_id? It should be fine with just get_user_weapon(iAttacker), as far as I know.

wrecked_ 08-06-2010 18:55

Re: make_deathmsg usage
 
The get_weaponname() function requires the CSW_* id.

Code:
new name[20] get_weaponname( get_user_weapon( id ), name, 19 ) format( name, 19, "%s", name[7] ) make_deathmsg( iAttacker, iVictim, 0, name )
Give that a shot.

DarkGod 08-06-2010 18:57

Re: make_deathmsg usage
 
Quote:

Originally Posted by wrecked_ (Post 1263699)
The get_weaponname() function requires the CSW_* id.

get_user_weapon() returns the CSW_* index.

wrecked_ 08-06-2010 19:34

Re: make_deathmsg usage
 
Quote:

Originally Posted by DarkGod (Post 1263705)
get_user_weapon() returns the CSW_* index.

Fixed.

RedRobster 08-06-2010 20:24

Re: make_deathmsg usage
 
I was just under the assumption that get_weaponname( ) would return the "weapon_name". But, I'm not sure.

As for the const thing I was talking about earlier, I would just do something like this:

PHP Code:

new const gszWeaponNames[][] =
{
    
"p228",
    
"",
    
"scout",
    
"grenade",
    
"xm1014",
    
"C4",
    
"mac10",
    
"aug",
    
"",
    
"dual elites",
    
"fiveseven",
    
"ump45"
    "sg550"
,
    
"galil",
    
"famas",
    
"usp",
    
"glock",
    
"awp",
    
"mp5",
    
"m249",
    
"m3",
    
"m4a1",
    
"tmp",
    
"g3sg1",
    
"",
    
"deagle",
    
"sg552",
    
"ak-47",
    
"knife",
    
"p90"


^If wrecked's version doesn't work. Then, do use a weapon, just do gszWeaponNames[wepid].

Bugsy 08-06-2010 21:25

Re: make_deathmsg usage
 
Quote:

Originally Posted by wrecked_ (Post 1263699)
The get_weaponname() function requires the CSW_* id.

Code:
new name[20] get_weaponname( get_user_weapon( id ), name, 19 ) format( name, 19, "%s", name[7] ) make_deathmsg( iAttacker, iVictim, 0, name )
Give that a shot.

format() is not needed, wrecked.

"weapon_ak47"
"ak47" can be accessed with name[ 7 ].
PHP Code:

new name[20]
get_weaponnameget_user_weaponiAttacker ) , name charsmaxname ) )
make_deathmsgiAttacker iVictim name] ) 

GXLZPGX, where is this being called? If you are using DeathMsg then you cannot pass victim and attacker as params like that; you must use read_data.
PHP Code:

public plugin_init()
{
    
register_event"DeathMsg" "EvDeathMsg" "a" "1>0" );    
}

public 
EvDeathMsg()
{
    new 
iKiller read_data);
    new 
iVictim read_data);

    static 
name[20]
    
get_weaponnameget_user_weaponiKiller ) , name charsmaxname ) )
    
make_deathmsgiKiller iVictim name] )




All times are GMT -4. The time now is 00:06.

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