Advertisement
sasaa86

admin_tools.c

Dec 17th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.33 KB | None | 0 0
  1. //! channel, from, text, color config class
  2. typedef Param4<int, string, string, string> AdminChatParams;
  3.  
  4. class AdminTool extends VPPModuleManager
  5. {
  6.     protected ref map<string, string> m_AdminList;
  7.     protected ref map<string, vector> m_TPLocations;
  8.     protected ref map<string,    int> m_ExtendedCommands;
  9.  
  10.     protected bool m_FreeCamera;
  11.     protected bool m_IsDebugRunning = false;
  12.  
  13.     protected PlayerBase Admin;
  14.     protected PlayerIdentity identityT;
  15.     protected string PlayerUID;
  16.     protected string GUID;
  17.    
  18.     protected string m_AdminListPath = "$CurrentDir:\\mpmissions\\DayZSurvival.chernarusplus\\ScriptedMods\\";
  19.  
  20.     override void Init()
  21.     {
  22.         Print("AdminTool:: Init():: Loading AdminTool Mods...");
  23.        
  24.         m_AdminList    = new map<string, string>; //UID, name
  25.         m_TPLocations  = new map<string, vector>; //name of town, pos
  26.         m_ExtendedCommands = new map<string,int>; //Command, length
  27.  
  28.         //-----Add Admins from txt-----
  29.         FileHandle AdminUIDSFile = OpenFile(m_AdminListPath + "Admins.txt",FileMode.READ);
  30.         if (AdminUIDSFile != 0)
  31.         {
  32.             string line_content = "";
  33.             while ( FGets(AdminUIDSFile,line_content) > 0 )
  34.             {
  35.                 m_AdminList.Insert(line_content,"null"); //UID , NAME
  36.                 Print("Adding Admin: "+ line_content + " To the Admin List!");
  37.             }
  38.             CloseFile(AdminUIDSFile);
  39.         }
  40.         else {
  41.         Print("Error Loading Admin GUIDS! File Missing");
  42.         }
  43.        
  44.         //Add Towns to TP array
  45.         m_TPLocations.Insert( "Severograd", "8428.0 0.0 12767.1" );
  46.         m_TPLocations.Insert( "Krasnostav", "11172.0 0.0 12314.1" );
  47.         m_TPLocations.Insert( "Mogilevka", "7537.8 0.0 5211.55" );
  48.         m_TPLocations.Insert( "Stary", "6046.94 0.0 7733.97" );
  49.         m_TPLocations.Insert( "Msta", "11322.55 0.0 5463.36" );
  50.         m_TPLocations.Insert( "Vybor", "3784.16 0.0 8923.48" );
  51.         m_TPLocations.Insert( "Gorka", "9514.27 0.0 8863.69" );
  52.         m_TPLocations.Insert( "Solni", "13402.57 0.0 6303.35" );
  53.         m_TPLocations.Insert( "NWAFS", "4540.52 0.0 9645.84" );
  54.         m_TPLocations.Insert( "NWAFC", "4823.43 0.0 10457.16" );
  55.         m_TPLocations.Insert( "NWAFN", "4214.84 0.0 10977.78" );
  56.         m_TPLocations.Insert( "BAF", "4467.61 0.0 2496.14" );
  57.         m_TPLocations.Insert( "NEAF", "11921.43 0.0 12525.55" );
  58.         m_TPLocations.Insert( "ChernoC", "6649.22 0.0 2710.03" );
  59.         m_TPLocations.Insert( "ChernoW", "6374.08 0.0 2361.01" );
  60.         m_TPLocations.Insert( "ChernoE", "7331.70 0.0 2850.03" );
  61.         m_TPLocations.Insert( "ElektroW", "10077.17 0.0 1988.65" );
  62.         m_TPLocations.Insert( "ElektroE", "10553.55 0.0 2313.37" );
  63.         m_TPLocations.Insert( "BerezC", "12319.54 0.0 9530.15" );
  64.         m_TPLocations.Insert( "BerezS", "11991.42 0.0 9116.95" );
  65.         m_TPLocations.Insert( "BerezN", "12823.14 0.0 10078.97" );
  66.         m_TPLocations.Insert( "Svet", "13900.82 0.0 13258.12" );   
  67.         m_TPLocations.Insert( "ZelenoS", "2572.80 0.0 5105.09" );
  68.         m_TPLocations.Insert( "ZelenoN", "2741.48 0.0 5416.69" );
  69.         m_TPLocations.Insert( "Lopatino", "2714.74 0.0 9996.33" );
  70.         m_TPLocations.Insert( "Tisy", "1723.10 0.0 13983.88" );
  71.         m_TPLocations.Insert( "Novaya", "3395.28 0.0 13013.61" );
  72.         m_TPLocations.Insert( "Novy", "7085.73 0.0 7720.85" );
  73.         m_TPLocations.Insert( "Grishino", "5952.15 0.0 10367.71" );
  74.         m_TPLocations.Insert( "Kabanino", "5363.97 0.0 8594.39" );
  75.  
  76.         //Init Commands
  77.         m_ExtendedCommands.Insert("/strip",6);
  78.         m_ExtendedCommands.Insert("/tpm",4);
  79.         m_ExtendedCommands.Insert("/tpp",4);
  80.         m_ExtendedCommands.Insert("/tpto",5);
  81.         m_ExtendedCommands.Insert("/spi",4);
  82.         m_ExtendedCommands.Insert("/spg",4);
  83.         m_ExtendedCommands.Insert("/tpc",4);
  84.         //Sub commands
  85.         m_ExtendedCommands.Insert("/export",7);
  86.         m_ExtendedCommands.Insert("/ammo",1);
  87.         m_ExtendedCommands.Insert("/stamina",1);
  88.         m_ExtendedCommands.Insert("/LoadoutType",1);
  89.         m_ExtendedCommands.Insert("/CustomLoadouts",1);
  90.         m_ExtendedCommands.Insert("/SpawnArmed",1);
  91.         m_ExtendedCommands.Insert("/updateLoadouts",1);
  92.         m_ExtendedCommands.Insert("/freecam",1);
  93.         m_ExtendedCommands.Insert("/debug",1);
  94.         m_ExtendedCommands.Insert("/nighttime",1);
  95.         m_ExtendedCommands.Insert("/daytime",1);
  96.         m_ExtendedCommands.Insert("/godmode",1);
  97.         m_ExtendedCommands.Insert("/heal",1);
  98.         m_ExtendedCommands.Insert("/kill",1);
  99.         m_ExtendedCommands.Insert("/tpalltome",1);
  100.         m_ExtendedCommands.Insert("/killall",1);
  101.         m_ExtendedCommands.Insert("/spawncar",1);
  102.         m_ExtendedCommands.Insert("/savePoint",10);
  103.         m_ExtendedCommands.Insert("/refuel",1);
  104.     }
  105.    
  106.     void AdminTool( DayZSurvival missionServer )
  107.     {
  108.  
  109.     }
  110.    
  111.     void ~AdminTool()
  112.     {
  113.        
  114.     }
  115.    
  116.     override void onUpdate(float timeslice)
  117.     {
  118.        
  119.     }
  120.  
  121.     int TeleportAllPlayersTo(PlayerBase Admin)
  122.     {
  123.         array<Man> players = new array<Man>;
  124.         GetGame().GetPlayers( players );
  125.  
  126.         vector AdminPos;
  127.         AdminPos = Admin.GetPosition();
  128.  
  129.         for ( int i = 0; i < players.Count(); ++i )
  130.         {
  131.             PlayerBase Target = players.Get(i);
  132.             Target.SetPosition( AdminPos );
  133.         }
  134.         return i;
  135.     }
  136.  
  137.     void oSpawnItemFunc(bool ground, PlayerBase player, string ClassName)
  138.     {
  139.         EntityAI item;
  140.         ItemBase itemBs
  141.  
  142.         vector NewPosition;
  143.         vector OldPosition;
  144.  
  145.         if (ground)
  146.         {
  147.             OldPosition = player.GetPosition();
  148.  
  149.             NewPosition[0] = OldPosition[0] + 1.5;
  150.             NewPosition[1] = OldPosition[1] + 0.1;
  151.             NewPosition[2] = OldPosition[2] + 1.5;
  152.  
  153.             item = GetGame().CreateObject( ClassName, NewPosition, false, true );
  154.         }else{
  155.  
  156.             item = player.GetInventory().CreateInInventory( ClassName );
  157.             itemBs = ItemBase.Cast(item);  
  158.             itemBs.SetQuantity(1);
  159.         }
  160.     }
  161.  
  162.     vector SnapToGround(vector pos)
  163.     {
  164.         float pos_x = pos[0];
  165.         float pos_z = pos[2];
  166.         float pos_y = GetGame().SurfaceY( pos_x, pos_z );
  167.         vector tmp_pos = Vector( pos_x, pos_y, pos_z );
  168.         tmp_pos[1] = tmp_pos[1] + pos[1];
  169.  
  170.         return tmp_pos;
  171.     }
  172.  
  173.     ref array<string> CheckCommand(string CommandLine)
  174.     {
  175.         ref array<string> ret = new array<string>;
  176.         string strRplce,mKey;
  177.         int cmdLength;
  178.  
  179.         strRplce = CommandLine;
  180.  
  181.         for (int i = 0; i < m_ExtendedCommands.Count(); ++i)
  182.         {
  183.             mKey      = m_ExtendedCommands.GetKey(i);
  184.             cmdLength = m_ExtendedCommands.Get(mKey);
  185.  
  186.             if (CommandLine.Contains(mKey))
  187.             {
  188.                 strRplce.Replace(mKey + " ","");
  189.                 ret.Insert(mKey); //0 = Command 1 = Data
  190.                 if (strRplce != "")
  191.                 {
  192.                     ret.Insert(strRplce);
  193.                 }
  194.                 return ret;
  195.             }
  196.         }
  197.         return NULL;
  198.     }
  199.  
  200.     //---------------------------------------------------------------------------------
  201.     void RequestHandler( Param request_info )
  202.     {
  203.         AdminChatParams chat_params = AdminChatParams.Cast(request_info);
  204.         if (chat_params)
  205.         {
  206.             array<Man> players = new array<Man>;
  207.             GetGame().GetPlayers( players );
  208.            
  209.             PlayerBase Admin;
  210.             PlayerIdentity AdminIdentity;
  211.             string AdminUID;
  212.  
  213.             PlayerBase selectedPlayer;
  214.             PlayerIdentity selectedIdentity;
  215.             string selectedUID;
  216.            
  217.             string chatLine = chat_params.param3;
  218.             string strMessage;
  219.             Param1<string> Msgparam;
  220.  
  221.             for (int i = 0; i < players.Count(); ++i)
  222.             {
  223.                 if (players.Get(i).GetIdentity().GetName() == chat_params.param2 && m_AdminList.Contains(players.Get(i).GetIdentity().GetPlainId()))
  224.                 {
  225.                     Admin         = players.Get(i);
  226.                     AdminIdentity = Admin.GetIdentity();
  227.                     AdminUID      = AdminIdentity.GetPlainId();
  228.                 }
  229.             }
  230.  
  231.             if (Admin && AdminUID != "")
  232.             {
  233.                 if (chatLine.Contains("/"))
  234.                 {
  235.                     ref array<string> chatData = CheckCommand(chatLine);
  236.                     string cCommand, cData;
  237.                     if (chatData != NULL)
  238.                     {
  239.                         cCommand = chatData.Get(0);
  240.                         cData    = chatData.Get(1);
  241.                     } else { cCommand = "UnknownCommand" }
  242.  
  243.                     switch(cCommand)
  244.                     {
  245.                         case "/savePoint":
  246.                         if (cData == "" || cData == "/savePoint")
  247.                         {
  248.                             Msgparam = new Param1<string>( "Error Adding Point, Please Provide A Name for the Spawn Point." );
  249.                             GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  250.                         }
  251.                         else
  252.                         {
  253.                             ref map<string, map<string,float>> m_SpawnPoints;
  254.                             ref map<string,float> InfoChached;
  255.                             JsonFileLoader<ref map<string, map<string,float>>>.JsonLoadFile("$profile:SpawnPoints.json", m_SpawnPoints);
  256.                        
  257.                             ref map<string,float> PointsInfo = new map<string,float>;
  258.                             vector savePos = Admin.GetPosition();
  259.                             string strsavePos = savePos.ToString();
  260.                             strsavePos.Replace("<","");
  261.                             strsavePos.Replace(">","");
  262.                             strsavePos.Replace(",","");
  263.                             PointsInfo.Insert(strsavePos,900);
  264.                             m_SpawnPoints.Insert(cData,PointsInfo);
  265.                            
  266.                             JsonFileLoader<ref map<string, map<string,float>>>.JsonSaveFile("$profile:SpawnPoints.json", m_SpawnPoints);
  267.                             Msgparam = new Param1<string>( "Added Spawn "+cData +" To the Json!, Point will be useable after restart" );
  268.                             GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  269.                         }
  270.                         break;
  271.  
  272.                         case "/strip":
  273.                                 for ( int a = 0; a < players.Count(); ++a )
  274.                                 {
  275.                                     selectedPlayer = PlayerBase.Cast(  players.Get(a) );
  276.                                     selectedIdentity = PlayerIdentity.Cast(  selectedPlayer.GetIdentity() );
  277.                                     if ( selectedIdentity.GetName() == cData )
  278.                                     {
  279.                                         selectedPlayer.RemoveAllItems();
  280.                                         Msgparam = new Param1<string>( "Player "+cData +" Stripped!" );
  281.                                         GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  282.                                     }
  283.                                 }
  284.                             break;
  285.  
  286.                             case "/tpm":
  287.                                 for ( int zm = 0; zm < players.Count(); ++zm )
  288.                                 {
  289.                                     if ( players.Get(zm).GetIdentity().GetName() == cData )
  290.                                     {
  291.                                         Admin.SetPosition(players.Get(zm).GetPosition());
  292.                                         strMessage = "You were teleported to player " + cData;
  293.                                         Msgparam = new Param1<string>( strMessage );
  294.                                         GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  295.                                     }
  296.                                 }
  297.                             break;
  298.  
  299.                             case "/tpp":
  300.                                 for ( int z = 0; z < players.Count(); ++z )
  301.                                 {
  302.                                     selectedPlayer = PlayerBase.Cast( players.Get(z) );
  303.                                     selectedIdentity = PlayerIdentity.Cast( selectedPlayer.GetIdentity() );
  304.                                     if ( selectedIdentity.GetName() == cData )
  305.                                     {
  306.                                         selectedPlayer.SetPosition(Admin.GetPosition());
  307.  
  308.                                         Msgparam = new Param1<string>( "You were teleported by the admin!" );
  309.                                         GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, selectedIdentity);
  310.                                              
  311.                                         strMessage = "Player " + cData + " was teleported to your location!";
  312.                                         Msgparam = new Param1<string>( strMessage );
  313.                                         GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  314.                                     }
  315.                                 }
  316.                             break;
  317.  
  318.                             case "/tpto":
  319.                                 vector position = "0 0 0";
  320.                                 if (m_TPLocations.Contains(cData))
  321.                                 {
  322.                                     m_TPLocations.Find( cData, position );
  323.  
  324.                                     vector ofixPlayerPos;
  325.                                     ofixPlayerPos[0] = position[0];
  326.                                     ofixPlayerPos[2] = position[2];
  327.  
  328.                                     ofixPlayerPos = SnapToGround( ofixPlayerPos );
  329.  
  330.                                     Admin.SetPosition(ofixPlayerPos);
  331.  
  332.                                     strMessage = "Teleported To Location: " + cData;
  333.                                     Msgparam = new Param1<string>( strMessage );
  334.                                     GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  335.                                 }
  336.                                 else
  337.                                 {
  338.                                     strMessage = "Teleport Failed! Location: " + cData + " Is not on the list!";
  339.                                     Msgparam = new Param1<string>( strMessage );
  340.                                     GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  341.                                 }
  342.                             break;
  343.  
  344.                             case "/spi":
  345.                                 oSpawnItemFunc(false,Admin,cData);
  346.                                 strMessage = "Admin Commands: Item " + cData + " Added in Inventory!";
  347.                                 Msgparam = new Param1<string>( strMessage );
  348.                                 GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  349.                             break;
  350.  
  351.                             case "/spg":
  352.                                 oSpawnItemFunc(true,Admin,cData);
  353.                                 strMessage = "Admin Commands: Item " + cData + " Spawned around you!";
  354.                                 Msgparam = new Param1<string>( strMessage );
  355.                                 GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  356.                             break;
  357.  
  358.                             case "/tpc":
  359.                                 vector tpPos = cData.ToVector();
  360.                                 vector fixPlayerPos;
  361.                                 fixPlayerPos[0] = tpPos[0];
  362.                                 fixPlayerPos[2] = tpPos[2];
  363.  
  364.                                 fixPlayerPos = SnapToGround( fixPlayerPos );
  365.                                 Admin.SetPosition(fixPlayerPos);
  366.  
  367.                                 strMessage = "Teleported to:: " + tpPos;
  368.                                 Msgparam = new Param1<string>( strMessage );
  369.                                 GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  370.                             break;
  371.  
  372.                             case "/export":
  373.                                 if (m_MissionServer.GetModule(AdvancedLoadouts))
  374.                                 {
  375.                                     AdvancedLoadouts.Cast(m_MissionServer.GetModule(AdvancedLoadouts)).ExportInventory(Admin,cData);
  376.                                     Msgparam = new Param1<string>( "LOADOUT EXPORTED!" );
  377.                                     GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  378.                                 }
  379.                                 else
  380.                                 {
  381.                                     Msgparam = new Param1<string>( "LOADOUT EXPORT FAILED! MOD DISABLED!" );
  382.                                     GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  383.                                 }
  384.                             break;
  385.  
  386.                             case "/ammo":
  387.                             EntityAI CurrentWeapon = Admin.GetHumanInventory().GetEntityInHands();
  388.                             if( CurrentWeapon )
  389.                                 {
  390.                                     CurrentWeapon.SetHealth( CurrentWeapon.GetMaxHealth( "", "" ) );
  391.                                     Magazine foundMag = ( Magazine ) CurrentWeapon.GetAttachmentByConfigTypeName( "DefaultMagazine" );
  392.                                     if( foundMag && foundMag.IsMagazine())
  393.                                     {
  394.                                         foundMag.ServerSetAmmoMax();
  395.                                     }
  396.                                                                        
  397.                                     Object Suppressor = ( Object ) CurrentWeapon.GetAttachmentByConfigTypeName( "SuppressorBase" );
  398.                                     if( Suppressor )
  399.                                     {
  400.                                         Suppressor.SetHealth( Suppressor.GetMaxHealth( "", "" ) );
  401.                                     }
  402.                                     string displayName = CurrentWeapon.ConfigGetString("displayName");
  403.  
  404.                                     Msgparam = new Param1<string>( "Weapon " + displayName + "Reloaded and Repaired" );
  405.                                     GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  406.                                 }
  407.                             break;
  408.  
  409.                             case "/updateLoadouts":
  410.                                 if (m_MissionServer.GetModule(AdvancedLoadouts))
  411.                                 {
  412.                                     AdvancedLoadouts.Cast(m_MissionServer.GetModule(AdvancedLoadouts)).ConstructLoadouts(true);
  413.                                     Msgparam = new Param1<string>( "LOADOUTS UPDATED!" );
  414.                                     GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  415.                                 }
  416.                                 else
  417.                                 {
  418.                                     Msgparam = new Param1<string>( "LOADOUT UPDATE FAILED! MOD DISABLED!" );
  419.                                     GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  420.                                 }
  421.                             break;
  422.  
  423.                             case "/freecam":
  424.                                  PlayerBase pBody = Admin;
  425.  
  426.                                  if (m_FreeCamera)
  427.                                     {
  428.                                         GetGame().SelectPlayer(Admin.GetIdentity(), pBody);
  429.                                         m_FreeCamera = false;
  430.                                         Msgparam = new Param1<string>( "Exiting FreeCam!" );
  431.                                         GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  432.                                     }
  433.                                     else
  434.                                     {
  435.                                         GetGame().SelectPlayer(Admin.GetIdentity(), NULL);
  436.                                         GetGame().SelectSpectator(Admin.GetIdentity(), "freedebugcamera", Admin.GetPosition());
  437.                                         m_FreeCamera = true;
  438.                                         Msgparam = new Param1<string>( "FreeCam Spawned!" );
  439.                                         GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  440.                                     }
  441.  
  442.                             break;
  443.  
  444.                             case "/debug":
  445.                                   if (m_IsDebugRunning)
  446.                                      {
  447.                                         Msgparam = new Param1<string>( "DeBug Monitor (Status Monitor) Disabled!" );
  448.                                         GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  449.                                         GetGame().SetDebugMonitorEnabled(0);
  450.                                         m_IsDebugRunning = false;
  451.                                      }
  452.                                      else
  453.                                      {
  454.                                         Msgparam = new Param1<string>( "DeBug Monitor (Status Monitor) Enabled!" );
  455.                                         GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  456.                                         GetGame().SetDebugMonitorEnabled(1);
  457.                                         m_IsDebugRunning = true;
  458.                                      }
  459.  
  460.                             break;
  461.  
  462.                             case "/nighttime":
  463.                                 GetGame().GetWorld().SetDate( 1988, 9, 23, 22, 0 );
  464.                                 Msgparam = new Param1<string>( "NIGHT TIME!!" );
  465.                                 GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  466.                             break;
  467.  
  468.                             case "/daytime":
  469.                                 GetGame().GetWorld().SetDate( 1988, 5, 23, 12, 0 );
  470.                                 Msgparam = new Param1<string>( "DAY TIME!!" );
  471.                                 GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  472.                             break;
  473.  
  474.                             /*case "/godmode":
  475.                                 string GmodeCheck;
  476.                                 g_Game.GetProfileString("SafeZoneStatus"+GUID,GmodeCheck);
  477.                                 if (GmodeCheck == "true")
  478.                                    {
  479.                                         g_Game.SetProfileString("SafeZoneStatus"+GUID,"false");
  480.                                         Msgparam = new Param1<string>( "God Mode DISABLED!" );
  481.                                         GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  482.                                    }
  483.                                    else
  484.                                    {
  485.                                         g_Game.SetProfileString("SafeZoneStatus"+GUID,"true");
  486.                                         Msgparam = new Param1<string>( "God Mode ENABLED!" );
  487.                                         GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  488.                                    }
  489.  
  490.                             break;
  491.                             */
  492.                             case "/heal":
  493.                                 Msgparam = new Param1<string>( "Player Healed!" );
  494.                                 GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  495.                                 Admin.SetHealth( Admin.GetMaxHealth( "", "" ) );
  496.                                 Admin.SetHealth( "","Blood", Admin.GetMaxHealth( "", "Blood" ) );
  497.                                 Admin.GetStatHeatComfort().Set(0);
  498.                                 Admin.GetStatTremor().Set(0);
  499.                                 Admin.GetStatWet().Set(0);
  500.                                 Admin.GetStatEnergy().Set(20000);
  501.                                 Admin.GetStatWater().Set(5000);
  502.                                 Admin.GetStatStomachEnergy().Set(20000);
  503.                                 Admin.GetStatStomachWater().Set(5000);
  504.                                 Admin.GetStatStomachVolume().Set(0);
  505.                                 Admin.GetStatDiet().Set(2500);
  506.                                 Admin.GetStatSpecialty().Set(1);
  507.                                 Admin.SetBleedingBits(0);
  508.                             break;
  509.  
  510.                             case "/kill":
  511.                                   Admin.SetHealth(0);
  512.                             break;
  513.                                                                
  514.                             case "/tpalltome":
  515.                                  int tpCount = TeleportAllPlayersTo(Admin);
  516.                                  string msgc = "All " + tpCount.ToString() + " Players Teleported to my POS!";
  517.                                  Msgparam = new Param1<string>( msgc );
  518.                                  GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  519.                             break;
  520.                                                                
  521.                             case "/killall":
  522.                                 for ( int ig = 0; ig < players.Count(); ++ig )
  523.                                 {
  524.                                     PlayerBase Target = players.Get(ig);
  525.                                     if ( Target.GetIdentity() != AdminIdentity )
  526.                                     {
  527.                                         Target.SetHealth(0);                       
  528.                                     }
  529.                                 }
  530.                             break;
  531.                            
  532.                             case "/spawncar":
  533.                                 Car MyNiva;
  534.                                 float adminHeading = MiscGameplayFunctions.GetHeadingAngle(Admin);
  535.                                 vector posModifier = Vector(-(3 * Math.Sin(adminHeading)), 0, 3 * Math.Cos(adminHeading));
  536.                                
  537.                                 MyNiva = Car.Cast(GetGame().CreateObject( "OffroadHatchback", Admin.GetPosition() + posModifier, false, true, true ));                 
  538.                                 MyNiva.GetInventory().CreateAttachment("HatchbackHood");
  539.                                 MyNiva.GetInventory().CreateAttachment("HatchbackTrunk");
  540.                                 MyNiva.GetInventory().CreateAttachment("HatchbackDoors_CoDriver");
  541.                                 MyNiva.GetInventory().CreateAttachment("HatchbackWheel");
  542.                                 MyNiva.GetInventory().CreateAttachment("HatchbackWheel");
  543.                                 MyNiva.GetInventory().CreateAttachment("HatchbackWheel");
  544.                                 MyNiva.GetInventory().CreateAttachment("HatchbackWheel");
  545.                                 MyNiva.GetInventory().CreateAttachment("SparkPlug");
  546.                                 MyNiva.GetInventory().CreateAttachment("EngineBelt");
  547.                                 MyNiva.GetInventory().CreateAttachment("CarBattery");
  548.                                
  549.                                 MyNiva.Fill( CarFluid.FUEL, MyNiva.GetFluidCapacity( CarFluid.FUEL ) );
  550.                                 MyNiva.Fill( CarFluid.OIL, MyNiva.GetFluidCapacity( CarFluid.OIL ) );
  551.                                 MyNiva.Fill( CarFluid.BRAKE, MyNiva.GetFluidCapacity( CarFluid.BRAKE ) );
  552.                                 MyNiva.Fill( CarFluid.COOLANT, MyNiva.GetFluidCapacity( CarFluid.COOLANT ) );
  553.                                
  554.                                 Msgparam = new Param1<string>( "Niva spawned." );
  555.                                 GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  556.                             break;
  557.  
  558.                             case "/refuel":
  559.                                 ref array<Object> nearest_objects = new array<Object>;
  560.                                 ref array<CargoBase> proxy_cargos = new array<CargoBase>;
  561.                                 Car toBeFilled;
  562.                                 GetGame().GetObjectsAtPosition ( Admin.GetPosition(), 10, nearest_objects, proxy_cargos );
  563.            
  564.                                 for (i = 0; i < nearest_objects.Count(); i++)
  565.                                 {
  566.                                     if (nearest_objects.Get(i).IsKindOf("CarScript"))
  567.                                     {
  568.                                         toBeFilled = Car.Cast(nearest_objects[i]);
  569.                                         float fuelReq = toBeFilled.GetFluidCapacity( CarFluid.FUEL ) - (toBeFilled.GetFluidCapacity( CarFluid.FUEL ) * toBeFilled.GetFluidFraction( CarFluid.FUEL ));
  570.                                         float oilReq = toBeFilled.GetFluidCapacity( CarFluid.OIL ) - (toBeFilled.GetFluidCapacity( CarFluid.OIL ) * toBeFilled.GetFluidFraction( CarFluid.OIL ));
  571.                                         float coolantReq = toBeFilled.GetFluidCapacity( CarFluid.COOLANT ) - (toBeFilled.GetFluidCapacity( CarFluid.COOLANT ) * toBeFilled.GetFluidFraction( CarFluid.COOLANT ));
  572.                                         float brakeReq = toBeFilled.GetFluidCapacity( CarFluid.BRAKE ) - (toBeFilled.GetFluidCapacity( CarFluid.BRAKE ) * toBeFilled.GetFluidFraction( CarFluid.BRAKE ));
  573.                                         toBeFilled.Fill( CarFluid.FUEL, fuelReq );
  574.                                         toBeFilled.Fill( CarFluid.OIL, oilReq );
  575.                                         toBeFilled.Fill( CarFluid.COOLANT, coolantReq );
  576.                                         toBeFilled.Fill( CarFluid.BRAKE, brakeReq );
  577.                                         Msgparam = new Param1<string>( nearest_objects.Get(i).GetType() + " refueled: " +fuelReq+ "L added, all fluids maxed" );
  578.                                         GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  579.                                     }
  580.                                 }
  581.                             break;
  582.  
  583.                             default:
  584.                                 Msgparam = new Param1<string>( "Error: The following command is Unknown." );
  585.                                 GetGame().RPCSingleParam(Admin, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, AdminIdentity);
  586.                             break;
  587.                     }
  588.                 }
  589.             }
  590.         }
  591.     }
  592. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement