Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Mötley on Mar 18, 2016, 09:16 PM

Title: onPlayerKill is not working
Post by: Mötley on Mar 18, 2016, 09:16 PM
even tried the wiki version \/

function onPlayerKill( killer, player, reason, bodypart )
{
    Message( "** " + killer.Name + " killed " + player.Name + " (" + GetWeaponName( reason ) + ") (" + bodypart + ")" );   
}

any explanation to why or what could be interfering with this?

i even added print. Nothing ???
Title: Re: onPlayerKill is not working
Post by: aXXo on Mar 18, 2016, 09:30 PM
I'm guessing that when you tested it, the killer and player were in the same team.
That would have resulted in calling onPlayerTeamKill and skipped onPlayerKill
Title: Re: onPlayerKill is not working
Post by: Mötley on Mar 18, 2016, 09:57 PM
I did not think of this as i don't have teams, When I get off of work i will retest! problem more than likely solved! Thanks
Title: Re: onPlayerKill is not working
Post by: rww on Mar 18, 2016, 10:10 PM
This isn't LU! You can use only ClientMessage and ClientMessageToAll for send message on chat ;)

function onPlayerKill( killer, player, reason, bodypart )
{
ClientMessageToAll( "** " + killer.Name + " killed " + player.Name + " (" + GetWeaponName( reason ) + ") (" + bodypart + ")",255,128,0,255);   
}
Title: Re: onPlayerKill is not working
Post by: Mötley on Mar 19, 2016, 12:01 AM
I had noticed this in the wiki. but MessagePlayer does exist and this Message is in the wiki. I will convert some time, Thanks for the tip! ;)
Title: Re: onPlayerKill is not working
Post by: rww on Mar 19, 2016, 12:30 AM
My mistake.. You can use MessagePlayer/Message on VC-MP, but i never use this functions, and I think that doesn't exist.
Title: Re: onPlayerKill is not working
Post by: KAKAN on Mar 19, 2016, 02:42 AM
Message and other shits work well here.
Motley, try this:
function onPlayerTeamKill( k, p, r, b ) onPlayerKill( k, p, r, b );
function onPlayerKill( k, p, r, b ){
Message("Something happened");
}
Title: Re: onPlayerKill is not working
Post by: Mötley on Mar 19, 2016, 04:03 AM
Quote from: KAKAN on Mar 19, 2016, 02:42 AMMessage and other shits work well here.
Motley, try this:
function onPlayerTeamKill( k, p, r, b ) onPlayerKill( k, p, r, b );
function onPlayerKill( k, p, r, b ){
Message("Something happened");
}

LOL something happened !
I never thought of sharing functions together " You taught me something.

I would of done
|

k, p, r, bwhat does this stand for?

killer, player, r, b,???
Title: Re: onPlayerKill is not working
Post by: MaTaDeToR on Mar 19, 2016, 04:07 AM
Quote from: Mr_Motley on Mar 19, 2016, 04:03 AM
Quote from: KAKAN on Mar 19, 2016, 02:42 AMMessage and other shits work well here.
Motley, try this:
function onPlayerTeamKill( k, p, r, b ) onPlayerKill( k, p, r, b );
function onPlayerKill( k, p, r, b ){
Message("Something happened");
}

LOL something happened !
I never thought of sharing functions together " You taught me something.

I would of done
|

k, p, r, bwhat does this stand for?

killer, player, r, b,???

Well, you could name these events anything you know,
function onPlayerKill( killer, player, reason, bodypart )
{
ClientMessageToAll("" + player + " Has been killed by " + killer + "",255,255,0);
}
like function onPlayerKill( THE_KILLER, VICTIM, OV_Reason, WHICH_PART_IT_SHOOT )
{
ClientMessageToAll("" + VICTIM + " Has been killed by " + THE_KILLER + "",255,255,0);
}
will work the same ;)
AND
function onPlayerKill( killer, player, reason, bodypart )
{
 ClientMessageToAll( "** " + killer.Name + " killed " + player.Name + " (" + GetWeaponName( reason ) + ") (" + bodypart + ")"[code],255,128,0,255
);   
}
change this line to
ClientMessageToAll( "** " + killer.Name + " killed " + player.Name + " (" + GetWeaponName( reason ) + ") (" + bodypart + ")",255,128,255); Since in RGB Colors, only three colors are used not FOUR! 255,128,0,255 @rwwpl wpl ;)
Title: Re: onPlayerKill is not working
Post by: Xmair on Mar 19, 2016, 04:18 AM
*cough cough*
You're wrong Mr.@KAKAN , It's RGBA. You can provide 4 parameters.
Title: Re: onPlayerKill is not working
Post by: MaTaDeToR on Mar 19, 2016, 04:21 AM
Quote from: Xmair on Mar 19, 2016, 04:18 AM*cough cough*
You're wrong Mr.@KAKAN , It's RGBA. You can provide 4 parameters.
Okay, never thougt of that. :)
Title: Re: onPlayerKill is not working
Post by: Mötley on Mar 19, 2016, 04:32 AM
So what do I need to do to have only One kill function? I want to have a Independent server. looks like its going to take a lot of stress testing on the kill system as Teams are set default unfortunately instead of adding scripted support for teams?

any suggestions would be helpful. ^^^^ everything in this post has helped me a lot!!! Thanks Everyone

@KAKAN THANKS FOR THE CODE! I modified it

"I just wish there was a distance function in the wiki so i can write longest headshots to stats!

Honestly! "I am too much of a noob to know how to script that " ???

somethings I just don't know and majority of the time when i see a code like distance I think "why didn't I think of that!
Title: Re: onPlayerKill is not working
Post by: KAKAN on Mar 19, 2016, 08:12 AM
Quote from: Xmair on Mar 19, 2016, 04:18 AM*cough cough*
You're wrong Mr.@KAKAN , It's RGBA. You can provide 4 parameters.
Well, what are you talking about? I don't need alpha in the WastedScreen function. So, why shall I use it? Don't worry, you won't be able to see the wasted screen since the fain and fadeout time is 0 ms :P

Quote from: MaTaDeToR on Mar 19, 2016, 04:07 AMWell, you could name these events anything you know,

Sorry, was at phone at that time.

Quote from: Mr_Motley on Mar 19, 2016, 04:03 AMk, p, r, bwhat does this stand for?

killer, player, r, b,???

Reason, bodypart :P Well, you can see the onPlayerKill's params, it's exactly same as of onPlayerTeamKill.
Title: Re: onPlayerKill is not working
Post by: Decent_946 on Mar 19, 2016, 08:39 AM
Quote from: Mr_Motley on Mar 19, 2016, 04:32 AM"I just wish there was a distance function in the wiki so i can write longest headshots to stats!
there you go. ( donno who made it )
function Distance(x1, y1, x2, y2)
{
local dist = sqrt(((x2 - x1)*(x2 - x1)) + ((y2 - y1)*(y2 - y1)));
return dist;
}

just an example of using the function.
function onPlayerKill( killer, player, bodypart, reason )
{
PrivMessage( player, "killed by "+killer.Name+" Distance: "+Distance( killer.Pos.x, killer.Pos.y, player.Pos.x, player.Pos.y )+"." );
}
Title: Re: onPlayerKill is not working
Post by: Xmair on Mar 19, 2016, 09:23 AM
*again coughs*
DistanceFromPoint ( x1, y1, x2, y2 )
Title: Re: onPlayerKill is not working
Post by: Decent_946 on Mar 19, 2016, 09:24 AM
Quote from: Xmair on Mar 19, 2016, 09:23 AM*again coughs*
DistanceFromPoint ( x1, y1, x2, y2 )
error: z missing.
Title: Re: onPlayerKill is not working
Post by: MacTavish on Mar 19, 2016, 09:30 AM
Quote from: Decent_946 on Mar 19, 2016, 09:24 AM
Quote from: Xmair on Mar 19, 2016, 09:23 AM*again coughs*
DistanceFromPoint ( x1, y1, x2, y2 )
error: x3 missing.

DistanceFromPoint(killer.Pos.x, killer.Pos.y, player.Pos.x,player.Pos.y);
Title: Re: onPlayerKill is not working
Post by: KAKAN on Mar 19, 2016, 09:31 AM
Quote from: Decent_946 on Mar 19, 2016, 09:24 AM
Quote from: Xmair on Mar 19, 2016, 09:23 AM*again coughs*
DistanceFromPoint ( x1, y1, x2, y2 )
error: x3 missing.
What's the use of x3 there?
I would say, z1, z2 are missing. Why would someone need the Z here?
Title: Re: onPlayerKill is not working
Post by: Xmair on Mar 19, 2016, 09:35 AM
@Decent_946 , ever viewed the wiki? (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/DistanceFromPoint)
Title: Re: onPlayerKill is not working
Post by: Decent_946 on Mar 19, 2016, 09:40 AM
Quote from: Xmair on Mar 19, 2016, 09:35 AM@Decent_946 , ever viewed the wiki? (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/DistanceFromPoint)
ofc, btw, atm i am too depressed cuz of my test. so that's why..
i 1st wanted to post that function but thought to give z axis also. ;) .
Title: Re: onPlayerKill is not working
Post by: Stormeus on Mar 19, 2016, 02:20 PM
Quote from: Kusanagi on Mar 19, 2016, 09:30 AM
Quote from: Decent_946 on Mar 19, 2016, 09:24 AM
Quote from: Xmair on Mar 19, 2016, 09:23 AM*again coughs*
DistanceFromPoint ( x1, y1, x2, y2 )
error: x3 missing.

DistanceFromPoint(killer.Pos.x, killer.Pos.y, player.Pos.x,player.Pos.y);

killer.Pos.Distance(player.Pos)
Title: Re: onPlayerKill is not working
Post by: Mötley on Mar 19, 2016, 04:12 PM
you guys are amazing!!! I noticed something I dont like, and that is bodypart names say head, right leg, left leg., right arm, left arm, and Dick, I guess i should create locals...?
Title: Re: onPlayerKill is not working
Post by: Murdock on Mar 19, 2016, 04:36 PM
Quote from: Mr_Motley on Mar 19, 2016, 04:12 PMyou guys are amazing!!! I noticed something I dont like, and that is bodypart names say head, right leg, left leg., right arm, left arm, and Dick, I guess i should create locals...?

I assume your server does not have female skins then
Title: Re: onPlayerKill is not working
Post by: Mötley on Mar 19, 2016, 04:49 PM
Quote from: Murdock on Mar 19, 2016, 04:36 PM
Quote from: Mr_Motley on Mar 19, 2016, 04:12 PMyou guys are amazing!!! I noticed something I dont like, and that is bodypart names say head, right leg, left leg., right arm, left arm, and Dick, I guess i should create locals...?

I assume your server does not have female skins then
lel never would of thought of that ;D


is it possible to turn the body part ids, From ids to words?
Title: Re: onPlayerKill is not working
Post by: DizzasTeR on Mar 19, 2016, 04:54 PM
Referring to this post for the second time :D

http://forum.vc-mp.org/?topic=254.0
Title: Re: onPlayerKill is not working
Post by: Mötley on Mar 19, 2016, 05:19 PM
??? I Am confused as I am looking for body part names? I really do not understand that post

LOL fixed

if ( limb == 1 ) limb = "Dick";

Message( killer + " sent to hospital " + player + " (" + wep + ") (" + limb + ") (" + distance + "m)" );
Speacial thanks to PunkNoodle
Title: Re: onPlayerKill is not working
Post by: MacTavish on Mar 19, 2016, 05:28 PM
this post may help you http://forum.vc-mp.org/?topic=400.msg2563#msg2563 you can edit returning instance as you want them like left shoulder instead left arm
Title: Re: onPlayerKill is not working
Post by: Mötley on Mar 19, 2016, 05:40 PM
Yes I like that method better than

function onPlayerTeamKill( killer, player, reason, bodypart) onPlayerKill( killer, player, reason, bodypart)
function onPlayerKill( killer, player, reason, bodypart)
{
local pos = killer.Pos;
local rot = killer.Angle, rad = rot * PI / 180.0;
local x = pos.x, y = pos.y, z = pos.z;
local x2 = x + 0.01 * cos(rad) - 5.0 * sin(rad);
local y2 = y + 0.01 * sin(rad) + 5.0 * cos(rad);
local wep = GetWeaponName( reason ), limb = ( bodypart ), distance = DistanceFromPoint(killer.Pos.x, killer.Pos.y, player.Pos.x,player.Pos.y);
if ( limb == 0 ) limb = "Torso";
if ( limb == 1 ) limb = "Dick";
if ( limb == 6 ) limb = "Head";
if ( limb == 3 ) limb = "Right-Arm";
if ( limb == 4 ) limb = "Left-Leg";
if ( limb == 5 ) limb = "Right-Leg";
if ( limb == 2 ) limb = "Left-Arm";


Message( killer + " sent to hospital " + player + " (" + wep + ") (" + limb + ") (" + distance + "m)" );

return 1;
}
I will convert
Title: Re: onPlayerKill is not working
Post by: MaTaDeToR on Mar 20, 2016, 03:42 AM
Quote from: Mr_Motley on Mar 19, 2016, 05:40 PMYes I like that method better than

function onPlayerTeamKill( killer, player, reason, bodypart) onPlayerKill( killer, player, reason, bodypart)
function onPlayerKill( killer, player, reason, bodypart)
{
local pos = killer.Pos;
local rot = killer.Angle, rad = rot * PI / 180.0;
local x = pos.x, y = pos.y, z = pos.z;
local x2 = x + 0.01 * cos(rad) - 5.0 * sin(rad);
local y2 = y + 0.01 * sin(rad) + 5.0 * cos(rad);
local wep = GetWeaponName( reason ), limb = ( bodypart ), distance = DistanceFromPoint(killer.Pos.x, killer.Pos.y, player.Pos.x,player.Pos.y);
if ( limb == 0 ) limb = "Torso";
if ( limb == 1 ) limb = "Dick";
if ( limb == 6 ) limb = "Head";
if ( limb == 3 ) limb = "Right-Arm";
if ( limb == 4 ) limb = "Left-Leg";
if ( limb == 5 ) limb = "Right-Leg";
if ( limb == 2 ) limb = "Left-Arm";


Message( killer + " sent to hospital " + player + " (" + wep + ") (" + limb + ") (" + distance + "m)" );

return 1;
}
I will convert
However, this could be a great use of Switch.
Title: Re: onPlayerKill is not working
Post by: rww on Apr 05, 2016, 07:12 AM
Sorry for bump...

@MaTaDeToR

In ClientMessage/ClientMessageToAll function you can use RGB or RGBA ;) Before you can use only RGBA (year ago).
Title: Re: onPlayerKill is not working
Post by: MaTaDeToR on Apr 07, 2016, 06:01 AM
Quote from: rwwpl on Apr 05, 2016, 07:12 AMSorry for bump...

@MaTaDeToR

In ClientMessage/ClientMessageToAll function you can use RGB or RGBA ;) Before you can use only RGBA (year ago).
;) alright i didn't noticed that! thanks.