Raised This Month: $ Target: $400
 0% 

[TF2] Getting client on player_death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 12-13-2014 , 16:35   [TF2] Getting client on player_death
Reply With Quote #1

Code:
HookEvent( "player_death", OnPlayerDeathPre, EventHookMode_Pre )
public OnPlayerDeathPre(Handle:event, const String:name[], bool:dontBroadcast)
    new client = GetEventInt(event, "player");
    GetClientOfUserId( client );
Seems to not work
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
arthurdead
Senior Member
Join Date: Jul 2013
Old 12-13-2014 , 17:30   Re: [TF2] Getting client on player_death
Reply With Quote #2

thats not how GetClientOfUserId works

PHP Code:
public OnPluginStart()
{
    
HookEvent("player_death"OnPlayerDeathPreEventHookMode_Pre);
}

public 
OnPlayerDeathPre(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetEventInt(event"player");
    new 
userid GetClientOfUserId(client);
    
//or new client = GetClientOfUserId(GetEventInt(event, "player"));
    //do stuff with userid

arthurdead is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-13-2014 , 18:33   Re: [TF2] Getting client on player_death
Reply With Quote #3

The key for the player killed is "userid" not "player". At least it is in the games I checked. player_death is one of those events that's different depending on which game it is.

Also, you're not actually saving that client index to a variable.

Quote:
Originally Posted by arthurdead View Post
thats not how GetClientOfUserId works

PHP Code:
public OnPluginStart()
{
    
HookEvent("player_death"OnPlayerDeathPreEventHookMode_Pre);
}

public 
OnPlayerDeathPre(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetEventInt(event"player");
    new 
userid GetClientOfUserId(client);
    
//or new client = GetClientOfUserId(GetEventInt(event, "player"));
    //do stuff with userid

I think you have those variable names switched as your client variable contains a userid and your userid variable contains a client index. Or they would if the key name was actually "player" (see above).
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 12-13-2014 at 18:37.
Powerlord is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 12-14-2014 , 09:33   Re: [TF2] Getting client on player_death
Reply With Quote #4

Tried both and it didn't worked the code is

Code:
public OnPlayerDeathPre(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetEventInt(event, "player");
    new userid = GetClientOfUserId(client);
    PrintToChatAll("Event runned");
//        new client = GetClientOfUserId(GetEventInt(event, "player"));
    if( GetClientTeam(userid) == _:TFTeam_Blue && IsValidClient( userid )) // && GameRules_GetRoundState() != RoundState_BetweenRounds ) //&& IsValidClient( client )) && IsValidRobot(client)
    {
        new MoneypackL = CreateEntityByName( "item_currencypack_large" );
        DispatchSpawn(MoneypackL);
        PrintToChatAll("Check succes");
        new Float:position[3];
        GetClientAbsOrigin(userid, position);
        GetEntPropVector(userid, Prop_Send, "m_vecOrigin",position);
        TeleportEntity(MoneypackL, position, NULL_VECTOR, NULL_VECTOR);
    }
}
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 12-14-2014 , 10:26   Re: [TF2] Getting client on player_death
Reply With Quote #5

First of all, you're mixing up client and userid. Please try to read up on some SM basics before you ask these questions.

Now, assuming this is TF2, which it probably is:
Code:
new client=GetClientOfUserId(GetEventInt(event, "userid"));  //Or "attacker" if you want the attacker
__________________
~Wliu
Wliu is offline
arthurdead
Senior Member
Join Date: Jul 2013
Old 12-14-2014 , 10:26   Re: [TF2] Getting client on player_death
Reply With Quote #6

Quote:
Originally Posted by Powerlord View Post
The key for the player killed is "userid" not "player". At least it is in the games I checked. player_death is one of those events that's different depending on which game it is.

Also, you're not actually saving that client index to a variable.



I think you have those variable names switched as your client variable contains a userid and your userid variable contains a client index. Or they would if the key name was actually "player" (see above).
i got confused sorry has been some time since i used sourcemod
arthurdead is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 12-14-2014 , 13:14   Re: [TF2] Getting client on player_death
Reply With Quote #7

Thanks that helped but how i can stop the cash from respawning?
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 12-14-2014 , 14:03   Re: [TF2] Getting client on player_death
Reply With Quote #8

Quote:
Originally Posted by Michalplyoutube View Post
Thanks that helped but how i can stop the cash from respawning?
What? Are you referring to MvM?
thecount 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 10:57.


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