The online racing simulator
#26 - sun
Hey Kuhs.

It was kind of you to share this. It really got me thinking after a while, Because At the time I wrote my code, Variables, functions Everything was Wizzing around my head, and I couldnt get it Lined Up!
#27 - KuHS
Quote from sun :Hey Kuhs.

It was kind of you to share this. It really got me thinking after a while, Because At the time I wrote my code, Variables, functions Everything was Wizzing around my head, and I couldnt get it Lined Up!

Just try and you will write it up
#28 - sun
Please provide me your opinions about this....

if (C.DistanceSincePit / 500d == 100)
{

C.Cash += 2500;
InSim.Send_MST_Message("/msg ^6>^8 " + C.PlayerName + " ^7received ^2€2500");
InSim.Send_MST_Message("/msg ^6>^2 Reason:^7 Distance bonus");
C.DistanceSincePit / 500d = 101;
}

I see something that doesn't make any sense. You're telling a math operation to equal 101. There's nothing that is actually being able to be assigned (You can't assign the "C.DistanceSincePit / 500d" to have a value as it's a math operation (division)) which will cause either a compilation error or warning.
#30 - sun
Sorry didn't see that....

if (C.DistanceSincePit / 500d == 100)
{

C.Cash += 2500;
InSim.Send_MST_Message("/msg ^6>^8 " + C.PlayerName + " ^7received ^2€2500");
InSim.Send_MST_Message("/msg ^6>^2 Reason:^7 Distance bonus");
C.DistanceSincePit / 500d += 1;
}

It's still the same bug, you're still assigning a number on both sides.

Let C.DistanceSincePit = 2000

you now have (2000 / 500) += 1

You are then incrementing 4 by 1, which cannot be done.
-
(sun) DELETED by sun : Already answered
If only I knew what was in the deleted post.
#33 - sun
Quote from dawesdust_12 :If only I knew what was in the deleted post.

Just a dumb question when not reading your post right.
#34 - sun
Ok, now I have a problem. I've just had a friend get to 100%. But it doesn't give him the reward.

if (C.DistanceSincePit / 500d == 100)

If you could help with that please
Quote from sun :Ok, now I have a problem. I've just had a friend get to 100%. But it doesn't give him the reward.

if (C.DistanceSincePit / 500d == 100)

If you could help with that please

if (C.DistanceSincePit / 500 >= 100)
{
C.DistanceSincePit = 0;
C.Cash += 12345;
//Send the bonus messages?
}

I recommend this exact order. Why?
First - Reset the DistanceSincePit variable first, as a protection measure.
Second - If the var has been set successfully, this line will be reached. In case the var has failed to be set, an exception will be thrown, and the cash increase code won't be reached.
Last - If everything went well, the message sending code will be reached, and message(s) about successful bonus receival will be sent to the user(s).

I have a question: Why 500d? That converts it to a decimal, iirc? Is DistanceSincePit a decimal?
#36 - sun
Fixed problem. I used... bool bonus1 = true all the way to bonus5. and used it in my code. Works like a charm Thanks guys for the help!
Instead of having unlimited "bonus1-5" you can just have one "byte"(i dont think you will have more than 255 different bonuses) and set it as default to zero. after that you can check each bonus like

if Player.Bonus <= 0 && Player.TotalDistance >= 100 then
{
GIVE_HIM_BONUS
Player.Bonus = 1;
}
else if Player.Bonus <= 1 && Player.TotalDistance >= 200 then
{
GIVE_HIM_BONUS_OF_200KM
Player.Bonus = 2;
}

and goes on....
Quote from DarkKostas :(i dont think you will have more than 255 different bonuses)

That should be setup as a enumeration then. In the case that multiple bonus can be set at one time, then he should use a bit field.
Yes, congrats Sun on getting this. It only took 2 years of asking the same question in several different threads repeatedly!
Quote from dawesdust_12 :Yes, congrats Sun on getting this. It only took 2 years of asking the same question in several different threads repeatedly!

Why was that needed? Stop trolling, it's not helping anyone.
Quote from Dygear :Why was that needed? Stop trolling, it's not helping anyone.

+1

@sun: Why not just a simple formula? Cash += 2500 + ((DistanceSincePit / 500) / 100 - 1) * 1000

Which can be simplified to:
Cash += 2500 + (DistanceSincePit / 50 - 1) * 1000

Then, first bonus will be 2500; Second bonus will be 3500, 3rd = 4500, and so on. Tweak it any way you like. IMO, that's the best way to go for that task. And if you want the 6th bonus to make it start all over again, reset DistanceSincePit, if the bonus that you just gave has been >=7500.
Quote from broken :+1

@sun: Why not just a simple formula? Cash += 2500 + ((DistanceSincePit / 500) / 100 - 1) * 1000

Which can be simplified to:
Cash += 2500 + (DistanceSincePit / 50 - 1) * 1000

Then, first bonus will be 2500; Second bonus will be 3500, 3rd = 4500, and so on. Tweak it any way you like. IMO, that's the best way to go for that task. And if you want the 6th bonus to make it start all over again, reset DistanceSincePit, if the bonus that you just gave has been >=7500.

Depends if you want it to go up in increments, he may want

1,000
2,000
4,000
8,000
16,000

or randomly done, or maybe each distance bonus will be higher in distance.
Quote from Krammeh :Depends if you want it to go up in increments, he may want

1,000
2,000
4,000
8,000
16,000

or randomly done, or maybe each distance bonus will be higher in distance.

I was just giving an example, but yes, you are right.

And what the hell have I done. This formula I made up is totally irrelevant, sorry.
Let me fix it..
So, if DistanceSincePit=50000=50km=bonus time, then this is how it should be(you can always tweak/change it the way you want):
Cash += 2500 + (DistanceSincePit / 50000 - 1) * 1000
(not sure if it can be simplified more)

And to illustrate another formula, I'll use Krammeh's example. To achieve this kind of effect, here's the formula:
1000 * (2 ^ (DistanceSincePit / 50000 - 1))
#44 - sun
Thanks Broken, and thanks krammeh!
2

FGED GREDG RDFGDR GSFDG