time problem.

05/05/2013 19:07 LordGragen.#1
first of all i want to say that i know this is not the best way, its for testing.

i created a code which will use this effect on you every 5 sec, and idk whats wrong but it keep using every 60 sec = 1min.

i rly dont understand why? here is the code

Code:
                            if (DateTime.Now.Second <= 05 && DateTime.Now.Second <= 00)
                            {
                                if (client.Entity.Level == 140)
                                {

                                    _String str = new _String(true);
                                    str.UID = client.Entity.UID;
                                    str.TextsCount = 1;
                                    str.Type = _String.Effect;
                                    str.Texts.Add("break_start");
                                    client.SendScreen(str, true);

                                }
                            }

any idea why?
05/05/2013 19:46 Spirited#2
Stop asking for help in that manor. It really bugs me. This isn't code "just for testing", this is a feature you've been trying to program for weeks now and you need programming help because you don't know what you're doing. There's a clear difference and if you want programming help, you need to say so; otherwise, you're just going to confuse people. Stop being so defensive, and let people help. There's no lost pride in asking for help, but pretending you're something you're not is just going to cause even more issues for you. The problem is probably in the loop you put it in; and as I said previously, this is a really bad way of doing this when you could just make a new status type in the client. This is just going to add another layer of stress on your server.
05/05/2013 20:10 LordGragen.#3
what are you talking about i already made that [Only registered and activated users can see links. Click Here To Register...]

and if i made a thread of cores i am asking for help.

i only made it coz idk why it was looping and since i didn't know why it interested me to ask.
05/05/2013 21:37 shadowman123#4
dude u have been asking Really Stupid Question, all u want to is to be spoon feeded which i wont Provide .. Help Urself
05/05/2013 21:58 Smaehtin#5
Quote:
Originally Posted by LordGragen. View Post
what are you talking about i already made that [Only registered and activated users can see links. Click Here To Register...]

and if i made a thread of cores i am asking for help.

i only made it coz idk why it was looping and since i didn't know why it interested me to ask.
Wow, sick code bro!
05/05/2013 22:24 InfamousNoone#6
if you're casting Level, which is of an integer type, to an integer type, to compare with another integer which is a constant, you're doing it wrong, or you're Korv' from like 6 years ago (BA DA DUM! -- hoping Korv' sees this and gets a small laugh out of walking down memory lane, haha)
05/05/2013 22:49 LordGragen.#7
did korv did the same mistake? XD
05/06/2013 07:17 Spirited#8
Well, let's step through your code, shall we? (Or of the code you posted - nobody spoon feed him on this one). So what do you think is wrong with the segment of code you posted? After reading it, do you believe the problem is with this code, or do you believe it's correct?
05/06/2013 13:51 LordGragen.#9
well i think it should be correct because thats how you guys told me to make it.

i made a new flag, i added the effect on client. and thats it
05/06/2013 18:36 Spirited#10
Quote:
Originally Posted by LordGragen. View Post
well i think it should be correct because thats how you guys told me to make it.

i made a new flag, i added the effect on client. and thats it
After reading it yourself though, do you understand it and do you feel that it should be correct?
05/06/2013 18:59 Super Aids#11
Why not just do this?
Code:
void UseEffect()
{
while (true)
{
	if (client.Entity.Level == 140)
	{
		_String str = new _String(true);
		 str.UID = client.Entity.UID;
		str.TextsCount = 1;
		str.Type = _String.Effect;
		str.Texts.Add("break_start");
		client.SendScreen(str, true);
	 }
	System.Threading.Thread.Sleep(5000);
}
}
05/06/2013 19:11 LordGragen.#12
@fang i feel like its correct.

@Super Aids
well lets say 200 people are online and 140, wont that hurt the server using the edit on 200 people evey 5 sec?
05/06/2013 19:29 _DreadNought_#13
Find out for yourself, would only take a line of two of code to run that 10 times, take an average & * by 200.
05/06/2013 20:17 Super Aids#14
Rather than running that for every player then run a loop that sleeps every 5 sec that does it. Or make some proper system implementation for such thing instead of using Trinitys source.
05/06/2013 20:38 pro4never#15
Quote:
Originally Posted by Super Aids View Post
Rather than running that for every player then run a loop that sleeps every 5 sec that does it. Or make some proper system implementation for such thing instead of using Trinitys source.
Keep in mind that this method would have to be run as its own thread because if you use .Sleep(x) from say a command or item, you just freeze the entire server for that amount of time causing mass lag.