Author Topic: Getrandom  (Read 1940 times)

Ok so I know you can get a random number between 2 numbers by doing this

announce(getrandom(1,50));
That will give me a random number between 1 and 50.

What I'm looking for is a way were I can but text in front of the number so I can make it say
"The random number selected was (number)"

Is there any way I can change the command about to get this to work?

announce("The random number selected was (" @ getRandom(1,50) @ ")");

announce("The random number selected was (" @ getRandom(1,50) @ ")");
Cool I'll give it a shot, thanks.

Could even make it a slash command, only using console.

Code: [Select]
function servercmdrnd(%a,%b) { announce("The random number selected was (" @ getRandom(1,50) @ ")"); }
Now just type /rnd

Makes it a lot easier.

a better syntax would be announce("The random number selected was SPC getRandom(1,50) @ ".");

a better syntax would be announce("The random number selected was SPC getRandom(1,50) @ ".");
oops nvm

You mean
a better syntax would be announce("The random number selected was" SPC getRandom(1,50) @ ".");

Except there was nothing wrong with the syntax

Code: [Select]
function serverCmdRoll(%client)
{
    if(%client.isAdmin) //To reduce abuse of the addon leading to mass chat spam
    {
        messageAll('',"\c6The dice has been rolled by:\c2" @ %client.name "\c6, it landed on:\c2" SPC getRandom(1,50) @ "\c6!");
    }
    else
    {
        messageClient(%client,'',"\c6To reduce chat spam your dice roll request has been denied.");
    }
}
That would work
« Last Edit: December 12, 2011, 04:29:52 PM by FFSO »



Wow, when was this?
It's been a default function since.. probably since BL was created.

Announce() is like a normal message except that it's in big, yellow text.

messageClient:
This is a normal message.
Announce:
This is an announcement.

I see.....well thanks for telling me.


Code: [Select]
function serverCmdRoll(%client)
{
    if(%client.isAdmin) //To reduce abuse of the addon leading to mass chat spam
    {
        messageAll('',"\c6The dice has been rolled by:\c2" @ %client.name "\c6, it landed on:\c2" SPC getRandom(1,50) @ "\c6!");
    }
    else
    {
        messageClient(%client,'',"\c6To reduce chat spam your dice roll request has been denied.");
    }
}
That would work

Now try to put that in the console.