Random word
#1

Hi,

I need a random word that can be placed in a sendclientmessage.
Like the words: His dog, his mom and the cat.


Код:
format(string, sizeof(string), "[KILL] "white"%s "green"Is killed by "white"[HERE SHOULD COME THE RANDOM NAME]. "red"Cash reward: %d", pname, killername, Random);
How to do that
Reply
#2

what you mean?

Like a random name of the players that are connected?
Reply
#3

I mean; I have some names; If someone gets killed it needs to say; killed by his cat, by his dog, etc etc
But not all at the same time, and not the same name everytime. So everytime a other name
Reply
#4

Use something like this:


pawn Код:
new RandomNames[][4] =
{
    {CAT},
    {DOG},
    {COW}
};

//onplayercommandtext
    new rand = random(sizeof(RandomNames));

format(string, sizeof(string), "[KILL] "white"%s "green"Is killed by "white"%s"red"Cash reward: %d", pname, killername, rand);
Reply
#5

Quote:
Originally Posted by Super_Panda
Посмотреть сообщение
Use something like this:


pawn Код:
new RandomNames[][4] =
{
    {CAT},
    {DOG},
    {COW}
};

//onplayercommandtext
    new rand = random(sizeof(RandomNames));

format(string, sizeof(string), "[KILL] "white"%s "green"Is killed by "white"%s"red"Cash reward: %d", pname, killername, rand);
*
pawn Код:
new RandomNames[][4] =
{
    "Cat",
    "DOG",
    "COW"
};
Reply
#6

Warning: C:\Users\****\Desktop\Pawno\pawno\****.pwn(1446) : warning 203: symbol is never used: "RandomNames"
Reply
#7

Quote:
Originally Posted by BloodGuy
Посмотреть сообщение
Warning: C:\Users\****\Desktop\Pawno\pawno\****.pwn(1446) : warning 203: symbol is never used: "RandomNames"
pawn Код:
#pragma unused RandomNames
Reply
#8

Add

pawn Код:
new rand = random(sizeof(RandomNames));
in the command
Reply
#9

Quote:
Originally Posted by Super_Panda
Посмотреть сообщение
Add

pawn Код:
new rand = random(sizeof(RandomNames));
in the command
I have that.
I have now:

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	new rand = random(sizeof(RandomNames));
	new Random = random(15000);
   	killtimer1 = SetTimerEx("killtimer2",35000,0,"d",playerid);
   	new pname[24];
   	new string[130];
   	GivePlayerMoney(playerid,Random);
   	GetPlayerName(playerid, pname, sizeof(pname));
   	format(string, sizeof(string), "[KILL] "white"%s "green"Is killed by "white"%s. "red"Cash reward: %d", pname, rand, Random);
   	SendClientMessageToAll(COLOR_RED, string);
   	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)