RESELECT:
if(last_RandomMessage == RandomSelection) {
//Oh no! The random selected the same message as before! This is where we make it select again and again until it gets a different message!
//To do this, we just simply create the random again!
RandomSelection = random(3);
last_RandomMessage = RandomSelection;
if(last_RandomMessage == RandomSelection)
goto RESELECT;
//We do not return here, because we would like to let the rest of the code run.
}
last_RandomMessage = RandomSelection;
reselect:
if(last_RandomMessage == RandomSelection) {
//Oh no! The random selected the same message as before! This is where we make it select again and again until it gets a different message!
//To do this, we just simply create the random again!
RandomSelection = random(3);
last_RandomMessage = RandomSelection;
printf("test");
if(last_RandomMessage == RandomSelection) goto reselect;
printf("test passed");
//We do not return here, because we would like to let the rest of the code run.
}
pawn Код:
|
last_RandomMessage = RandomSelection;
then it works...
you realize you have pawn Код:
|
[22:59:45] This is random message numero dos! [22:59:45] This is random message numero tres! [22:59:45] This is random message numero uno! [22:59:45] This is random message numero uno! [22:59:45] This is random message numero dos! [22:59:45] This is random message numero uno! [22:59:45] This is random message numero tres! [22:59:45] This is random message numero dos! [22:59:45] This is random message numero uno! [22:59:46] This is random message numero tres! [22:59:46] This is random message numero tres! [22:59:46] This is random message numero tres! [22:59:46] This is random message numero tres! [22:59:46] This is random message numero dos! [22:59:46] This is random message numero tres! [22:59:46] This is random message numero tres! [22:59:46] This is random message numero dos! [22:59:47] This is random message numero tres! [22:59:47] This is random message numero dos! [22:59:47] This is random message numero tres! [22:59:47] This is random message numero tres! [22:59:47] This is random message numero tres! [22:59:47] This is random message numero dos! [22:59:47] This is random message numero uno! [22:59:47] This is random message numero tres! [22:59:47] This is random message numero tres! [22:59:48] This is random message numero uno! [22:59:48] This is random message numero dos! [22:59:48] This is random message numero tres! [22:59:48] This is random message numero tres! [22:59:48] This is random message numero dos! .. |
reselect:
if(last_RandomMessage == RandomSelection) {
//Oh no! The random selected the same message as before! This is where we make it select again and again until it gets a different message!
//To do this, we just simply create the random again!
RandomSelection = random(3);
printf("test");
if(last_RandomMessage == RandomSelection) goto reselect;
last_RandomMessage = RandomSelection;
printf("test passed");
//We do not return here, because we would like to let the rest of the code run.
}
if(last_RandomMessage == RandomSelection)
{
//last_RandomMessage = RandomSelection; - don't need this because it already equals it, we checked in the above if statement
RandomSelection = random(3);
if(last_RandomMessage == RandomSelection)
{
if(!last_RandomMessage) RandomMessage++;//if last_RandomMessage == 0, ++ to it, so 0 would become 1.
else RandomMessage--;//else minus so 2 = 1, 1 = 0;
}
//We do not return here, because we would like to let the rest of the code run.
}
I.e. use this:
pawn Код:
|
last_RandomMessage = RandomSelection;
if(last_RandomMessage == RandomSelection)
new CommercialOld;
new Commercials[][]={
">>> advertisement [0]",
">>> advertisement [1]",
">>> advertisement [2]"
};
forward CommercialMsg();public CommercialMsg(){
new Rnd=(1+CommercialOld+(random(sizeof(Commercials)-1)))%sizeof(Commercials);
SendClientMessageToAll(MSGCOMM_COLOR,Commercials[Rnd]);
CommercialOld=Rnd;
return 1;
}
//OnGameModeInit():
SetTimer("CommercialMsg",180000,true);
(1+CommercialOld+(random(sizeof(Commercials)-1)))%sizeof(Commercials) (1+ 2+(random( 3-1)))% 3 ( 3+(random( 2)))% 3 ( 3+( 0))% 3=0 ( 3+( 1))% 3=1