Mirage Source

Free ORPG making software.
It is currently Sat Apr 27, 2024 6:31 pm

All times are UTC




Post new topic Reply to topic  [ 44 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Shutdown
PostPosted: Sat Sep 23, 2006 5:10 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Haha :P The timer for the server shutdown is set to 5000ms, which equals to 5s.

Make it 2000, or it wont be correct with the actual text that is sent to all players online.

Or replace this:
Code:
Static Secs As Long

    If Secs <= 0 Then Secs = 30
    Call GlobalMsg("Server Shutdown in " & Secs & " seconds.", BrightBlue)
    Call TextAdd(frmServer.txtText, "Automated Server Shutdown in " & Secs & " seconds.", True)
    Secs = Secs - 2
    If Secs <= 0 Then
        tmrShutdown.Enabled = False
        Call DestroyServer
    End If


Since 2000 * 2.5 = 5000, it most mean that we need to multiply the Secs = 30 with 2.5, which gives us 75 :)

With this:
Code:
Static Secs As Long

    If Secs <= 0 Then Secs = 75
    Call GlobalMsg("Server Shutdown in " & Secs & " seconds.", BrightBlue)
    Call TextAdd(frmServer.txtText, "Automated Server Shutdown in " & Secs & " seconds.", True)
    Secs = Secs - 2
    If Secs <= 0 Then
        tmrShutdown.Enabled = False
        Call DestroyServer
    End If


Why do I even tell a so simple thing? Just dont tell me its wrong :oops: hehe






KILL ME!

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 5:33 pm 
Offline
Regular

Joined: Mon Jun 12, 2006 10:10 pm
Posts: 68
It'd be better if you changed the interval to 1000 and...

Code:
Static Secs As Long

    If Secs <= 0 Then Secs = 30
    If Secs Mod 5 = 0 Or Secs <= 5 Then
        Call GlobalMsg("Server Shutdown in " & Secs & " seconds.", BrightBlue)
        Call TextAdd(frmServer.txtText, "Automated Server Shutdown in " & Secs & " seconds.", True)
    End If
    Secs = Secs - 1
    If Secs <= 0 Then
        Call GlobalMsg("Server Shutdown.", BrightRed)
        tmrShutdown.Enabled = False
        Call DestroyServer
    End If


That'd give you...

Quote:
Server Shutdown in 30 seconds.
Server Shutdown in 25 seconds.
Server Shutdown in 20 seconds.
Server Shutdown in 15 seconds.
Server Shutdown in 10 seconds.
Server Shutdown in 5 seconds.
Server Shutdown in 4 seconds.
Server Shutdown in 3 seconds.
Server Shutdown in 2 seconds.
Server Shutdown in 1 seconds.
Server Shutdown.


Sorry for saying "My code is better!" and hijacking your topic...

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 6:11 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Ill get my revenge when I have time in this topic ;)

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 6:27 pm 
Offline
Regular

Joined: Mon Jun 12, 2006 10:10 pm
Posts: 68
I just realized GSD did the same thing as I did, only he did it really badly and used a bunch of "if" statements.

Bad GSD! Bad!

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 6:52 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
pingu wrote:
I just realized GSD did the same thing as I did, only he did it really badly and used a bunch of "if" statements.

Bad GSD! Bad!


You scammer, stealing code ;)

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 7:11 pm 
Offline
Regular

Joined: Mon Jun 12, 2006 10:10 pm
Posts: 68
William wrote:
pingu wrote:
I just realized GSD did the same thing as I did, only he did it really badly and used a bunch of "if" statements.

Bad GSD! Bad!


You scammer, stealing code ;)


Eh, no...

It's like this in Elysium (that means GSD coded it):
Code:
Static Secs As Long

    If Secs <= 0 Then Secs = 30
    ShutdownTime.Caption = "Shutdown: " & Secs & " Seconds"

    If Secs = 30 Then Call TextAdd(frmServer.txtText(0), "Automated Server Shutdown in " & Secs & " seconds.", True)
    If Secs = 30 Then Call GlobalMsg("Server Shutdown in " & Secs & " seconds.", BrightBlue)
    If Secs = 25 Then Call GlobalMsg("Server Shutdown in " & Secs & " seconds.", BrightBlue)
    If Secs = 20 Then Call GlobalMsg("Server Shutdown in " & Secs & " seconds.", BrightBlue)
    If Secs = 15 Then Call GlobalMsg("Server Shutdown in " & Secs & " seconds.", BrightBlue)
    If Secs = 10 Then Call GlobalMsg("Server Shutdown in " & Secs & " seconds.", BrightBlue)
    If Secs < 6 Then
        Call GlobalMsg("Server Shutdown in " & Secs & " seconds.", BrightBlue)
    End If
    Secs = Secs - 1

    If Secs <= 0 Then
        tmrShutdown.Enabled = False
        Call DestroyServer
    End If


Terrible method...

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:10 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Yep it is. Whats this in your other post:

Code:
If Secs Mod 5 = 0 Or Secs <= 5 Then


Whats "Mod 5" ?? LoL

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:16 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
Mod returns the remainder, so Secs Mod 5 means if it is a perfect interval of 5, such as 5, 10, 15, 20, etc.

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:26 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Spodi wrote:
Mod returns the remainder, so Secs Mod 5 means if it is a perfect interval of 5, such as 5, 10, 15, 20, etc.


Okay, I need to go to my math classes, cause you lost me at remainder. Although I from sweden, so don't judge me ;)

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Last edited by William on Sat Sep 23, 2006 8:27 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:27 pm 
Offline
Regular

Joined: Mon Jun 12, 2006 10:10 pm
Posts: 68
It's simply the "%" operation in most other languages.

EDIT:

Saw your post.

9 / 5 = 2 with 4 left over.

"Mod" simply calculates what is left over. If 0 is left over, it's a perfect divide.

_________________
Image


Last edited by pingu on Sat Sep 23, 2006 8:29 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:27 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
pingu wrote:
It's simply the "%" operation in most other languages.

Okay, so that means Im stupid since I still dont understand it. WTG William! The "Secs" variable doesnt change, so why is there a need for Mod 5?

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:30 pm 
Offline
Regular

Joined: Mon Jun 12, 2006 10:10 pm
Posts: 68
William wrote:
pingu wrote:
It's simply the "%" operation in most other languages.

Okay, so that means Im stupid since I still dont understand it. WTG William! The "Secs" variable doesnt change, so why is there a need for Mod 5?


Secs does change. Every second it is lowered by 1.

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:32 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Yes, but in that if statement.

Code:
If Secs =


Should not change by adding Mod 5.

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:32 pm 
Offline
Knowledgeable
User avatar

Joined: Sun May 28, 2006 10:07 pm
Posts: 327
Location: Washington
MSDN Help Library wrote:
Mod Operator

Used to divide two numbers and return only the remainder.

Syntax

result = number1 Mod number2

The Mod operator syntax has these parts:

Part Description
result Required; any numeric variable.
number1 Required; any numeric expression.
number2 Required; any numeric expression.


Remarks

The modulus, or remainder, operator divides number1 by number2 (rounding floating-point numbers to integers) and returns only the remainder as result. For example, in the followingexpression, A (result) equals 5.

A = 19 Mod 6.7

Usually, the data type of result is a Byte, Byte variant, Integer, Integer variant, Long, or Variant containing a Long, regardless of whether or not result is a whole number. Any fractional portion is truncated. However, if any expression is Null, result is Null. Any expression that is Empty is treated as 0.


[Edited because copying/pasting the MSDN Help removed some spaces.. :P]


Last edited by Verrigan on Sat Sep 23, 2006 8:37 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:36 pm 
Offline
Regular

Joined: Mon Jun 12, 2006 10:10 pm
Posts: 68
William wrote:
Yes, but in that if statement.

Code:
If Secs =


Should not change by adding Mod 5.


Secs is "Static", meaning it acts just like a global variable. You might not get that part.

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:36 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Now I understand :)

PingusIQ = 100 Mod 5

Which means it is 20 :P

Well anyway, that should be correct, but this one yeah ;)

PingusDadsShoeSize = 2150 Mod 37.8

= 56,878306878306878306878306878307

= 55 ???? noo,, I dont think I understand now.. DAMMIT!

EDIT: I know what static is, dont insult me.. Im not retarded :P Just not the theory of Mod

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:39 pm 
Offline
Knowledgeable
User avatar

Joined: Sun May 28, 2006 10:07 pm
Posts: 327
Location: Washington
William wrote:
PingusIQ = 100 Mod 5

Which means it is 20 :P


Actually, 100 Mod 5 = 0, since 100 / 5 = 20 with 0 as a remainder. (Mod just returns the remainder)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:42 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Verrigan wrote:
William wrote:
PingusIQ = 100 Mod 5

Which means it is 20 :P


Actually, 100 Mod 5 = 0, since 100 / 5 = 20 with 0 as a remainder. (Mod just returns the remainder)


So if the outcome is a whole number, its always zero? And elseif its something else like 67, it would be 70 ? :oops:

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:44 pm 
Offline
Knowledgeable
User avatar

Joined: Sun May 28, 2006 10:07 pm
Posts: 327
Location: Washington
99 Mod 5 would be 4 (99 / 5 = 19 with 4 remaining)
98 Mod 5 would be 3
97 Mod 5 would be 2
96 Mod 5 would be 1
95 Mod 5 would be 0 (Because if it divides evenly with no remainder, the remainder is zero)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:46 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
Verrigan wrote:
99 Mod 5 would be 4 (99 / 5 = 19 with 4 remaining)
98 Mod 5 would be 3
97 Mod 5 would be 2
96 Mod 5 would be 1
95 Mod 5 would be 0 (Because if it divides evenly with no remainder, the remainder is zero)


99 / 5 = 19,8 which means 0.8 remaing? Where do you get the 4 from?

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:49 pm 
Offline
Knowledgeable
User avatar

Joined: Sun May 28, 2006 10:07 pm
Posts: 327
Location: Washington
I knew that's what it was. :) You don't divide the number to decimal format. You use only whole numbers.. So if you get to the end, you will have a remainder. (My son learned this in 3rd/4th grade.. so 8 or 9 yrs old..)

The remainder is what is left over... so:

99 / 5 = 19 and 4/5 (4 being the numerator, and 5 being the denominator, since we were dividing by 5) The 'Remainder' is the numerator before you take it all the way to decimal form.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:49 pm 
Offline
Regular

Joined: Mon Jun 12, 2006 10:10 pm
Posts: 68
Look, I managed to think up a formula to help you.

If you do:
Num1 Mod Num2


It translates to:
Num1 - (Num2 * Int(Num1 / Num2))

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 8:56 pm 
Offline
Community Leader
User avatar

Joined: Mon May 29, 2006 1:00 pm
Posts: 2538
Location: Sweden
Google Talk: johansson_tk@hotmail.com
pingu wrote:
Look, I managed to think up a formula to help you.
If you do:
Num1 Mod Num2

It translates to:
Num1 - (Num2 * Int(Num1 / Num2))


That I understand. But isnt there something called: what you dont know doesn't hurt you.

And to translate that into a coding statement.

What you can't code correctly, program around it, if you can't program around it: dig a hole, lay down, and beg for someone to fill the hole.

Discussion Closed. I still don't understand fully, but I don't want to. Just so everybody know, Im a "A" student in Mathematics (studying on IB).

_________________
I'm on Facebook!My Youtube Channel Send me an email
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 10:02 pm 
Offline
Regular

Joined: Mon Jun 12, 2006 10:10 pm
Posts: 68
Would you mind not flipping out on us? This isn't about your grade in math, it's about understanding a very useful operation that you will need for programming in any language.

Okay, I'll try once more to explain, but I'll try to jam everything into one post.

Don't get intimidated because this operator is text instead of a symbol. It doesn't make much sense because it isn't a function, but an operator. I'm going to use the "@" symbol instead of "Mod" (or "%", because that get's confused with percentage). Got it?

So, sample problem number 1 goes like this:
13 @ 5 = ?

Now, take it in steps. Find out what "13 / 5" equals. It's 2.6, but there is a nasty decimal at the end. We don't want him so we round down to 2. Now we need to multiply this 2 by the number we divided by. Normally, this would give you the same number you started with (13), but because we rounded down, it won't.

5 * 2 = 10

We now have 10. This is telling us that 10 is the highest number below 13 that can be divided by 5 evenly. Knowing that, we just compare 10 and 13.

13 - 10 = 3

3 is our answer. The remainder of a division problem is the difference between the closest perfect divide (that means that it doesn't have a decimal answer) and the number we started with.


I don't know how you learn, so I'm going to try it in terms of fractions.

67 @ 10 = ?

Let's divide using the calculator first.

67 / 10 = 6.7

In this method, we don't throw the decimal out yet. I've used "10" to make this much easier to do. Split the number according to the space right before the decimal.

So, we have:

6

And

.7

We need to figure out what .7 is in terms of something over 10 (If it were 67 @ 8, we'd figure it out over 8 instead. Yhis rule applies for all problems, not just 10 and 8!)

x / 10 = .7

Simple algebra here. Multiply both sides by 10 and you get:

x = 7

Guess what? The answer is 7. If we were in school and had to divide and find that remainder, 6 would be the answer (67 / 10 rounded down) and 7 would be the remainder (67 @ 10).


I hope I kind of help. It's easiest to use mod with 10, because it works perfectly.

85 @ 10 = 5
42 @ 10 = 2
70 @ 10 = 0

But, as I showed...

30 @ 5 = 0
29 @ 5 = 4
28 @ 5 = 3
27 @ 5 = 2
26 @ 5 = 1
25 @ 5 = 0

You'll get used to it. I do it in my head a slightly different way. I round up instead and then subtract the other way, but they both work.

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 23, 2006 10:31 pm 
Offline
Knowledgeable
User avatar

Joined: Mon Jul 24, 2006 2:04 pm
Posts: 339
He's just trying to help you, William...

Especially if you're taking math, you should know how to do this. Remainders are something you deal with when you first learn division in elementary school. If you dont know it now, you are going to be screwed later on if you ever need to use it again.

And grades only show how much you study what is being taught at the time, not how good you are at the subject.

_________________
NetGore Free Open Source MMORPG Maker


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 44 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group