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

Get the "killers" client


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Porcellian
Member
Join Date: Oct 2017
Old 09-02-2018 , 05:03   Get the "killers" client
Reply With Quote #1

Hello,

I am new to sourcemod scripting, and I wonder how I can fetch data from the "killer" in a game.
I basically want the killer to die, if he doesn't kill the correct player.

So, bascially something like this (and no it is not real code)

Code:
if(killer Killed badPlayer) {
makeDeath(killer);
} else {
print ("you killed the right player");
}
I don't really know how to do this, I've looked trough several plugins source code to see if I can use anything of that, but I can't find anything relevant. So preferably, if it's easy I could use a finished code for that. Or I just need to know how to get the client of the "killer" so I can use it somehow.

Any ideas?
Porcellian is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 09-02-2018 , 05:14   Re: Get the "killers" client
Reply With Quote #2

What will determine the right player? Steam ID, etc.?
__________________
Psyk0tik is offline
Porcellian
Member
Join Date: Oct 2017
Old 09-02-2018 , 05:17   Re: Get the "killers" client
Reply With Quote #3

To get the client of the one who was killed, we are using this:
Quote:
int client = GetClientOfUserId(event.GetInt("userid"));
Porcellian is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 09-02-2018 , 07:46   Re: Get the "killers" client
Reply With Quote #4

Quote:
Originally Posted by Porcellian View Post
To get the client of the one who was killed, we are using this:
No, I am asking how you would want to determine which victim is the "right player" or "wrong player"... You're asking for a code that detects when a killer kills the wrong player, but how would you determine if the victim is the right or wrong target?



Also, if you want to get the User ID of the killer, you need to hook the player_death event.

PHP Code:
int attacker GetClientOfUserId(event.GetInt("attacker")); 
__________________

Last edited by Psyk0tik; 09-02-2018 at 07:49.
Psyk0tik is offline
Porcellian
Member
Join Date: Oct 2017
Old 09-02-2018 , 08:32   Re: Get the "killers" client
Reply With Quote #5

I tried this, but it doesn't seem to work.

Quote:
if(attacker != badPlayer) {
if(badPlayer != client) {
AcceptEntityInput(iRagdoll, "Kill");
CreateDeathRagdoll(attacker);
KillTrail(attacker);
}
}
Porcellian is offline
Porcellian
Member
Join Date: Oct 2017
Old 09-02-2018 , 08:43   Re: Get the "killers" client
Reply With Quote #6

I had to add this "ForcePlayerSuicide(attacker);"

and now it is working correct, thank you!
Porcellian is offline
Reply


Thread Tools
Display Modes

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 16:01.


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