Advertisement
XConquer

5990 Quiz Packet

Apr 29th, 2022
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. #region QuizShow (2068)
  2. case 2068:
  3. {
  4. const byte GiveAwaser = 3, Remove = 8;
  5. byte Typ = packet[4];
  6. var quizShow = Kernel.QuizShow;
  7. switch (Typ)
  8. {
  9. case GiveAwaser://give right question
  10. {
  11. if (quizShow.Open)
  12. {
  13. if (client.Quiz == null)
  14. client.Quiz = quizShow.RegisteredUsers[client.Entity.UID];
  15.  
  16. if (client.Quiz == null) break;
  17.  
  18. client.Quiz.Timer += (ushort)quizShow.NewQuestionTime;
  19. byte answer = packet[8];
  20. if (answer > 4) break;
  21. bool right = answer == quizShow.CurrentQuestion.AnswerRight;
  22.  
  23. client.Quiz.Answered = true;
  24. ulong pts = 300;
  25. if (right)
  26. {
  27. pts = (byte)(quizShow.RightAnswerReward + quizShow.TimeLimit - quizShow.NewQuestionTime);
  28.  
  29. client.Quiz.RightQuestion = 1;
  30. client.Quiz.Points += pts;
  31. client.Entity.QuizPoints += pts;
  32. client.Entity.TreasuerPoints += 1;
  33. }
  34. else
  35. {
  36. pts = 300;
  37.  
  38. client.Quiz.RightQuestion = 2;
  39. client.Quiz.Points += pts;
  40. client.Entity.QuizPoints += pts;
  41. }
  42. client.IncreaseExperience(client.ExpBall / 300 * pts, false);
  43.  
  44. if (quizShow.FirstQuestion)
  45. {
  46. QuizRank rnk = new QuizRank();
  47. rnk.GiveRight = client.Quiz.RightQuestion;
  48. rnk.MyPoints = (ushort)client.Quiz.Points;
  49. rnk.MyRank = 0;
  50. rnk.MyTime = client.Quiz.Timer;
  51. rnk.Type = QuizShowTypes.SendTop;
  52. client.Send(rnk.ToArray());
  53. }
  54. }
  55. break;
  56. }
  57. case Remove:
  58. {
  59. if (quizShow.Open)
  60. quizShow.RemovePlayer(client);
  61. break;
  62. }
  63. }
  64. break;
  65. }
  66. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement