PDA

View Full Version : Random player death message


Nathan_Taylor
15/03/2013, 06:29 PM
//RANDOM DEATH MESSAGES
new RandomDeath[][] =
{
"was killed by",
"was fragged by",
"was ended by",
"was pulverized by"

};

new RandomSuicide[][] =
{
"committed suicide",
"took thier own life",
"messed up"
};


For the sake of putting my code on here, i changed all those messages from what they really are oin my server xD. Anyway, this is in OnPlayerDeath()

public OnPlayerDeath(playerid, killerid, reason)
{

//OTHER CODE......

if(!killerid){

GetPlayerName(playerid, kname, MAX_PLAYER_NAME);
GetPlayerName(killerid, dname, MAX_PLAYER_NAME);
format(allmessage, sizeof(allmessage), "{00FF00}%s{FFFFFF} %s {00FF00}%s.", kname, RandomDeath[random(sizeof(RandomDeath))], dname);
SendClientMessageToAll(-1, allmessage);

} else {
GetPlayerName(playerid, dname, MAX_PLAYER_NAME);
format(allmessage, sizeof(allmessage), "{00FF00}%s{FFFFFF} %s", dname, RandomSuicide[random(sizeof(RandomSuicide))]);
SendClientMessageToAll(-1, allmessage);
}

//OTHER CODE....

}


When a user dies, it just displays a random message from either one, for instance, if I commit suicide, sometimes it will say "USERNAME got killed by" and if I get killed by someone else, sometimes the message will be something like "USERNAME committed suicide"

Anyone see why?

Jstylezzz
15/03/2013, 06:36 PM
What happens if you change

if(!killerid)

to

if(killerid != playerid)

??

Vince
15/03/2013, 06:38 PM
Actually it should be
if(killerid != INVALID_PLAYER_ID)

Nathan_Taylor
15/03/2013, 06:41 PM
What happens if you change

if(!killerid)

to

if(killerid != playerid)

??

Actually it should be
if(killerid != INVALID_PLAYER_ID)


thanks to both of you :)