update: 添加玩家复活套装
This commit is contained in:
109
Mod/RespawnEqument/Scripts/CustomRevivalSuit/config.c
Normal file
109
Mod/RespawnEqument/Scripts/CustomRevivalSuit/config.c
Normal file
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* @file config.c
|
||||
* @author 稻草人
|
||||
* @version 1.0
|
||||
* @date 2025-00-01
|
||||
* @copyright Copyright (c) 2025
|
||||
*
|
||||
* @brief This file contains the configuration for the custom revival suit feature.
|
||||
*/
|
||||
static ref CustomRevivalSuitCfg g_CustomRevivalSuitCfg;
|
||||
static ref CustomRevivalSuitCfg GetCustomRevivalSuitCfg()
|
||||
{
|
||||
if ( !g_CustomRevivalSuitCfg )
|
||||
{
|
||||
g_CustomRevivalSuitCfg = new ref CustomRevivalSuitCfg();
|
||||
g_CustomRevivalSuitCfg.loadConfig();
|
||||
}
|
||||
return g_CustomRevivalSuitCfg;
|
||||
}
|
||||
|
||||
class CustomRevivalSuitCfg
|
||||
{
|
||||
protected static string profileDir = "$profile:DcrServerModCfg\\CustomRevivalSuitCfg";
|
||||
protected static string profileName = "\\CustomRevivalSuitCfg.json";
|
||||
protected static string profilePath = profileDir + profileName;
|
||||
|
||||
ref array< ref PlayerRevivalEquipmentData > PlayerRevivalEquipmentDataList;
|
||||
|
||||
void loadConfig()
|
||||
{
|
||||
if ( !FileExist( profilePath ) )
|
||||
makeConfig();
|
||||
|
||||
JsonFileLoader< ref CustomRevivalSuitCfg >.JsonLoadFile( profilePath, this );
|
||||
}
|
||||
|
||||
void makeConfig()
|
||||
{
|
||||
PlayerRevivalEquipmentDataList = new ref array< ref PlayerRevivalEquipmentData >();
|
||||
ref PlayerRevivalEquipmentData playerData = new ref PlayerRevivalEquipmentData( "76561198422667486" );
|
||||
PlayerRevivalEquipmentDataList.Insert( playerData );
|
||||
|
||||
MakeDirectory( "$profile:DcrServerModCfg/" );
|
||||
MakeDirectory( profileDir + "/" );
|
||||
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
void SaveConfig()
|
||||
JsonFileLoader< ref CustomRevivalSuitCfg >.JsonSaveFile( profilePath, this );
|
||||
|
||||
ref PlayerRevivalEquipmentData GetPlayerRevivalEquipmentData( string steamid )
|
||||
{
|
||||
foreach ( ref PlayerRevivalEquipmentData playerData : PlayerRevivalEquipmentDataList )
|
||||
if ( playerData.SteamId == steamid )
|
||||
return playerData;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void RemovePlayerRevivalEquipmentData( string steamid )
|
||||
{
|
||||
foreach ( ref PlayerRevivalEquipmentData playerData : PlayerRevivalEquipmentDataList )
|
||||
{
|
||||
if ( playerData.SteamId == steamid )
|
||||
{
|
||||
PlayerRevivalEquipmentDataList.RemoveItem( playerData );
|
||||
SaveConfig()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PlayerRevivalEquipmentData
|
||||
{
|
||||
string SteamId;
|
||||
|
||||
ref TStringArray Equipments;
|
||||
ref TStringArray ItemList;
|
||||
ref WeaponCfg WeaponData;
|
||||
|
||||
void PlayerRevivalEquipmentData( string steamid )
|
||||
{
|
||||
SteamId = steamid;
|
||||
Equipments = { "WoolGloves_White", "BaseballCap_Black",
|
||||
"Jeans_Blue", "Wellies_Black", "TShirt_Black"
|
||||
};
|
||||
ItemList = { "Apple" };
|
||||
WeaponData = new ref WeaponCfg();
|
||||
}
|
||||
}
|
||||
|
||||
class WeaponCfg
|
||||
{
|
||||
string WeaponName;
|
||||
string Desc;
|
||||
|
||||
ref TStringArray WeaponComponents;
|
||||
|
||||
void WeaponCfg()
|
||||
{
|
||||
WeaponName = "FAL";
|
||||
Desc = "武器配件中,一级配件(比如枪托,弹夹)放在前排,二级配件(比如电池)其次 以此类推"
|
||||
WeaponComponents = {
|
||||
"Fal_FoldingBttstck",
|
||||
"Mag_FAL_20Rnd"
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user