SA-MP Forums Archive
message in a row - 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: message in a row (/showthread.php?tid=566032)



message in a row - TiXz0r - 02.03.2015

I do not want random , I want to go in a row automessages.
like:
first message 1,next message 2, next message 3,next message 4,
i dont want random like:message 2 ,message 1,message 3
Код:
public RandomMsg()
{
    switch(random(3))
    {
    case 0: SendClientMessageToAll(COLOR_SERVERMSG, "message 1");
    case 1: SendClientMessageToAll(COLOR_SERVERMSG, "message 2");
    case 2: SendClientMessageToAll(COLOR_SERVERMSG, "message 3");  
    case 3: SendClientMessageToAll(COLOR_SERVERMSG, "message 4");  
    case 4: SendClientMessageToAll(COLOR_SERVERMSG, "message 5");  
    case 5: SendClientMessageToAll(COLOR_SERVERMSG, "message 6");  

	}
}



Re: message in a row - Schneider - 02.03.2015

//Top of script:
pawn Код:
new CurrentMessage;
pawn Код:
public RandomMsg()
{
    switch(CurrentMessage)
    {
        case 0: { SendClientMessageToAll(COLOR_SERVERMSG, "message 1"); CurrentMessage++; }
        case 1: { SendClientMessageToAll(COLOR_SERVERMSG, "message 2"); CurrentMessage++; }
        case 2: { SendClientMessageToAll(COLOR_SERVERMSG, "message 3"); CurrentMessage++; }
        case 3: { SendClientMessageToAll(COLOR_SERVERMSG, "message 4"); CurrentMessage++; }  
        case 4: { SendClientMessageToAll(COLOR_SERVERMSG, "message 5"); CurrentMessage++; }  
        case 5: { SendClientMessageToAll(COLOR_SERVERMSG, "message 6"); CurrentMessage=0; }  
    }
}

Edit:...or you could define all the messages on top of your script:
pawn Код:
new CurrentMessage;
new ServerMessages[6][128] = {
    "Message 1",
    "Message 2",
    "Message 3",
    "Message 4",
    "Message 5",
    "Message 6"
};
pawn Код:
public RandomMsg()
{
    SendClientMessageToAll(COLOR_SERVERMSG, ServerMessages[CurrentMessage]);
    CurrentMessage++;
    if(CurrentMessage == sizeof(ServerMessages)) CurrentMessage=0;
}



Re: message in a row - TiXz0r - 03.03.2015

Quote:
Originally Posted by Schneider
Посмотреть сообщение
//Top of script:
pawn Код:
new CurrentMessage;
pawn Код:
public RandomMsg()
{
    switch(CurrentMessage)
    {
        case 0: { SendClientMessageToAll(COLOR_SERVERMSG, "message 1"); CurrentMessage++; }
        case 1: { SendClientMessageToAll(COLOR_SERVERMSG, "message 2"); CurrentMessage++; }
        case 2: { SendClientMessageToAll(COLOR_SERVERMSG, "message 3"); CurrentMessage++; }
        case 3: { SendClientMessageToAll(COLOR_SERVERMSG, "message 4"); CurrentMessage++; }  
        case 4: { SendClientMessageToAll(COLOR_SERVERMSG, "message 5"); CurrentMessage++; }  
        case 5: { SendClientMessageToAll(COLOR_SERVERMSG, "message 6"); CurrentMessage=0; }  
    }
}

Edit:...or you could define all the messages on top of your script:
pawn Код:
new CurrentMessage;
new ServerMessages[6][128] = {
    "Message 1",
    "Message 2",
    "Message 3",
    "Message 4",
    "Message 5",
    "Message 6"
};
pawn Код:
public RandomMsg()
{
    SendClientMessageToAll(COLOR_SERVERMSG, ServerMessages[CurrentMessage]);
    CurrentMessage++;
    if(CurrentMessage == sizeof(ServerMessages)) CurrentMessage=0;
}
thanks, rep+