Usage of Random
#1

Hello. I was wondering what the Usage of "Random" is, because I want it to send random message's to the players, as like a tool-tip?
Reply
#2

i didnt understand what you need exactly, if you want what's the parameters of the function random is random(maximum number);
Reply
#3

https://sampwiki.blast.hk/wiki/Random

Random just randomizes between 0 and whatever number you input minus one (read post below).

The example on that wiki shows you how you could do random messages. If you don't understand how to make random messages from that wiki, read this one:

https://sampwiki.blast.hk/wiki/Random_Messages
Reply
#4

Quote:
Originally Posted by coole210
Посмотреть сообщение
Random just randomizes between 0 and whatever number you input.
Wrong. If you put 1 it will only ever return 0, ONE value. If you put TWO it has the possibility to return TWO values - 0/1.
Reply
#5

Quote:
Originally Posted by MP2
Посмотреть сообщение
Wrong. If you put 1 it will only ever return 0, ONE value. If you put TWO it has the possibility to return TWO values - 0/1.
I know, I was simplifying it. I'll edit the post.
Reply
#6

pawn Код:
forward RandomMessage();

new RandomMessages[8][156] =
{
    "message1",
    "message2",
    "message3",
    "message4",
    "message5",
    "message6",
    "message7",
    "message8"
};


public OnGameModeInit()
{
    SetTimer("RandomMessage",60000,1); //every minute the message is sent
        return 1;
}


public RandomMessage()
{
    SendClientMessageToAll(COLOR, RandomMessages);
    return 1;
}
Reply
#7

You need to learn to do arrays if you want random messages.
pawn Код:
new
    szRandMessages[][] = {
    {"Message one"},    // 0
    {"Message two"},    // 1
    {"Message three"}// 2
    {"Message four"},   // 3
    {"Message five"},   // 4
    {"Message six"}};   // 5

public OnGameModeInit()
{
    SetTimer("RandomMessages", 30000, 1);
    return 1;
}

forward RandomMessages();
public RandomMessages()
{
    SendClientMessageToAll(-1, szRandMessages[random(sizeof(szRandMessages))]);
    print("30 secs");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)