Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: ysc3839 on Oct 18, 2014, 04:34 AM

Title: Death Messages (like SA:MP)
Post by: ysc3839 on Oct 18, 2014, 04:34 AM
Screenshot:
(http://i58.tinypic.com/2r6mr6s.jpg)

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.
Title: Re: Death Messages (like SA:MP)
Post by: Sebastian on Oct 19, 2014, 10:11 AM
Will death messages remove ever ? Can't see that.
Title: Re: Death Messages (like SA:MP)
Post by: ysc3839 on Oct 24, 2014, 11:20 AM
Quote from: sseebbyy on Oct 19, 2014, 10:11 AMWill death messages remove ever ? Can't see that.
It won't remove.
Title: Re: Death Messages (like SA:MP)
Post by: MacTavish on Nov 20, 2014, 07:16 AM
shows me Error TextInfo doesnt exists idk what is the problem
Title: Re: Death Messages (like SA:MP)
Post by: Thijn on Nov 20, 2014, 11:19 AM
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.
Title: Re: Death Messages (like SA:MP)
Post by: Sebastian on Nov 20, 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. ;)
Title: Re: Death Messages (like SA:MP)
Post by: MacTavish on Nov 20, 2014, 06:03 PM
It gives me this error
(http://tiny-img.com/image.php?di=0OTU)
Title: Re: Death Messages (like SA:MP)
Post by: Thijn on Nov 20, 2014, 06:29 PM
Did you forgot to add this piece of code?
function onServerStart()
{
 TextInfo <- array( MaxLines );
}
Title: Re: Death Messages (like SA:MP)
Post by: MacTavish on Nov 21, 2014, 10:28 AM
I have added but still showing this error
Title: Re: Death Messages (like SA:MP)
Post by: ysc3839 on Nov 21, 2014, 03:05 PM
Quote from: RATHORE on Nov 21, 2014, 10:28 AMI have added but still showing this error
It isn't any wrong for me... :(
Title: Re: Death Messages (like SA:MP)
Post by: MacTavish on Nov 21, 2014, 07:27 PM
Problem solved :)
Title: Re: Death Messages (like SA:MP)
Post by: abbasi on Jun 28, 2015, 12:51 PM
I am getting error
http://s24.postimg.org/5u3dzgf85/Capture.png
Title: Re: Death Messages (like SA:MP)
Post by: DizzasTeR on Jun 28, 2015, 01:39 PM
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.
Title: Re: Death Messages (like SA:MP)
Post by: . on Jun 28, 2015, 01:39 PM
If you can't read. Why DAFUQ are you trying to script? :-\

(http://s1.postimg.org/70js6emv3/Capture.png)
Title: Re: Death Messages (like SA:MP)
Post by: abbasi on Jun 28, 2015, 05:55 PM
TextInfo[MaxLines-1] = CreateTextdraw(Text, PosX, PosY+(MaxLines-1)*LineGap, 0xFFB0B0B0);
this is line 78 tell me what is error??
Title: Re: Death Messages (like SA:MP)
Post by: Honey on Jun 28, 2015, 10:49 PM
How are we supposed to know an error which occurs on your computer? Learn some debugging skills do some experiments and come up with your findings and we'll be glad to help from our side.
Title: Re: Death Messages (like SA:MP)
Post by: Thijn on Jun 29, 2015, 05:39 AM
Quote from: abbasi on Jun 28, 2015, 05:55 PM TextInfo[MaxLines-1] = CreateTextdraw(Text, PosX, PosY+(MaxLines-1)*LineGap, 0xFFB0B0B0);
this is line 78 tell me what is error??
As you can see from the Locals dump, Text is NULL. There's your error, now go find the solution yourself.
Title: Re: Death Messages (like SA:MP)
Post by: abbasi on Jun 29, 2015, 10:36 AM
:/