[HELP] RANDOM NUMBER GENERATOR

Ask anything you want to know
User avatar
francisco
Posts: 62
Joined: Tue Mar 07, 2023 1:48 pm
Location: Brazil
Contact:

Re: [HELP] RANDOM NUMBER GENERATOR

Post by francisco »

shrmaprem0202 wrote: Thu Feb 01, 2024 10:57 am I want to create a random post code there i can use %total% tag in random tag
Now we will be able to do this by following these steps:

1. Create a Post Lister with the following:

Code: Select all

-Enter Code-
{{NULL()}}

-Enter Config-
<FORUMID>24031</FORUMID>
<LIMIT>1</LIMIT>

-Footer-
{{PAGING(%last%)}}
Now, click on the Post Lister code menu you just created and select "Rule" and in the Code Rule field add the following:

Code: Select all

#SET(end)#
#HIDE#
Image


2. Now let's create a new TAG Code with the code to generate random numbers that I showed in the last message, with the exception that we will not define the "end" directly in the code, as it will be the value of the Post Lister's "paging last" - make sure the TAG Code will be right after the Post Lister:

Code: Select all

{{VALUE(1)@INT@SET(start)@NULL}}

{{DATE(U)@INT@SET(time)@NULL}}
{{RANDOM("013579")@INT@SET(seed1)@NULL}}
{{RANDOM("02468")@INT@SET(seed2)@NULL}}
{{VAR(time)@DIVIDE@VAR(seed1)@INT@SET(rseed_div)@NULL}}
{{VAR(rseed_div)@MULTIPLY@VAR(seed2)@INT@SET(rseed)@NULL}}
{{VAR(end)@MINUS@VAR(start)@PLUS(1)@SET(range)@NULL}}
{{VAR(rseed)@DIVIDE@VAR(range)@INT@SET(quotient)@NULL}}
{{VAR(quotient)@MULTIPLY@VAR(range)@SET(quotient_divisor)@NULL}}
{{VAR(rseed)@MINUS@VAR(quotient_divisor)@SET(remainder)@NULL}}
{{VAR(remainder)@PLUS@VAR(start)@SET(random_number)@NULL}}

{{VAR(random_number)}}
Now let's also define a Code Rule for this TAG Code, as follows:

Code: Select all

#SET(random_post)#
#HIDE#

3. Now the last and most important thing, let's define a new Post Lister that will show the random post itself:

Code: Select all

-Enter Code-
<h3>%id% - %title%</h3> ... any code

-Enter Config-
<FORUMID>24031</FORUMID>     <-- Same as the first Post Lister
<LIMIT>1</LIMIT>
<PAGE>{{VAR(random_post)}}</PAGE>     <-- Here's the magic!
😴
shrmaprem0202
Posts: 38
Joined: Tue Mar 07, 2023 7:13 pm
Contact:

Re: [HELP] RANDOM NUMBER GENERATOR

Post by shrmaprem0202 »

francisco wrote: Thu Feb 01, 2024 8:50 pm
shrmaprem0202 wrote: Wed Jan 31, 2024 4:42 am What if i need only 1 to 35
Okay, so after some thinking I came out with this "thing" to generate random numbers between a given range (just set "start" and "end" - must be positive numbers and end > start):

Code: Select all

{{VALUE(1)@INT@SET(start)@NULL}}
{{VALUE(35)@INT@SET(end)@NULL}}

{{DATE(U)@INT@SET(time)@NULL}}
{{RANDOM("013579")@INT@SET(seed1)@NULL}}
{{RANDOM("02468")@INT@SET(seed2)@NULL}}
{{VAR(time)@DIVIDE@VAR(seed1)@INT@SET(rseed_div)@NULL}}
{{VAR(rseed_div)@MULTIPLY@VAR(seed2)@INT@SET(rseed)@NULL}}
{{VAR(end)@MINUS@VAR(start)@PLUS(1)@SET(range)@NULL}}
{{VAR(rseed)@DIVIDE@VAR(range)@INT@SET(quotient)@NULL}}
{{VAR(quotient)@MULTIPLY@VAR(range)@SET(quotient_divisor)@NULL}}
{{VAR(rseed)@MINUS@VAR(quotient_divisor)@SET(remainder)@NULL}}
{{VAR(remainder)@PLUS@VAR(start)@SET(random_number)@NULL}}


{{VAR(random_number)}}
https://stackoverflow.com/questions/198 ... mod-operat
https://www.w3resource.com/php-exercise ... ise-40.php
Wow it's working perfectly thanks love you bro 💕💕💕
Post Reply