The online racing simulator
Km Bonus
(20 posts, started )
#1 - sun
Km Bonus
Hi all.

I have not really been on for at least 4 -5 years, so first I would like to say, Hi again.

-------------------------------------------------

Ok, I've just found my InSim, and I want to add a Km Bonus System. Yes thats right a KM Bonus System. Dont be alarmed! I've got my code here, but I just need someone to help me out with the variables.

My Code so far is:

// KM bonuses
if (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[0].PLID)].UniqueID)].TotalDistance / 1000 == 100) ;
{
// Give them £2000
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Cash = cashbonus;
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Username += cash;

}

Now as we see here the code inside the statement will not work. This is what I need help with. What I want to do is put

"Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Cash"

into some kind of... Oh, forgot the name... Damn.... But some kind of Integrar should I say for now. For example:

Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Cash == CashBonus;

Can anyone help me?

Thanks!
-
(MariusMM) DELETED by MariusMM : History
#2 - sun
Yes. Thanks!

Would this be right?

// KM bonuses
if (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[0].PLID)].UniqueID)].TotalDistance / 1000 == 100) ;
{
// Give them £2000
int cashbonus = 2000;
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Cash = cashbonus;
InSim.Send_MST_Message(Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Username + " /msg ^7Received a Cash Bonus of £2000");
InSim.Send_MST_Message("/msg ^7For Driving A Long Distance");

}

2 things I see potentially happening:
1) They will have their money reset to 2000 (= vs +=)
2) It'll happen constantly the entire time that they are on any KM that meets the condition, If you parked, you'd keep getting +2000 (or =2000 as your code is right now).
#4 - sun
Yeh. Thats why i added a "goto
" function. But that does not seem to be working either. I tested it out, an it just cycles through the code, 2000 4000 6000. But does not give me any money.

Could anyone correct my code please?
... don't use goto's.. :S.

A simple way would be some sort of flag that you set when you give the bonus (either for the session, or store it in the DB).. and then check that flag to make sure that bonus hasn't been given out already.
#6 - amp88
Quote from sun :Hi all.

I have not really been on for at least 4 -5 years, so first I would like to say, Hi again.

Not so. You have actually created a number of threads in the last couple of years. Most of them are in this format:

"I have a problem. I have either not tried or have half-heartedly tried to solve them. The problem I have is based on the fact I have stolen someone else's code / waded into a situation I have no knowledge of. Please help me out."

You have had various people attempt to help you out with direct code, with pointers in the right direction and with suggestions on where to look for help. Despite these you have either decided not to educate yourself or you have attempted to and failed to do so.

The reason that I am posting this is not because I want to bully or attack you; it's because I want to highlight the fact that you have not been helped a single bit by the help you have received from this community. The only way you would benefit from this thread is if someone gave you code you could copy exactly or you actually sat down and tried to learn something about developing an application. Hopefully no-one will just give you code unless you can actually show you understand how it works and how to modify it, because it's not a long-term solution.

Quote from sun :Can anyone help me?

Thanks!

The only person who can truly help you is yourself. Either go away and try to learn or give up.

For reference, here are 2 other threads by sun asking about the same area: Thread 1, Thread 2.
Amp, we all have our views on the Sun saga.. I'd put him as the biggest curse on the programmer forum.. even worse than people going "I can has insims?".
#8 - sun


Actually the code above is mine. I've just took the time to find what the variables are. Year 9 High School - Cannot afford to waste my time on peoples negative opinions about me. You was like that once. Get over it.

----------------------------

Now getting back onto topic which like were 'SUPPOSED' to be on.

I just dont understand how this does not work and the program just skips through all 3 of them...

if (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[0].PLID)].UniqueID)].TotalDistance / 1000 == 100) ;

In my sense.... If the user has driven 100 KM, give the user 2000 cash e.g....

then 'goto fourthousand;'

fourthousand:
// 4000 Bonus (200 KM)
if (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[0].PLID)].UniqueID)].TotalDistance / 1000 == 200) ;
{

So the program should wait untill the user has driven 200 KM. Right?
Sun:
1) You haven't learned. Your logic is STILL flawed. Why would anyone try to help you when you still haven't proved that you've tried to learn. You're making the EXACT same mistakes you made when you first made threads, and asking the same question.

2)
#10 - sun
Quote from dawesdust_12 :Sun:
1) You haven't learned. Why would anyone try to help you when you still haven't proved that you've tried to learn.

And how would YOU know? Exactly. You don't know me from 4 years ago. So don't THINK you do.
... Time must fly a lot for you. You've only been here for 3 years.

I do know, because I've read the forums a lot... You've asked the same question 3 times.. Amp linked it above. April 2008 and May 2009 with the EXACT same question of a bonus system by KM driven.. Heck, both threads have a solution in logic.. you just haffto implement the code yourself.. however you still expect people to provide the code.

You haven't learned. As evidenced by the SAME code you were using a year ago. Not to mention you seem to think a goto is a good idea.
#12 - sun
People to provide the code? Ok. So whats the point in the help programming forum? I've provided the code I've written to get help on something I dont understand. That IS what the help programming forum is for. So I can either get help, or what is the point in the forum?

Somethings I did lets say a year ago, 2 years ago, I cannot change. Whats done is done. There's a Fact for you.
There's getting help, or there's just wanting people to write the code for you. In the threads that you've made in the past.. I count 3 solutions to this problem in text and overall logic... but strangely they're not implemented. I wonder why...

You expect people to gift you the code. You write stuff, but when you get a problem, you don't exercise any problem solving skills. You expect people to fix the code for you and say "here it is". When people give you explanations on how to implement something like they have.. it gets met with "HOW DO I DO THIS?" again and again. You don't try to write things yourself.
Protip: before writing code, first think what you want to make and how to do it (in english, not C# :shy e.g.:
Quote :1. check user's bank balance
2. if he has enough cash to buy a drink, add 10% to his energy and remove $5 from his bank balance
3. if he doesn't has enough cash, return an error and proceed.

#15 - sun
I'm not asking for that. I just give up. Its the same over again. Whats the point? You think I don't try? you think I expect people to give me code? I'M ASKING FOR PEOPLE'S HELP AND OPINIONS ON IT

Problem Now? FFS
You do expect people to give code. I'll quote a few posts where people have given you the exact answer.

Quote from Krammeh :If currentmiles > milestone
and if milestonecompleted !=true
reward, and set that milestone as done.

Don't forget to clear the milestone done, if they leave the track.

Quote from Heiko1 :Just a sample code from my system:

if (Player.DroveKM.Session == 10)
{
Send.Player.Cash += 500;
Reset = Player.DroveKM.Session;
}

if (Player.DroveKM.Session == 30)
{
Send.Player.Cash += 1000;
Reset = Player.DroveKM.Session;
}

if (Player.DroveKM.Ses......

Hope i can help you

Regarts Heiko1

Quote from KuHS :Here you go my code, simple and working. It's in my updatecheck void:

if ((C.InitialBonus) >= 100) // 100 is the proc, so you can have bars and lines with this
{
C.OLap += 20;
C.OBonus += 2000;
C.InitialBonus = 0;
InSim.Send_MTC_MessageToConnection("^3You've got " + (C.OBonus) + "$ a bonus for " + (C.OLap) + " laps on the track", (C.UniqueID), 0);
C.Cash += (C.OBonus);

if ((C.BDistance) >= 1760) // At 1,76 km you will get +1 bonus proc, you can change it
{
C.BDistance -= 1760;
C.InitialBonus += 1;
}

Conn.BDistance += Convert.ToInt32(SpeedMS); // And dont forget this
}


All that from your thread last year.. yet you're still stuck on it. You haven't tried obviously.
#17 - sun
Heiko1's Has Kind of helped me...... But I'm still not getting it to work..... I'll try my self..... But I can have help right?
Help != Programming for you.

Give a man a fish he eats for a day, teach a man to fish he eats for a life time.
why not try this on System Timers instead?

its like this


if (C.DistanceSinceTravel >= 80000)
{
if (C.BonusTravelled == 0)
{
C.Cash += 2500;
C.BonusDone += 1;
}
else if (C.BonusTravelled == 1)
{
C.Cash += 4500;
C.BonusDone += 1;
}
}

C means u need to use foreach (clsconn... C in Connections)

mostly i use it as the CheckUser Timers

EDIT: OOPS ITS DISTANCE BONUS SRY
Quote from Dygear :Give a man a fish he eats for a day, teach a man to fish he eats for a life time.

So true!

I cannot believe that these threads are still goin on..this old place has'nt changed much...

Km Bonus
(20 posts, started )
FGED GREDG RDFGDR GSFDG