AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Get the "killers" client (https://forums.alliedmods.net/showthread.php?t=310396)

Porcellian 09-02-2018 05:03

Get the "killers" client
 
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?

Psyk0tik 09-02-2018 05:14

Re: Get the "killers" client
 
What will determine the right player? Steam ID, etc.?

Porcellian 09-02-2018 05:17

Re: Get the "killers" client
 
To get the client of the one who was killed, we are using this:
Quote:

int client = GetClientOfUserId(event.GetInt("userid"));

Psyk0tik 09-02-2018 07:46

Re: Get the "killers" client
 
Quote:

Originally Posted by Porcellian (Post 2613285)
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")); 


Porcellian 09-02-2018 08:32

Re: Get the "killers" client
 
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 09-02-2018 08:43

Re: Get the "killers" client
 
I had to add this "ForcePlayerSuicide(attacker);"

and now it is working correct, thank you!


All times are GMT -4. The time now is 20:49.

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