I changed like 2-3 things from false to true and it worked but when i restarted server then tried it didn't work again. Anyone know why? (source 5165)
Quote:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NewestCOServer.Features
{
public class QuizShow
{
public static Dictionary<ushort, Question> AllQuestions = new Dictionary<ushort, Question>();
public static Dictionary<ushort, Question> Questions = new Dictionary<ushort, Question>();
static System.Timers.Timer Timer;
public static ushort QuestionNO = 0;
public static QuizShowScore[] Scores = new QuizShowScore[500];
public static bool QuizON = false;
public static bool QuizON1 = true;
static List<int> Container;
public static void Start()
{
QuizON = true;
Random Rand = new Random();
Container = new List<int>();
for(int x = 0; x < 20;x++)
{
Again:
int Gen = Rand.Next(0, 83);
if (!Container.Contains(Gen))
{
Question Q = (Question)AllQuestions[(ushort)Gen];
Answer[] RealAnswers = new Answer[4];
bool[] Set = new bool[4];
for (int i = 0; i < 4; i++)
{
int e = Rand.Next(0, 4);
while(Set[e])
e = Rand.Next(0, 4);
RealAnswers[i] = Q.Answers[e];
Set[e] = true;
}
Q.Answers = RealAnswers;
Questions.Add((ushort)x, Q);
Container.Add(Gen);
}
else
goto Again;
}
Timer = new System.Timers.Timer();
Timer.Interval = 30000;
Timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
foreach (NewestCOServer.Game.Character Char in NewestCOServer.Game.World.H_Chars.Values)
{
Char.MyClient.AddSend(Packets.QuizShowStart((ushor t)Questions.Count));
Char.QuizShowInfo = new Info();
}
Scores = new QuizShowScore[500];
for (int x = 0; x < 501; x++)
{ try { Scores[x] = new QuizShowScore(); } catch { continue; } }
Program.MainQuizShowInfo = new MainInfo();
Juststarted = true;
QuestionNO = 0;
Timer.Start();
Timer.AutoReset = true;
}
public static void Stop()
{
Juststarted = false;
QuizON = true;
Timer.AutoReset = false;
}
static bool Juststarted = false;
static void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (Juststarted)
{
foreach (NewestCOServer.Game.Character Char in NewestCOServer.Game.World.H_Chars.Values)
{
Char.MyClient.AddSend(Packets.QuizQuestion(0, 0, 0, 0, 1, Questions[0], Questions[0].Answers[0], Questions[0].Answers[1], Questions[0].Answers[2], Questions[0].Answers[3]));
Char.QuizShowInfo.LastAnswer = Environment.TickCount;
}
QuestionNO++;
Juststarted = false;
}
else
{
if (Features.QuizShow.Questions.ContainsKey((ushort)( QuestionNO)))
{
ushort nextq = QuestionNO;
nextq++;
foreach (Game.Character Chrr in Game.World.H_Chars.Values)
{
Main.GameClient GC = Chrr.MyClient;
GC.AddSend(Packets.QuizQuestion(GC.MyChar.QuizShow Info.Score, GC.MyChar.QuizShowInfo.Time,
(ushort)(800 * GC.MyChar.QuizShowInfo.Score / 100), 1, nextq, Features.QuizShow.Questions[QuestionNO], Features.QuizShow.Questions[QuestionNO].Answers[0], Features.QuizShow.Questions[QuestionNO].Answers[1], Features.QuizShow.Questions[QuestionNO].Answers[2], Features.QuizShow.Questions[QuestionNO].Answers[3]));
GC.MyChar.QuizShowInfo.LastAnswer = Environment.TickCount;
}
}
else
{
try
{
foreach (Game.Character Chr in Game.World.H_Chars.Values)
{
Chr.MyClient.AddSend(Packets.QuizShowEnd(Chr.Name, Chr.QuizShowInfo.Score, Chr.QuizShowInfo.Time, Chr.QuizShowInfo.Rank, (ushort)(800 * Chr.QuizShowInfo.Score / 100)));
}
Timer.Elapsed -= Timer_Elapsed;
Timer.Stop();
Timer.Dispose();
}
catch { }
QuizON = true;
}
QuestionNO++;
}
}
public class QuizShowScore
{
public uint EntityID = 0;
public uint Score = 0;
}
public class MainInfo
{
public string[] Name;
public ushort[] Time;
public ushort[] Score;
public MainInfo()
{
Name = new string[3];
Time = new ushort[3];
Score = new ushort[3];
Name[0] = "none";
Name[1] = "none";
Name[2] = "none";
Time[0] = 0;
Time[1] = 0;
Time[2] = 0;
Score[0] = 0;
Score[1] = 0;
Score[2] = 0;
}
}
public class Info
{
public int LastAnswer;
public ushort Time;
public ushort Score;
public ushort QNo;
public byte[] Answers;
public ushort Rank;
public Info()
{
LastAnswer = 0;
Time = 0;
Score = 0;
QNo = 1;
Answers = new byte[Questions.Count];
Rank = 0;
}
}
public class Question
{
public string m_Question;
public Answer[] Answers;
public Question(string question, Answer[] answers)
{
m_Question = question;
Answers = answers;
}
public static implicit operator string(Question q)
{
return q.m_Question;
}
}
public class Answer
{
public string m_Answer;
public ushort Points;
public Answer(string answer, ushort points)
{
m_Answer = answer; Points = points;
}
public static implicit operator string(Answer q)
{
return q.m_Answer;
}
}
}
}