Random word - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Random word (
/showthread.php?tid=294586)
Random word -
BloodGuy - 02.11.2011
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
Respuesta: Random word -
Super_Panda - 02.11.2011
what you mean?
Like a random name of the players that are connected?
Re: Random word -
BloodGuy - 02.11.2011
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
Respuesta: Random word -
Super_Panda - 02.11.2011
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);
Re: Respuesta: Random word -
FireCat - 02.11.2011
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"
};
Re: Random word -
BloodGuy - 02.11.2011
Warning: C:\Users\****\Desktop\Pawno\pawno\****.pwn(1446) : warning 203: symbol is never used: "RandomNames"
Re: Random word -
FireCat - 02.11.2011
Quote:
Originally Posted by BloodGuy
Warning: C:\Users\****\Desktop\Pawno\pawno\****.pwn(1446) : warning 203: symbol is never used: "RandomNames"
|
pawn Код:
#pragma unused RandomNames
Respuesta: Random word -
Super_Panda - 02.11.2011
Add
pawn Код:
new rand = random(sizeof(RandomNames));
in the command
Re: Respuesta: Random word -
BloodGuy - 02.11.2011
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;
}