Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question...
#1
Int(Rnd * 10)

Right so lets say m = Int(Rnd * 10)

Is there any way to say:

Code:
If m = even-number then

Basically, I want to know if a variable is an even number.
Reply
#2
Code:
If m mod 2 = 0 then

Just off the top of my head, but believe it'd work. :wink:

Then for odd:

Code:
if m mod 2 = 1 then
Reply
#3
Nooo, the mod thingy..
Reply
#4
I love the mod operation. It has so many cool uses and most people don't know about it.
Reply
#5
wow im suddenly really glad i clicked on this ... rofl
Reply
#6
Spodi Wrote:
Code:
If m mod 2 = 0 then

Just off the top of my head, but believe it'd work. :wink:

Then for odd:

Code:
if m mod 2 = 1 then

Tongue Thanks
Works perfectly (if you hadn't guessed, I needed "m" to be only a 50% chance)
Reply
#7
Why not use:

Code:
If Int(Rnd * 2) = 1 Then ...

That'll give you a pseudo-50/50 chance and require less processing/code. :wink:
Reply
#8
Spodi Wrote:Why not use:

Code:
If Int(Rnd * 2) = 1 Then ...

That'll give you a pseudo-50/50 chance and require less processing/code. :wink:

Well, theres more to my code than just needing a 50% chance. It's part of my mining sub:

[code]
m = Int(Rnd * GetPlayerMining(Index))
' Narrow Odds to 50%, no matter how good the skill is
If m Mod 2 = 1 Then
m = 0
End If
' Give them nothing
If m = 0 Then
Call PlayerMsg(Index, "You find nothing.", Yellow)
Call SetPlayerMiningEXP(Index, GetPlayerMiningEXP(Index) + 1)
End If

' Give Them Loot1
If m >= 1 And m
Reply
#9
Ah ok, I figured there was more to the story. :wink:
Reply
#10
Mining is basicly only used for quests, right?
Reply
#11
Not really, it's a job in TPO (Another game Sonire is working on, sort of. Lol).

Meaning, the players have an obligation to mine in order to make money and items and such.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)