spawnloadouts
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
| spawnloadouts [2026/03/19 08:32] – adminwiki | spawnloadouts [2026/03/19 08:52] (actual) – adminwiki | ||
|---|---|---|---|
| Línea 7: | Línea 7: | ||
| - El archivo CommonItems.txt contiene los items comunes para todos los personajes. | - El archivo CommonItems.txt contiene los items comunes para todos los personajes. | ||
| - Los archivos de la carpeta Donators se identifican con el número SteamId de cada jugador. | - Los archivos de la carpeta Donators se identifican con el número SteamId de cada jugador. | ||
| + | |||
| + | **Ejemplo de la estructura de carpetas y archivos** | ||
| + | |||
| + | G: | ||
| + | │ | ||
| + | │ | ||
| + | │ | ||
| + | └───Donators | ||
| + | 76561198031630167.txt | ||
| + | 76561198182095246.txt | ||
| + | |||
| **Ejemplo de archivo Regular.txt** | **Ejemplo de archivo Regular.txt** | ||
| Línea 45: | Línea 56: | ||
| AviatorGlasses | AviatorGlasses | ||
| StunBaton | StunBaton | ||
| + | |||
| + | |||
| + | **EJEMPLO DE ARCHIVO DE MISION init.c** | ||
| + | |||
| + | void main() | ||
| + | { | ||
| + | Weather weather = g_Game.GetWeather(); | ||
| + | weather.MissionWeather(false); | ||
| + | |||
| + | Hive ce = CreateHive(); | ||
| + | if ( ce ) | ||
| + | ce.InitOffline(); | ||
| + | } | ||
| + | | ||
| + | | ||
| + | // SPAWN LOADOUT | ||
| + | class CustomMission: | ||
| + | { | ||
| + | string m_SpawnLoadoutDirectory = " | ||
| + | string m_DonatorDirectory = m_SpawnLoadoutDirectory + " | ||
| + | string m_RegularLoadout = m_SpawnLoadoutDirectory + " | ||
| + | string m_CommonItems = m_SpawnLoadoutDirectory + " | ||
| + | | ||
| + | void CustomMission() | ||
| + | { | ||
| + | FileHandle templateFile; | ||
| + | |||
| + | PrintString(" | ||
| + | PrintString(" | ||
| + | PrintString(" | ||
| + | PrintString(" | ||
| + | PrintString(" | ||
| + | | ||
| + | if (!FileExist(m_SpawnLoadoutDirectory)) | ||
| + | { | ||
| + | PrintString(" | ||
| + | PrintString(" | ||
| + | MakeDirectory(m_SpawnLoadoutDirectory); | ||
| + | PrintString(" | ||
| + | | ||
| + | // create default CommonItems.txt | ||
| + | PrintString(" | ||
| + | templateFile = OpenFile(m_CommonItems, | ||
| + | FPrintln(templateFile, | ||
| + | CloseFile(templateFile); | ||
| + | PrintString(" | ||
| + | | ||
| + | // create default Regular.txt | ||
| + | PrintString(" | ||
| + | templateFile = OpenFile(m_RegularLoadout, | ||
| + | FPrintln(templateFile, | ||
| + | CloseFile(templateFile); | ||
| + | PrintString(" | ||
| + | } | ||
| + | | ||
| + | if (!FileExist(m_DonatorDirectory)) | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | // create template donator file | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | override void StartingEquipSetup(PlayerBase player, bool clothesChosen) | ||
| + | { | ||
| + | PrintString(" | ||
| + | player.RemoveAllItems(); | ||
| + | | ||
| + | FileHandle donatorFile; | ||
| + | string line; | ||
| + | | ||
| + | TStringArray contents = new TStringArray(); | ||
| + | string file = GetDonatorFile(player.GetIdentity().GetPlainId()); | ||
| + | | ||
| + | if (FileExist(file)) | ||
| + | { | ||
| + | PrintString(" | ||
| + | SpawnLoadout(player, | ||
| + | return; | ||
| + | } | ||
| + | | ||
| + | PrintString(" | ||
| + | SpawnLoadout(player, | ||
| + | } | ||
| + | | ||
| + | private void SpawnLoadout(PlayerBase player, ref TStringArray loadout) | ||
| + | { | ||
| + | PrintString(" | ||
| + | FileHandle loadoutFile; | ||
| + | string line; | ||
| + | | ||
| + | // creates clothes loadout | ||
| + | PrintString(" | ||
| + | foreach (string clothes : loadout) | ||
| + | { | ||
| + | PrintString(" | ||
| + | player.GetInventory().CreateInInventory(clothes); | ||
| + | } | ||
| + | |||
| + | // creates common items | ||
| + | PrintString(" | ||
| + | TStringArray items = ReadFileLines(m_CommonItems); | ||
| + | foreach (string item : items) | ||
| + | { | ||
| + | PrintString(" | ||
| + | if (!item.Contains("//" | ||
| + | { | ||
| + | player.GetInventory().CreateInInventory(item); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | private void CreateQuantityItem(PlayerBase player, string item) | ||
| + | { | ||
| + | PrintString(" | ||
| + | TStringArray quantity = new TStringArray(); | ||
| + | item.Split(" | ||
| + | | ||
| + | ItemBase quantityItem = player.GetInventory().CreateInInventory(quantity[0]); | ||
| + | quantityItem.SetQuantity(quantity[1].ToFloat()); | ||
| + | } | ||
| + | | ||
| + | private string GetDonatorFile(string id) | ||
| + | { | ||
| + | PrintString(" | ||
| + | return string.Format(" | ||
| + | } | ||
| + | | ||
| + | private TStringArray ReadFileLines(string path) | ||
| + | { | ||
| + | PrintString(" | ||
| + | FileHandle file; | ||
| + | string line; | ||
| + | | ||
| + | TStringArray contents = new TStringArray(); | ||
| + | | ||
| + | file = OpenFile(path, | ||
| + | while (FGets(file, | ||
| + | { | ||
| + | line.Trim(); | ||
| + | PrintString(" | ||
| + | if (line != string.Empty) | ||
| + | { | ||
| + | contents.Insert(line); | ||
| + | line = string.Empty; | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | CloseFile(file); | ||
| + | return contents; | ||
| + | } | ||
| + | }; | ||
| + | | ||
| + | Mission CreateCustomMission(string path) | ||
| + | { | ||
| + | return new CustomMission(); | ||
| + | } | ||
| + | |||
spawnloadouts.1773919924.txt.gz · Última modificación: por adminwiki
