Create a free account to remove all ad content.

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

0 Members and 1 Guest are viewing this topic.

Forgeplex

  • Jr. Member
  • *
  • Posts: 52
    • View Profile
Random Reward Script
« on: April 06, 2018, 06:04:33 PM »
Does anybody know how to make this?

Lunar

  • Elite Member
  • *
  • Posts: 995
  • The God of the Galaxy
    • View Profile
  • 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

Craig

  • Developer
  • Extreme Member
  • *
  • Posts: 6655
  • Dig Deep
    • View Profile
    • Twitter
  • 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
    • View Profile
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