![]() |
My little problemo!
I'm having a few problems. I've created a minor event thing on Era, You donate money to a guy, which adds the
''this.MaxDonater (money, amount)'' It all works, however, when trying to find out who has done the second most donated money, it causes a few problems... Here's the script: HTML Code:
public function ShowBridgeStats()HTML Code:
MaxDonater=3003,RaeiphonIt's probably a simple thing I am missing, but I can't seem to find it. If anyone could help, it'd be great, thanks! [I used a public function to call it from another NPC] |
I think its only coincidence that they are the same, and only coincidence that they are the greatest donation.
That doesnt not calculate the greatest value of them all. It repeatedly sets the MaxSecond var to the latter of any two pairs of values if the latter is the largest. Nothing is ever compared with MaxSecond, so there is no reason to think that the last value of MaxSecond is actually the largest of all the values ever assigned to in the iteration. I say you just toss out whatever code you have for calculating the two, and rewrite it. I dont see the Maximum value being calculated here, so maybe theres a chance its being calculated after this, which would be the same as if the check in this one didnt even exist. No insult intended, but that code makes absolutely no sense. Here, this may help: NPC Code: now, to calculate the largest and second largest, you only have to do a couple things: 1) pair the amounts and the names in a list; amounts first, names second. 2) assign the result of passing this list to the function above, to the MaxDonater variable 3) remove MaxDonater from the list. 4) assign the result of applying the function to the newly updated list to MaxSecondDonater. MaxDonater isnt in the list, so it cant be duplicated in MaxSecondDonater hope this helps. |
I don't quite understand your code at all to be honest.
An array starts at the NULL position (0), not at one... If you started it at one, then you would compleatly miss the first param in the array. I'll give it a go though, thanks... |
Well, there needs to be something in the temp.largest variable before the loop starts. On line 3, the first item in the array is dumped into it, and there isnt much point in starting the loop off at 0, since youd just be comparing the first value with its self. It also allows for cases where there is only one donator, donators.size() will be equal to 1, so the loop will be skipped, and the first and only item in the array is returned.
|
I see, thank you
|
Don't call index 0 NULL, because it's not... FYI.
|
Erm, problem.
if (0 == NULL) { that returns true. |
0 == false == "" == null == "0"
|
x_____________________________________________X SOMEONE FIX THIS PL0X
0 == "0", true 0 == false, true 0 != NULL 0 != "" Graal should be like that |
Quote:
|
Quote:
|
| All times are GMT +2. The time now is 10:01 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.