osdever

ЕБАТЬ ПИЗДЕЦ ЖОПА

Jun 2nd, 2020
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.13 KB | None | 0 0
  1. using NFSScript;
  2. using NFSScript.Core;
  3. using NFSScript.Math;
  4. using NFSScript.MW;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12.  
  13. namespace MW_Online
  14. {
  15.     public static class MsgWorker
  16.     {
  17.         public static StreamWriter writer = new StreamWriter("superlog.txt");
  18.         public static void StartWorker()
  19.         {
  20.             new Thread(msgWork).Start();
  21.         }
  22.         private static void msgWork()
  23.         {
  24.             try
  25.             {
  26.                 Connection.srReceiver = new StreamReader(Connection.tcpServer.GetStream());
  27.                 Log.Print("MW-Online", "Accepting messages from server!");
  28.                 while (true)
  29.                 {
  30.                     try
  31.                     {
  32.                         string msg = Privatcom_Basic_Server.Base64.Decrypt(Connection.srReceiver.ReadLine()).Replace("~n~", "\n");
  33.  
  34.                         writer.WriteLine(msg);
  35.                         writer.Flush();
  36.                         //Llog("MW-Online", "From server: " + msg);
  37.                         if (msg.StartsWith("SetAI#"))
  38.                         {
  39.                             string[] g = msg.Split('#');
  40.                             int mem = int.Parse(g[1]);
  41.                             string t = g[2];
  42.                         }
  43.                         if (msg.StartsWith("ShowUpdateForm"))
  44.                         {
  45.                             new UpdateForm().ShowDialog();
  46.                         }
  47.                         if (msg.StartsWith("SetPos#"))
  48.                         {
  49.                             string[] s = msg.Split('#');
  50.                             // x1#y2#z3
  51.                             float x = float.Parse(s[1]);
  52.                             float y = float.Parse(s[2]);
  53.                             float z = float.Parse(s[3]);
  54.  
  55.  
  56.  
  57.                             StreamWriter wr = new StreamWriter("TRACKS\\HotPositionL2RA.HOT");
  58.                             wr.Write(String.Format("HOTPOSITION: {0}, {1}, {2} Angle = 0xcfec Speed = {3}", x, y, z, 0));
  59.                             wr.Flush();
  60.                             wr.Close();
  61.                             wr.Dispose();
  62.  
  63.                             GameMemory.memory.WriteInt32((IntPtr)0x9B090C, 0x01);
  64.                         }
  65.                         if (msg.StartsWith("ShowListDialog#"))
  66.                         {
  67.                             string[] s = msg.Split('#');
  68.                             // s[1] = response
  69.                             // s[2] = line~n~line2~n~line3 = lines
  70.                             GameDialog.MenuResponse = s[1];
  71.                             GameDialog.MenuIdx = 0;
  72.                             GameDialog.MenuText = s[2].Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
  73.                             GameDialog.ShowMenu();
  74.  
  75.                         }
  76.                         if (msg.StartsWith("Disconnect"))
  77.                         {
  78.                             Connection.CloseConnection();
  79.                             GameDialog.ShowStableDialog(0, "Disconnected...");
  80.  
  81.                         }
  82.                         if (msg.StartsWith("ShowDialog#"))
  83.                         {
  84.                             string[] s = msg.Split('#');
  85.                             // s[0] = ShowDialog
  86.                             // s[1] = Type. Ex: 1
  87.                             // s[2] = Text.
  88.                             int type = int.Parse(s[1]);
  89.                             string text = s[2];
  90.                             GameDialog.ShowStableDialog(type, text);
  91.                         }
  92.                         if (msg.StartsWith("ShowText#"))
  93.                         {
  94.                             string[] s = msg.Split('#');
  95.                             // s[0] = ShowTtext
  96.                             // s[1] = Text
  97.                             string text = s[1];
  98.                             UI.ShowTextScreenMessage(text);
  99.                         }
  100.                         if (msg.StartsWith("PlayerUpdate#") && !Sync.PauseSync)
  101.                         {
  102.                             writer.WriteLine(msg);
  103.                             writer.Flush();
  104.                             string[] s = msg.Split('#');
  105.                             // PlayerUpdate0#id1#posx2#posy3#posz4#rotx5#roty6#rotz7
  106.                             int player_id = int.Parse(s[1]);
  107.                             float posx = float.Parse(s[2]);
  108.                             float posy = float.Parse(s[3]);
  109.                             float posz = float.Parse(s[4]);
  110.                             float rotx = float.Parse(s[5]);
  111.                             float roty = float.Parse(s[6]);
  112.                             float rotz = float.Parse(s[7]);
  113.                             float rotw = float.Parse(s[8]);
  114.                             float speedx = float.Parse(s[9]);
  115.                             float speedy = float.Parse(s[10]);
  116.                             float spn = float.Parse(s[11]);
  117.                             if (!float.IsNaN(posx) && !float.IsNaN(posy) && !float.IsNaN(posz) && !float.IsNaN(rotx) && !float.IsNaN(roty) && !float.IsNaN(rotz) && !float.IsNaN(speedx) && !float.IsNaN(speedy) && !float.IsNaN(spn))
  118.                             {
  119.                                 //Llog("MW-Online", "Updating player ID: " + player_id);
  120.                                 // Llog("MW-Online", String.Format("PosX: {0}, PosY = {1}, PosZ = {2}", posx, posy, posz));
  121.                                 //Llog("MW-Online", String.Format("RotX: {0}, RotY = {1}, RotZ = {2}", rotx, roty, rotz));
  122.  
  123.  
  124.                                // PosC.Set(44 * 4 * player_id, posx, posz);
  125.                                 GameMemory.memory.WriteFloat((IntPtr)MWAddresses.PlayerAddrs.STATIC_PLAYER_POS_X + 44 * 4 * player_id, posx);
  126.                                 //GameMemory.memory.WriteFloat((IntPtr)MWAddresses.PlayerAddrs.STATIC_PLAYER_POS_Y + 44 * 4 * player_id, 0);
  127.                                 GameMemory.memory.WriteFloat((IntPtr)MWAddresses.PlayerAddrs.STATIC_PLAYER_POS_Z + 44 * 4 * player_id, posz);
  128.                                 //GameMemory.memory.WriteFloat((IntPtr)MWAddresses.PlayerAddrs.STATIC_PLAYER_SPEED + 44 * 4 * player_id, spd);
  129.                                 GameMemory.memory.WriteFloat((IntPtr)MWAddresses.PlayerAddrs.STATIC_PLAYER_X_ROT + 44 * 4 * player_id, rotx);
  130.                                 GameMemory.memory.WriteFloat((IntPtr)MWAddresses.PlayerAddrs.STATIC_PLAYER_Y_ROT + 44 * 4 * player_id, roty);
  131.                                 GameMemory.memory.WriteFloat((IntPtr)MWAddresses.PlayerAddrs.STATIC_PLAYER_Z_ROT + 44 * 4 * player_id, rotz);
  132.                                 GameMemory.memory.WriteFloat((IntPtr)MWAddresses.PlayerAddrs.STATIC_PLAYER_W_ROT + 44 * 4 * player_id, rotw);
  133.                                 GameMemory.memory.WriteFloat((IntPtr)0x9386F0 + 44 * 4 * player_id, speedx);
  134.                                 GameMemory.memory.WriteFloat((IntPtr)0x9386E8 + 44 * 4 * player_id, speedy);
  135.                                 GameMemory.memory.WriteFloat((IntPtr)NewAddresses.SPIN + 44 * 4 * player_id, spn);
  136.                             }
  137.                         }
  138.                         if(msg.StartsWith("MeetUp#"))
  139.                         {
  140.                             string[] s = msg.Split('#');
  141.                             UI.ShowTextScreenMessage(String.Format("MEET UP^^{0}^Drive there and evade the pursuit!", s[4]));
  142.                         }
  143.                         if (msg.StartsWith("911Call")) //Server wants to play the pursuit :D
  144.                         {
  145.                             Function.Call(MWFunctions.SHOW_RACE_COUNTDOWN);
  146.                             Thread.Sleep(4000);
  147.                             Function.Call(MWFunctions.FORCE_PURSUIT_START, 50, 5);
  148.                         }
  149.                     }
  150.                     catch (Exception ex) { string m = String.Format("Connection error: {0}", ex.Message); Log.Print("MW-Online", m); GameDialog.ShowStableDialog(0, m); Connection.CloseConnection(); break; }
  151.                 }
  152.             }
  153.             catch { }
  154.         }
  155.        
  156.     }
  157. }
Add Comment
Please, Sign In to add comment