Author Topic: [Scripts] Random Reward Script  (Read 362 times)

0 Members and 1 Guest are viewing this topic.

Forgeplex

  • Jr. Member
  • **
  • Posts: 52
  • Owner of Forgeplex.
    • View Profile
    • Forgeplex Website (Released Website)
    • Awards
  • Steam: masterbroofficial
[Scripts] Random Reward Script
« on: April 06, 2018, 06:04:33 PM »
Does anybody know how to make this?
Forgeplex has been revived! See ya soon!
Forgeplex Progress is increasing!
My Twitter: twitter.com/MBroOfficial
The official owner of Forgeplex!
The official Discord: discord.gg/WqYS2mD

Lunar

  • Elite Member
  • *****
  • Posts: 954
  • The God of the Galaxy
  • Awards 3 years on site 2 years on site 1 year on site
    • View Profile
    • Awards
  • Xbox: Qvzw
  • PSN: Widumn_Boise
Re: Random Reward Script
« Reply #1 on: April 07, 2018, 12:37:01 PM »

var [num] = [rand:2]

If
IsVar [num] [=] [0]
Then
Inventory [player] [add] [reward1] [1]
ElseIf
IsVar [num] [=] [1]
Then
Inventory [player] [add] [reward2] [1]
ElseIf
IsVar [num] [=] [2]
Then
Inventory [player] [add] [reward3] [1]
Else
EndIf


If this is what you mean it just gets a random number between 0-2, and then gives a certain item for each number

Marked as best answer by Forgeplex on April 15, 2018, 06:38:24 PM

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6650
  • Dig Deep
  • Awards Developer 5 years on site 4 years on site 3 years on site 2 years on site Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: Random Reward Script
« Reply #2 on: April 08, 2018, 02:59:45 AM »

var [num] = [rand:2]

If
IsVar [num] [=] [0]
Then
Inventory [player] [add] [reward1] [1]
ElseIf
IsVar [num] [=] [1]
Then
Inventory [player] [add] [reward2] [1]
ElseIf
IsVar [num] [=] [2]
Then
Inventory [player] [add] [reward3] [1]
Else
EndIf


If this is what you mean it just gets a random number between 0-2, and then gives a certain item for each number

A slightly more streamlined version. Since if num is not 0 and not 1 we know it must be 2 so the last ElseIf is unnecessary.

var [num] = [rand:2]
If
IsVar [num] [=] [0]
Then
Inventory [player] [add] [reward1] [1]
ElseIf
IsVar [num] [=] [1]
Then
Inventory [player] [add] [reward2] [1]
Else
Inventory [player] [add] [reward3] [1]
EndIf


Forgeplex

  • Jr. Member
  • **
  • Posts: 52
  • Owner of Forgeplex.
    • View Profile
    • Forgeplex Website (Released Website)
    • Awards
  • Steam: masterbroofficial
Re: Random Reward Script
« Reply #3 on: April 15, 2018, 03:38:54 PM »

var [num] = [rand:2]

If
IsVar [num] [=] [0]
Then
Inventory [player] [add] [reward1] [1]
ElseIf
IsVar [num] [=] [1]
Then
Inventory [player] [add] [reward2] [1]
ElseIf
IsVar [num] [=] [2]
Then
Inventory [player] [add] [reward3] [1]
Else
EndIf


If this is what you mean it just gets a random number between 0-2, and then gives a certain item for each number

A slightly more streamlined version. Since if num is not 0 and not 1 we know it must be 2 so the last ElseIf is unnecessary.

var [num] = [rand:2]
If
IsVar [num] [=] [0]
Then
Inventory [player] [add] [reward1] [1]
ElseIf
IsVar [num] [=] [1]
Then
Inventory [player] [add] [reward2] [1]
Else
Inventory [player] [add] [reward3] [1]
EndIf

Thanks to Craig and Lunar! :D
Forgeplex has been revived! See ya soon!
Forgeplex Progress is increasing!
My Twitter: twitter.com/MBroOfficial
The official owner of Forgeplex!
The official Discord: discord.gg/WqYS2mD