Ok I noticed with the rand() it does stay within the range I give it It is one above and one below
for example
var/A += rand(1,4)
if A = 0 then
A could be 0 - 5
ID:173301
Jan 24 2004, 9:37 am
|
|
Jan 24 2004, 9:58 am
|
|
I tested this a few thousand times, and not once did that happen.
|
In response to Garthor
|
|
usr.Strength += rand(2,4)
Well in this area of the Levelup() it happens to add a extra 1 sometimes. |
In response to Darkfirewolf5
|
|
Obviously your problem is that you are using usr in a proc. Fix that.
|
In response to Garthor
|
|
I dont really get why thats the problem it would be basically the same if I used src if I did usr.Levelup() wouldnt it?
|
In response to Darkfirewolf5
|
|
No.
usr leads to all kinds of problems, ESPECIALLY if you "dont really get why". It's like saying "I've ran across the street when it was a green light once and was fine, so obviously it's a safe thing to do!" http://www.byondscape.com/ascape.dmb/LummoxJR.2002-1104/ |
In response to Darkfirewolf5
|
|
No one else has ever had a problem with rand(). There's probably something else in your code that you're overlooking which is causing it. Either that or you've just discovered a "fluke of BYOND".
|
In response to Garthor
|
|
i just read the page the link links to and I realized i was using usr in mob/logout i changed the code to this mob/Logout()
src.client.base_SaveMob() and it's still giving me the same error when i run the game and logout i'm using it with deadron's character handling library and i've been getting that problem. Isn't the character handling library supposed to do that on it's own.(that what it says in the library) |
Since this was dragged back up by another mention elsewhere, and to prevent one of our bug sweepers from adding it to the bug list, I'm gonna state the obvious for future reference.
|
Run this:
<code>mob/verb/TestRand() var/counter = 1000 var/min = 1 var/max = 4 var/A = 0 var/B = 0 for(counter, counter>0, counter--) var/result = rand(min, max) if(result == min - 1) A++ if(result == max + 1) B++ src << "[min-1]s: [A]" src << "[max+1]s: [B]"</code> If the end results are anything besides 0 for you, then something's up. If not, everything is working fine. |