Jump to content


Photo

Dice Roll - MFL Scripts


11 replies to this topic

#1 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,249 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 14 December 2020 - 07:44 PM

Please use this thread to post all questions related to the Dice Roll script.

 

ATTENTION - ANY AND ALL SCRIPTS REQUIRE TO HAVE THIS GLOBAL CACHE SCRIPT PLACED AS THE FIRST ITEM IN YOUR HEADER MESSAGE !!! The script builds a cache for local storage and indexedDB storage in your browser to limit the API call to the MFL Server.

You only need a single copy of this  ,do not add multiple times if using multiple scripts.

<script src="https://www.mflscripts.com/mfl-apps/global/cache.js"></script>

 

See troubleshooting section at very bottom of this post before submitting a question.

 

Before installing any scripts - please review this video tutorial on how to prepare your MyFantasyLeague site for customizations.

 

Access ALL of MFLScripts here.

 

example.jpg

 

 

 

Most if not all of our custom scripts require the addition of a font awesome library to be loaded into a homepage message that is marked as a "Header"  OR you can import the font awesome stylesheet into your main css file , it must be the very first line in your css file. Its likely if your using any of our scripts you already have a copy loaded, so please disregard and move onto the main script installation section.

 

 

Example 1 - inserting font awesome js file into a header message

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css"/> 

    

 

Example 2 - inserting font awesome into your main css file as first line in the stylesheet

@import "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css";  

 

 

 

 

 

DICE ROLL SCRIPT INSTALLATION

Pace the following into any homepage message (Do NOT mark as a header or footer). Edit the css to match your site. Set the settings as you want.

 

To create a random draft order , install the Dice Roll script into any of your homepagemessage and display on your site where you want. This radon generator will roll virtual dice and give each owner a number which can be used to determine your leagues draft order. You can use the included "var" settings and set your icon sizing and how many dice and number of side per dice.

<!-- DICE ROLL -->

<!--- START DICE ROLL HTML --->
<div class="mobile-wrap">
    <table class="homepagemodule report" id="dice_roll" cellspacing="1" align="center">
                  <!--- EDIT HERE TO RENAME CAPTION FOR DICE ROLL --->
        <caption><span>Draft Dice Roll</span></caption>  
        <tr>
                  <!--- EDIT HERE TO RENAME TH FOR DICE ROLL --->
          <th>Official Dice Roll</th>   
        </tr>
        <tr class="oddtablerow">
          <td>  
                  <!--- EDIT HERE FOR INSTRUCTION OF YOUR DICE ROLL --->
            When you click the "Roll the Dice" button you will be rolling 20/5000 sided dice randomly to determine your position in this years draft.<br>Each owner can roll the dice 1 time , once rolled your results will display in the table below and you will not be able to roll again.<br><br>Highest roll gets 1st pick and so on and so fourth.<br><br>Good Luck!
          </td>
        </tr>
        <tr id="dicebtn_here" class="eventablerow">
          <td id="diceRollResult" align="center" style="display:none"></td>
        </tr>
    </table>
</div>

<script>
var numOfDices              = 20;     //Enter number of dice
var numOfSides              = 5000;   //Enter how many sides each dice have
var diceFranchiseIconHeight = 25;     //Must enter height of icon
var diceFranchiseIconWidth  = 150;    //Must enter width of icon
</script>

<script src="https://www.mflscripts.com/mfl-apps/diceRoll/script.js"></script>

<script>
setInterval(function() {
            showLeagueDiceRollResultsForCommish();
}, 5000);
</script>



<style>
/***************************************/


/*           DICE ROLL SCRIPT          */


/***************************************/

td#diceRollResult table th,
td#diceRollResult table td {
  text-align:center
}

td#diceRollResult table th:first-of-type,
td#diceRollResult table td:first-of-type {
  text-align:left
}

td#diceRollResult table td:last-of-type {
  font-weight:bold;
  color:#ff4200;
  
}

td#diceRollResult table tr:nth-child(2) > td:nth-child(1):before {
  content:"1.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(3) > td:nth-child(1):before {
  content:"2.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(4) > td:nth-child(1):before {
  content:"3.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(5) > td:nth-child(1):before {
  content:"4.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(6) > td:nth-child(1):before {
  content:"5.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(7) > td:nth-child(1):before {
  content:"6.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(8) > td:nth-child(1):before {
  content:"7.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(9) > td:nth-child(1):before {
  content:"8.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(10) > td:nth-child(1):before {
  content:"9.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(11) > td:nth-child(1):before {
  content:"10.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(12) > td:nth-child(1):before {
  content:"11.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(13) > td:nth-child(1):before {
  content:"12.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(14) > td:nth-child(1):before {
  content:"13.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(15) > td:nth-child(1):before {
  content:"14.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(16) > td:nth-child(1):before {
  content:"15.";
  padding-right:5px;
}

td#diceRollResult table tr:nth-child(17) > td:nth-child(1):before {
  content:"16.";
  padding-right:5px;
}

td#diceRollResult table td:first-of-type:before {
  width:24px;
  display:inline-block;
  text-align:center;
  vertical-align:middle
}
</style>

 

 

 

 

TROUBLESHOOTING TIPS

 

1. Make sure to review the help video to check your league settings are setup so customized scripts can be used.

 

2. Recopy the code above and try again. Be sure your advanced editor is turned off.

 

3. Right click mouse on your page where script displays and click "Inspect Element" . In the browsers new popup window that displays , click on the "Console" tab. Now click on the "Errors" section. Here you will find a list of any errors that have occurred. Many errors our self explanatory and you can address yourself. If your error is showing cross site  CORS has been blocked , then you need to check every CSS, JS and IMAGE file on your site and be sure they all are using https  url and not http. Another error that appears could be "too many requests" , this happens when you refresh your site many times and MFL blocks your IP for 15 minutes for submitting too many API request. If thats the case , just wait 15-20 minutes and try again.

 

4. Check out the MFL Menu > Help section. We have added a new link here called "Manage Cache". By default we are caching the API files for our script in the browsers local storage. If you script isn't updating , you can force an update by clicking "Clear Local Storage". The next link is called "Enable IndexedDB" , this link is only meant to be used for owner that are getting the "Too Many Requests" error because there are using several scripts on several different MFL leagues that use the same serverID. Click this if needed more storage.

 

5. If the above wasn't any help , then post a question and we will do our best to help when the time allows.


All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#2 UCanCallMeMitch

UCanCallMeMitch

    Veteran

  • Members
  • PipPipPip
  • 3,838 posts
  • Gender:Male
  • Location:Colorado

  • 2021 MFL: 74144

Posted 14 December 2020 - 08:55 PM

Luv these separate threads on the scripts / apps, but I have a request.

 

Could you have a link to a league that uses them so we can see them in action? 


ldsportslogoindex_32x32.png  LuckyDog Sports 
" Fantasy Fun For Football Fanatics "


#3 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,249 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 14 December 2020 - 09:54 PM

wanted to do that but so many scripts are not populated unless logged in or as commish , many others are vacant most of the year with no data so pages blanked and will prompt more questions then answers


All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#4 UCanCallMeMitch

UCanCallMeMitch

    Veteran

  • Members
  • PipPipPip
  • 3,838 posts
  • Gender:Male
  • Location:Colorado

  • 2021 MFL: 74144

Posted 15 December 2020 - 04:17 AM

Good Point.  Thanks for considering.


ldsportslogoindex_32x32.png  LuckyDog Sports 
" Fantasy Fun For Football Fanatics "


#5 DA-G-GURU

DA-G-GURU

    Veteran

  • Members
  • PipPipPip
  • 1,206 posts
  • Gender:Male
  • Location:DAGrafixDesigns.com

Posted 15 December 2020 - 01:14 PM

I think your the reason for the separate threads :P


Simply The Best in Grafix and CSS webdesign since 2005

www.dagrafixdesigns.com

---------------
Twitter @DA_Sticks

#6 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,249 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 15 December 2020 - 01:33 PM

adding screen shots to all script posts now , so at least you can see what they can and should look like

 

 

got admin forum rights today , so cleaning up all the posts , pinning and locking down some threads to try to get some organization here and filter all questions into the threads assigned for each script


All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#7 UCanCallMeMitch

UCanCallMeMitch

    Veteran

  • Members
  • PipPipPip
  • 3,838 posts
  • Gender:Male
  • Location:Colorado

  • 2021 MFL: 74144

Posted 16 December 2020 - 07:17 AM

Yea, someone is finally in charge.

 

Outstanding move on inserting an image of the final product to each thread,

 

And if not me pushing the limits - who else?


ldsportslogoindex_32x32.png  LuckyDog Sports 
" Fantasy Fun For Football Fanatics "


#8 Gridiron Guru

Gridiron Guru

    Member

  • Members
  • PipPip
  • 24 posts

Posted 25 September 2021 - 11:21 AM

I plan on using the dice roll to determine if a hold out player will return to the their team under current salary/contract terms.   I notice that the change the dice number and number of sides does not affect the dice roll as expected.  is possible to change the text 'current draft order'  and is there an option to turn the icon representing the team back to the team name?

 

var numOfDices              = 2;     //Enter number of dice
var numOfSides              = 6;   //Enter how many sides each dice have
var diceFranchiseIconHeight = 25;     //Must enter height of icon
var diceFranchiseIconWidth  = 150;    //Must enter width of icon


#9 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,249 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 25 September 2021 - 02:57 PM

You can change the text to whatever you want
Look at the HTML , its noted that you can change it

If your league uses icons then icons are displayed

All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#10 Gridiron Guru

Gridiron Guru

    Member

  • Members
  • PipPip
  • 24 posts

Posted 25 September 2021 - 11:00 PM

Thanks! How do I get the number of dice and number of sides to stick if I want two 6 sided die? Even when I change it it still seems to roll twenty 5000 sided dice

#11 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,249 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 25 September 2021 - 11:48 PM

Thanks! How do I get the number of dice and number of sides to stick if I want two 6 sided die? Even when I change it it still seems to roll twenty 5000 sided dice

 

 

do a hard refresh on your site and see if its working now with number of dice and sides , i found a spelling error in the script which i think caused the number selected not to work and it was using the default settings


All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#12 Gridiron Guru

Gridiron Guru

    Member

  • Members
  • PipPip
  • 24 posts

Posted 26 September 2021 - 07:37 AM

Excellent! works great now, Thank you!





Reply to this topic



  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users