Randomizing death messages -
LiamM - 01.04.2011
Here is my code for my death messages, but I was wondering if it was possible to randomize messages, As you can see one line of code says
pawn Код:
format(string, sizeof(string), "{FF6600}*** %s has fucked up %s, with a %s", killer, playername, deathreason);
Is it possible to randomise the message so that it doesnt allways say "has fucked up" and can maybe change to... "has re-arranged the face of %s" ?
Is this possible?
pawn Код:
new string[256];
new deathreason[20];
GetPlayerName(playerid, playername, sizeof(playername));
GetWeaponName(reason, deathreason, 20);
if (killerid == INVALID_PLAYER_ID) {
switch (reason) {
case WEAPON_DROWN:
{
format(string, sizeof(string), "{FF6600}*** %s has drowned.)", playername);
}
default:
{
if (strlen(deathreason) > 0) {
format(string, sizeof(string), "{FF6600}*** %s has died. (%s)", playername, deathreason);
} else {
format(string, sizeof(string), "{FF6600}*** %s has died.", playername);
}
}
}
}
else {
new killer[MAX_PLAYER_NAME];
GetPlayerName(killerid, killer, sizeof(killer));
if (strlen(deathreason) > 0) {
format(string, sizeof(string), "{FF6600}*** %s has fucked up %s, with a %s", killer, playername, deathreason);
} else {
format(string, sizeof(string), "{FF6600}*** %s has fucked up %s.", killer, playername);
}
}
SendClientMessageToAll(COLOR_YELLOW, string);
return 1;
}
Re: Randomizing death messages -
Type-R - 01.04.2011
It is possible, just do something like this:
At the top of the Script
Код:
new Death[][3] =
{
{1},
{2}
};
At the top of your command:
Код:
new Random = random(sizeof(Death));
I would save it to dini or something, because if not then i don't know how to check it without playerid...
So if you wanna save it to dini, so put this below Random:
Код:
dini_IntSet("File destination", "Death", Death[Random][0]);
Then somewhere in your command put this if you did with Dini:
Код:
if(dini_Int("file destination", "Death") == 1)
{
format(string, sizeof(string), "{FF6600}*** %s has fucked up %s.", killer, playername);
}
else if(dini_Int("file destination", "Death") == 2)
{
Write here something else
}
Done
If without dini do something like this:
Код:
if(death[playerid] == 1) // i dont know how to do it without playerid, so you have to figure it out :(
{
format(string, sizeof(string), "{FF6600}*** %s has fucked up %s.", killer, playername);
}
else if(death[playerid] == 2)
{
Write here something else
}
Re: Randomizing death messages -
legodude - 01.04.2011
damn thats one inefficient way to do it.
add as said the array on top of your script OR:
add a switch(random(5)) with 5 cases to the onplayerdeath
and there do a format
Re: Randomizing death messages -
LiamM - 04.04.2011
I tried both of these methods and they did not work.. Any other suggestions from readers??
Re: Randomizing death messages -
LiamM - 07.04.2011
bump
Re: Randomizing death messages -
Vince - 07.04.2011
pawn Код:
new
deathmsgs[][] = {
{"%s has fucked up %s with a %s"},
{"%s has killed %s with a %s"}
};
// OnPlayerDeath
new
rand = random(sizeof(deathmsgs)),
msg[128];
format(msg, sizeof(msg), deathmsgs[rand], killerid, playerid, reason);
Something like that.
Re: Randomizing death messages -
LiamM - 10.04.2011
That worked, sorry for the late reply, forgot. Thanks alot man