Death Messages (like SA:MP)

Started by ysc3839, Oct 18, 2014, 04:34 AM

Previous topic - Next topic

ysc3839

Screenshot:


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

Will death messages remove ever ? Can't see that.

ysc3839

Quote from: sseebbyy on Oct 19, 2014, 10:11 AMWill death messages remove ever ? Can't see that.
It won't remove.

MacTavish

shows me Error TextInfo doesnt exists idk what is the problem

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

Retired VC:MP Player/Scripter :P

Thijn

Quote from: RATHORE on Nov 20, 2014, 07:16 AMshows me Error TextInfo doesnt exists idk what is the problem
Show the full error report.

Sebastian

If you are going to use this script, do not forget to add a script that will remove the too old death messsages. ;)

MacTavish


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

Retired VC:MP Player/Scripter :P

Thijn

Did you forgot to add this piece of code?
function onServerStart()
{
 TextInfo <- array( MaxLines );
}

MacTavish

I have added but still showing this error

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

Retired VC:MP Player/Scripter :P

ysc3839

Quote from: RATHORE on Nov 21, 2014, 10:28 AMI have added but still showing this error
It isn't any wrong for me... :(

MacTavish


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

Retired VC:MP Player/Scripter :P


DizzasTeR

First of all a f*ing bump of 2014 topic, and secondly, if you look into that image you see:

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.

.

If you can't read. Why DAFUQ are you trying to script? :-\

.

abbasi

TextInfo[MaxLines-1] = CreateTextdraw(Text, PosX, PosY+(MaxLines-1)*LineGap, 0xFFB0B0B0);
this is line 78 tell me what is error??