Random problem :(
#1

Hi.. recently i have created a liiiitlle script and dont work
Код:
    if (strcmp("/random", cmdtext, true, 6) == 0)
    {
	            if(IsPlayerConnected(playerid))
	            {
	            new rand = random(3)+1;
	            GetPlayerName(playerid, sendername, sizeof(sendername));
			    new random[MAX_PLAYERS];
   			    if(rand == 3)
	            {
				random = "happy";
				random = "very happy";
				random = "lucky";
				}
				else
				{
				random = "sad";
				}
			    format(string, sizeof(string), "A player is  %s", random);
			    ProxDetector(10.0, playerid, string, COLOR_PINK,COLOR_PINK,COLOR_PINK,COLOR_PINK,COLOR_PINK);
		        }
     return 1;
     }
The problem is..
When i type /random the script show me only: A player is LUCKY
or
A player is sad
(
how can i solve this problem?
Reply
#2

what do you actual want
Reply
#3

i want , when you type /random, the script select one of
Код:
happy, lucky, very happy or sad
Reply
#4

change this code to yours



Код:
new gla;
gla=random(10); // Type here the number of messages you have.
switch(gla)
{
case 0: SendClientMessage(playerid, 0xFFFFFFFF, "This is the first message");
case 1: SendClientMessage(playerid, 0xFFFFFFFF, "This is the sencond message");
case 2: SendClientMessage(playerid, 0xFFFFFFFF, "This is the third message");
//....
}
Reply
#5

You're creating an array with 500 cells, but only up to a maximum of 10 of those cells will actually be used. Wouldn't it just be a better idea to make it..

pawn Код:
new random[10];
Infact you shouldn't even call it 'random', since it's sharing the name with a function.
Reply
#6

pawn Код:
if (strcmp("/random", cmdtext, true, 6) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        new rand = random(3)+1;
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new random[MAX_PLAYERS];
        if(rand == 1)
        {
            random = "happy";
        }
        if(rand == 2)
        {
            random = "very happy";
        }
        if(rand == 3)
        {
            random = "lucky";
        }
        else
        {
            random = "sad";
        }
        format(string, sizeof(string), "A player is  %s", random);
        ProxDetector(10.0, playerid, string, COLOR_PINK,COLOR_PINK,COLOR_PINK,COLOR_PINK,COLOR_PINK);
    }
    return 1;
}
Reply
#7

pawn Код:
if (strcmp("/random", cmdtext, true, 6) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        new rand = random(4);
        new emo[12];
        if(rand == 0) { emo = "happy"; }
        else if(rand == 1) { emo = "very happy"; }
        else if(rand == 2) { emo = "lucky"; }
        else { emo = "sad"; }
        format(string, sizeof(string), "A player is  %s", emo);
        ProxDetector(10.0, playerid, string, COLOR_PINK,COLOR_PINK,COLOR_PINK,COLOR_PINK,COLOR_PINK);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)