Jump to content

Forums Announcement

Read-Only Mode for Announcements & Changelogs

Dear Survivors, we'd like to inform you that this forum will transition to read-only mode. From now on, it will serve exclusively as a platform for official announcements and changelogs.

For all community discussions, debates, and engagement, we encourage you to join us on our social media platforms: Discord, Twitter/X, Facebook.

Thank you for being a valued part of our community. We look forward to connecting with you on our other channels!

Stay safe out there,
Your DayZ Team

comiekto

Members
  • Content Count

    3
  • Joined

  • Last visited

Everything posted by comiekto

  1. comiekto

    gift mod

    Hello friends, I'm starting out in this world of creating mods and I'm trying to learn, I made this code that generates gift items for players, but it doesn't do anything, absolutely nothing, it's on the server side, I placed it in the 3_game folder, it doesn't generate an error and it doesn't do anything Can anyone help me get it to run? class GiftItem { int deliveryTime; ref array<string> items; ref array<string> attachments; // Lista de anexos para cada item } class GiftConfig { ref array<ref GiftItem> m_GiftItems; void LoadConfig() { string jsonPath = "$profile:GiftLetal/gift_config.json"; if (FileExist(jsonPath)) { JsonFileLoader<GiftConfig>.JsonLoadFile(jsonPath, this); Print("[Gift] Gift config loaded successfully."); } else { Print("[Gift] Gift config file not found."); } } } class GiftManager { protected ref GiftConfig m_Config; void GiftManager() { m_Config = new GiftConfig(); m_Config.LoadConfig(); } void CheckConnectionTime() { if (GetGame().IsServer()) { PlayerBase player = GetPlayer(); if (player) { int playerConnectionTime = GetPlayerConnectionTime(player); foreach (ref GiftItem giftItem : m_Config.m_GiftItems) { if (playerConnectionTime >= giftItem.deliveryTime) { string chosenItem = giftItem.items.GetRandomElement(); ref array<string> attachments = giftItem.attachments; // Obtenha a lista de anexos string playerName = player.GetIdentity().GetName(); // Obtém o nome do jogador GetGame().ChatPlayer(0, playerName + " receberá um presente em 10 segundos pelo seu tempo logado.", player); // Mensagem no chat global para o jogador // Espera 10 segundos antes de entregar o presente GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(PerformGiftDelivery, 10000, false, chosenItem, attachments, player); break; } } } } } void PerformGiftDelivery(string itemName, ref array<string> attachments, PlayerBase player) { if (player) { vector playerPos = player.GetPosition(); vector playerDir = player.GetDirection(); vector dropPos = playerPos + (playerDir * 2); EntityAI item = EntityAI.Cast(GetGame().CreateObject(itemName, dropPos)); // Adiciona os anexos ao item foreach (string attachment : attachments) { item.GetInventory().CreateAttachment(attachment); } Print("[Gift] Dropped item " + itemName + " with attachments " + attachments + " in front of player."); } else { Print("[Gift] Unable to drop item. Player not found."); } } int GetPlayerConnectionTime(PlayerBase player) { return 120; // Retorna 1 hora (3600 segundos) como exemplo } } class PluginMain { ref GiftManager m_GiftManager; void PluginMain() { m_GiftManager = new GiftManager(); GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(m_GiftManager.CheckConnectionTime, 0, true); // Chama a cada tick } } void main() { PluginMain pluginMain; pluginMain = new PluginMain(); } PlayerBase GetPlayer() { if (GetGame() && GetGame().GetPlayer()) { return PlayerBase.Cast(GetGame().GetPlayer()); } else { return null; } }
  2. comiekto

    gift mod

    and I want to do this to learn a little about scripting in dayz
  3. comiekto

    gift mod

    This mod gives the gift to the player, every x time he remains logged in and drops the item at his position, warning him 10 seconds before
×