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

[CSGO] How get weapon index of the victim after its death?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 07-29-2015 , 08:49   [CSGO] How get weapon index of the victim after its death?
Reply With Quote #1

Code:
public OnPluginStart( ) {     HookEvent("player_death", OnPlayerDeath); } some Action func {         ...     Weapons[client][0] = GivePlayerItem( client, "weapon_ak47" );     Weapons[client][1] = GivePlayerItem( client, "weapon_p250" );         ...     } public Action OnPlayerDeath(Handle event, char[] name, bool dontBroadcast) {         Handle event = CreateEvent( "player_death" );     if ( event == INVALID_HANDLE ) {         return;     }         int id = GetClientOfUserId( GetEventInt( event, "userid" ) );         for(int y; y < 2; y++) {         if( IsValidEntity( Weapons[id][y]  ) ) {             AcceptEntityInput( Weapons[id][y], "Kill" );         }     } }

It not works and crash the server

Last edited by ZASTRELIS; 07-29-2015 at 08:51.
ZASTRELIS is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 07-29-2015 , 08:52   Re: [CSGO] How get weapon index of the victim after its death?
Reply With Quote #2

use SDKHook_WeaponDrop
8guawong is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 07-29-2015 , 09:23   Re: [CSGO] How get weapon index of the victim after its death?
Reply With Quote #3

Code:
public OnClientPutInServer(client) {     // if(GetUserFlagBits(client) & ADMFLAG_ROOT)     SDKHook( client, SDKHook_WeaponDrop, Hook_WeaponDrop ); } public OnClientDisconnect(client) {     // if(GetUserFlagBits(client) & ADMFLAG_ROOT)     SDKUnhook(client, SDKHook_WeaponDrop, Hook_WeaponDrop); }

Code:
// test.sp(24) : error 130: cannot coerce functions to values
// test.sp(30) : error 130: cannot coerce functions to values
ZASTRELIS is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 07-29-2015 , 10:29   Re: [CSGO] How get weapon index of the victim after its death?
Reply With Quote #4

post full code lol or no1 is going to be able to help you
8guawong is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 07-29-2015 , 10:32   Re: [CSGO] How get weapon index of the victim after its death?
Reply With Quote #5

it was my mistake..
ZASTRELIS is offline
Marcus_Brown001
AlliedModders Donor
Join Date: Nov 2012
Location: Illinois, United States
Old 07-29-2015 , 19:56   Re: [CSGO] How get weapon index of the victim after its death?
Reply With Quote #6

Why are you trying to create the same event you already hooked, in that event's callback? O.o

Try something like this:
PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_death"Player_DeathEventHookMode_Pre);
}

stock void SomeFunction(iClient)
{
    
g_iSomeArray[iClient][0] = GivePlayerItem(iClient"weapon_ak47");
    
g_iSomeArray[iClient][1] = GivePlayerItem(iClient"p250");
    
    if (
g_iSomeArray[iClient][0] == -|| g_iSomeArray[iClient][1] == -1)
        
LogError("Attempted to give an invalid item.");
}

public 
Action Player_Death(Handle hEventchar[] sNamebool bBroadcast)
{
    
int iClient GetClientOfUserId(GetEventInt(hEvent"userid" ));
    
    if (!
IsClientInGame(iClient) || g_iSomeArray[iClient][0] == -|| g_iSomeArray[iClient][1] == -1)
        return 
Plugin_Continue;
        
    for (
int i2i++)
    {
        if (
IsValidEntity(g_iSomeArray[iClient][i])
            
AcceptEntityInput(g_iSomeArray[iClient][i], "kill");
    }
    
    return 
Plugin_Continue;


Last edited by Marcus_Brown001; 07-29-2015 at 20:52.
Marcus_Brown001 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-30-2015 , 03:13   Re: [CSGO] How get weapon index of the victim after its death?
Reply With Quote #7

OnTakeDamage_Alive

Check for 0 health and the victims active weapon.
__________________
Neuro Toxin 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 09:45.


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