Death Messages (like SA:MP)

ysc3839

  • VC:MP Beta Tester
  • Posts: 622
Death Messages (like SA:MP)
« on October 18th, 2014, 05:34 AM »
Screenshot:


Code: [Select]
MaxLines <- 8;
LineGap <- 15;
PosX <- -400;
PosY <- 380;
function onServerStart()
{
TextInfo <- array( MaxLines );
}
function onPlayerDeath(player, reason)
{
local Text="";
if (reason==70)
{
Text="*> "+player.Name+" committed suicide. <*";
}
else if (reason==39)
{
Text="*> "+player.Name+" died in a car crash. <*";
}
else if (reason==31)
{
Text="*> "+player.Name+" burned to death. <*";
}
else if (reason==14)
{
Text="*> "+player.Name+" choked to death. <*";
}
else if (reason==43)
{
Text="*> "+player.Name+" drowned. <*";
}
else if (reason==41 || reason==51)
{
Text="*> "+player.Name+" exploded. <*";
}
else if (reason==44)
{
Text="*> "+player.Name+" fell to death. <*";
}
else
{
Text="*> "+player.Name+" died for some reason. <*";
}
RightMessage(Text);
}
function onPlayerKill(player, killer, reason, bodypart)
{
RightMessage(DeathText(player, killer, reason, bodypart));
}
function onPlayerTeamKill(player, killer, reason, bodypart)
{
RightMessage(DeathText(player, killer, reason, bodypart));
}
function DeathText(player, killer, reason, bodypart)
{
local Text="";
if (reason == 14 || reason == 31 || reason == 39 || reason == 40 || reason == 41 || reason == 44 || reason == 51)
{
Text="*> "+killer.Name+" killed "+player.Name+" with "+GetWeaponName(reason)+". <*";
}
else
{
Text="*> "+killer.Name+" killed "+player.Name+" with "+GetWeaponName(reason)+" "+BodyPartText(bodypart)+". <*";
}
}
function RightMessage(Text)
{
if (TextInfo[0])
{
TextInfo[0].Delete();
}
for (local i=0; i<MaxLines-1; i++)
{
if (TextInfo[i+1])
{
TextInfo[i] = TextInfo[i+1];
TextInfo[i].SetPosForAll(PosX, PosY+(i)*LineGap);
}
}
TextInfo[MaxLines-1] = CreateTextdraw(Text, PosX, PosY+(MaxLines-1)*LineGap, 0xFFB0B0B0);
TextInfo[MaxLines-1].ShowForAll();
}
function BodyPartText(bodypart)
{
switch( bodypart )
{
case 0:return "to body";
case 1:return "to torso";
case 2:return "to left arm";
case 3:return "to right arm";
case 4:return "to left leg";
case 5:return "to right leg";
case 6:return "to head";
case 7:return "hitting his car";
default:return "unknown";
}
}

Set DeathMessages to false in server.conf.
And you can use "RightMessage" function to show any text you want.

Sebastian

  • VC:MP Beta Tester
  • Something like this: hga hga hga
  • Posts: 1,141

ysc3839

  • VC:MP Beta Tester
  • Posts: 622

MacTavish

  • Hero Member
  • Nicks( Kusanagi, Beztone, RATHORE )
  • Posts: 811

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Thijn

  • VC:MP Beta Tester
  • Posts: 1,688

Sebastian

  • VC:MP Beta Tester
  • Something like this: hga hga hga
  • Posts: 1,141
Re: Death Messages (like SA:MP)
« Reply #5, on November 20th, 2014, 12:37 PM »
If you are going to use this script, do not forget to add a script that will remove the too old death messsages. ;)

MacTavish

  • Hero Member
  • Nicks( Kusanagi, Beztone, RATHORE )
  • Posts: 811

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Thijn

  • VC:MP Beta Tester
  • Posts: 1,688
Re: Death Messages (like SA:MP)
« Reply #7, on November 20th, 2014, 06:29 PM »
Did you forgot to add this piece of code?
Code: [Select]
function onServerStart()
{
 TextInfo <- array( MaxLines );
}

MacTavish

  • Hero Member
  • Nicks( Kusanagi, Beztone, RATHORE )
  • Posts: 811

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

ysc3839

  • VC:MP Beta Tester
  • Posts: 622

MacTavish

  • Hero Member
  • Nicks( Kusanagi, Beztone, RATHORE )
  • Posts: 811

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

abbasi

  • Newbie
  • Posts: 46

DizzasTeR

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,190
Re: Death Messages (like SA:MP)
« Reply #12, on June 28th, 2015, 02:39 PM »
First of all a f*ing bump of 2014 topic, and secondly, if you look into that image you see:

Code: [Select]
Player 'imran' ID 0 connected

on console so what does that mean? Let me tell you, you are imran and you just wanted to screw up the forum once again by bumping a topic and posting a error which was generated by you not by the snippet.

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,808
.

abbasi

  • Newbie
  • Posts: 46
Re: Death Messages (like SA:MP)
« Reply #14, on June 28th, 2015, 06:55 PM »
Code: [Select]
TextInfo[MaxLines-1] = CreateTextdraw(Text, PosX, PosY+(MaxLines-1)*LineGap, 0xFFB0B0B0);
this is line 78 tell me what is error??