-
Content Count
28 -
Joined
-
Last visited
Everything posted by DcrClub
-
I have been studying the players.db file for a while. I have always wanted to use the correct method to read out all the data and perform addition, deletion, modification and query processing. However, I have little knowledge of binary data processing. Now I can only parse all the data of the current player, but I cannot process the basic attributes of the player and the context attributes of the inventory materials. I don't understand this data structure. Is there any teacher who can help me process the code to realize the addition, deletion, modification and query of the inventory materials? import struct from io import BytesIO import sqlite3 import json import bson class DzChar: def __init__(self, id, uid, alive, data): self.ID = id self.UID = uid self.Alive = alive self.Items = [] self.decode_data(data) def decode_data(self, data): try: stream = BytesIO(data) # 1. 读取 HeaderData self.HeaderData = stream.read(16) self.HeaderGUID = self.HeaderData.hex().upper() # 2. 读取 CharacterName Length char_name_len_data = stream.read(1) if len(char_name_len_data) < 1: print("Error: Unable to read CharacterName length.") return char_name_len = struct.unpack('<B', char_name_len_data)[0] # 3. 读取 CharacterName character_name_data = stream.read(char_name_len) if len(character_name_data) < char_name_len: print("Error: Unable to read complete CharacterName.") return self.CharacterName = character_name_data.decode('utf-8') # 4. 读取 StatsData Length data_len_data = stream.read(2) if len(data_len_data) < 2: print("Error: Unable to read StatsData length.") return data_len = struct.unpack('<H', data_len_data)[0] # 5. 读取 StatsData self.StatsData = stream.read(data_len) # self.parse_stats_data() # 6. 读取 Version ver_data = stream.read(2) if len(ver_data) < 2: print("Error: Unable to read Version.") return self.Ver = struct.unpack('<H', ver_data)[0] # 7. 读取 Items Count items_count_data = stream.read(4) if len(items_count_data) < 4: print("Error: Unable to read Items Count.") return items_count = struct.unpack('<I', items_count_data)[0] # 8. 读取 Items for i in range(items_count): print(f"Reading item {i+1}/{items_count}") item = DzItem(self.UID, stream) self.Items.append(item) # 9. 检查是否有剩余数据 remaining = stream.read() if remaining: print(f"Remaining Data ({len(remaining)} bytes): {remaining.hex()}") else: print("No remaining data.") except Exception as e: print(f"Exception during decode_data: {e}") def parse_stats_data(self): try: # 假设 StatsData 是 JSON 格式的数据 stats_str = self.StatsData.decode('utf-8', errors='ignore') # 尝试解析为 JSON self.ParsedStatsData = json.loads(stats_str) print(f"Parsed StatsData: {json.dumps(self.ParsedStatsData, indent=4, ensure_ascii=False)}") except json.JSONDecodeError: print("StatsData is not valid JSON.") # 如果是其他格式,可以尝试其他解析方法 class DzItem: def __init__(self, uid, stream, parent=None): try: self.Parent = uid self.ParentItem = parent self.Childs = [] # 读取 Data Count data_count_data = stream.read(4) if len(data_count_data) < 4: print("Error: Unable to read Data Count.") return self.DataCount = struct.unpack('<I', data_count_data)[0] # 读取 Classname Length item_name_len_data = stream.read(1) if len(item_name_len_data) < 1: print("Error: Unable to read Classname length.") return item_name_len = struct.unpack('<B', item_name_len_data)[0] # 读取 Classname self.Classname = stream.read(item_name_len).decode('utf-8') # 读取 Skip (6 bytes) self.Skip = stream.read(6) # 读取 Slot Length slot_len_data = stream.read(1) if len(slot_len_data) < 1: print("Error: Unable to read Slot length.") return slot_len = struct.unpack('<B', slot_len_data)[0] # 读取 Slot self.Slot = stream.read(slot_len).decode('utf-8') # 读取 Custom Data Length custom_data_len_data = stream.read(4) if len(custom_data_len_data) < 4: print("Error: Unable to read Custom Data Length.") return custom_data_len = struct.unpack('<I', custom_data_len_data)[0] # 读取 PersistentGuid (16 bytes) self.PersistentGuid = stream.read(16).hex().upper() # 读取 Data (custom_data_len - 16 bytes) data_length = custom_data_len - 16 self.Data = stream.read(data_length) # 尝试解析 Data # self.parse_data() # 读取 Childs Count childs_count_data = stream.read(4) if len(childs_count_data) < 4: print("Error: Unable to read Childs Count.") return childs_count = struct.unpack('<I', childs_count_data)[0] # 读取 Childs for _ in range(childs_count): child = DzItem(uid, stream, self) self.add_child(child) except Exception as e: print(f"Exception during DzItem initialization: {e}") def parse_data(self): try: # 假设 Data 是 JSON 格式的数据 data_str = self.Data.decode('utf-8', errors='ignore') # 尝试解析为 JSON self.ParsedData = json.loads(data_str) print(f" Parsed Data: {json.dumps(self.ParsedData, indent=4, ensure_ascii=False)}") except json.JSONDecodeError: print(" Data is not valid JSON.") # 如果是其他格式,可以尝试其他解析方法 def add_child(self, item): self.Childs.append(item) class DzPlayersDb: def __init__(self, db_path): self.Players = [] connection = sqlite3.connect(db_path) cursor = connection.cursor() cursor.execute("SELECT * FROM Players") rows = cursor.fetchall() for row in rows: Id = row[0] Alive = row[1] UID = row[2] Data = row[3] self.Players.append(DzChar(Id, UID, bool(Alive), Data)) connection.close() def print_item(item, indent=0): indent_str = ' ' * indent print(f"{indent_str}Classname: {item.Classname}") print(f"{indent_str}Slot: {item.Slot}") print(f"{indent_str}PersistentGuid: {item.PersistentGuid}") print(f"{indent_str}Data: {item.Data.hex()}") # 如果解析出了 Data,可以打印解析后的数据 if hasattr(item, 'ParsedData'): print(f"{indent_str}Parsed Data: {json.dumps(item.ParsedData, indent=4, ensure_ascii=False)}") print(f"{indent_str}Number of Childs: {len(item.Childs)}") for child in item.Childs: print(f"{indent_str}Child Item:") print_item(child, indent + 1) def main(): db_path = 'players.db' # 确保这里的路径是您的数据库文件的正确路径 db = DzPlayersDb(db_path) for player in db.Players: print(f"\n--- Player ID: {player.ID} ---") print(f"UID: {player.UID}") print(f"Alive: {player.Alive}") print(f"Character Name: {player.CharacterName}") print(f"Version: {player.Ver}") print(f"Number of Items: {len(player.Items)}") # 如果解析出了 StatsData,可以打印解析后的数据 if hasattr(player, 'ParsedStatsData'): print(f"Parsed StatsData: {json.dumps(player.ParsedStatsData, indent=4, ensure_ascii=False)}") for idx, item in enumerate(player.Items, start=1): print(f"Item {idx}:") print_item(item) if __name__ == '__main__': main() Place the py file and players.db in the same directory
-
Why using the File method to request a network file address will only return a errorcode = 5. header is set "application/octet-stream". However, the successful file cannot be downloaded locally.
-
Has anyone used the File method? About HTTP download files.
DcrClub replied to DcrClub's topic in Modelling
Dayz mod has no execution permission. Can't download files, can't let me dynamically update UI -
Has anyone used the File method? About HTTP download files.
DcrClub replied to DcrClub's topic in Modelling
If get is not a data stream, only string will be returned, and file cannot download files. this API design is really chicken ribs. override void OnSuccess( string data, int dataSize ) { Print( "Request successful => data length: " + dataSize ); for( int i = 0; i < data.Length(); i++ ) { Print( data ); } }; SCRIPT : Request successful => data length: 174377 SCRIPT : � SCRIPT : P SCRIPT : N SCRIPT : G SCRIPT : SCRIPT : SCRIPT : SCRIPT : SCRIPT : m_LoginTimeMs: 6200 SCRIPT : ---- PlayerBase OnStoreLoad SUCCESS ---- -
During the fireworks, if a player is resurrected nearby, it will cause the player's client to crash directly. Cause: DayZGame.c line 3335 When fireworks explode, the player's camera object will be called to add jitter effect, but this call code is incorrectly executed on the server. Fix:
-
Simply on the server side, I have tried several ways to generate an item on the map and then transfer the item to the designated inventory, for example: Man.c file ServerTakeEntityToCargo ServerTakeEntityToInventory ServerTakeEntityAsAttachment ServerTakeEntityToTargetCargo Methods of this class, Occasionally, there will be a problem. After several items are moved to the inventory, the items will be stacked, that is, all the items are crowded on the first grid, or the moved items cannot be moved in the target inventory, and the data of the server and the client are not synchronized correctly. However, in the implementation of these methods, I have observed that the refresh operation has been called. Will this be network synchronization? Or which method can be perfectly solved, operating items on the server side and synchronizing perfectly with the client side?
-
The application scenario requires that because I have some independent item attributes that need to persist in the context, I don't want to delete and create this item frequently. Then transfer the variable attributes, so I need to maintain a method frequently, add or delete variables. That's why I need to transfer items in different containers.
-
On server side... not on client
-
I was wrong. It is the management password, which is equivalent to rcon
-
Perhaps it is to prevent module developers from stealing rcon's password
-
This buddy was limited by the regular game framework... He believes that all games must have a purpose. Players must have a clear game goal and need game developers to design a plot line for him before he can play. However, such games are like work and make people physically and mentally exhausted.
-
The method you mentioned can only be obtained by running it on the client side, if it is on the server side. Return empty \brief Gets the server address. (from client) */ proto bool GetHostAddress( out string address, out int port ); /** \brief Gets the server name. (from client) */ proto owned string GetHostName(); /** \brief Gets the server data. (from client) */ proto GetServersResultRow GetHostData();
-
remove items like gates without mods..?
DcrClub replied to ubeydullah.kiliclioglu's topic in Scripting
Therefore, it is also necessary to write code to realize this function. to rewrite the events triggered by the server when the player chats. however, I rewrite OnEvent events in the MissionServer. I don't like init.c, which will make init.c very bloated... in addition, the include method is not very good. I mount the pbo file of the module into-servermod = @ servermod when the server starts. -
remove items like gates without mods..?
DcrClub replied to ubeydullah.kiliclioglu's topic in Scripting
I don't understand. If you don't use code to handle player chat messages. How do you listen to specific user commands? There is no such function in the official code of dayz, is there? -
remove items like gates without mods..?
DcrClub replied to ubeydullah.kiliclioglu's topic in Scripting
Do you want to implement it in init.c? This requirement must be solved by adding additional code. -
remove items like gates without mods..?
DcrClub replied to ubeydullah.kiliclioglu's topic in Scripting
This requires a specific requirement document. How do you need to retrieve items, how do you need to delete items, and then find someone to customize a server mod... -
issue: I need a way to counter the appearance of goods copying plug-ins.
DcrClub posted a topic in Scripting
Specific plug-in operation steps: First player to open a plug-in program, and then enter the game. When the player places any item in his hand, he can use the mouse to drag the replica from his hand to the ground indefinitely, but the item in his hand will not disappear, This gives me a headache, so I hope that the api of dayz can be more open. Since you don't do anti-plug-in programs, it is always possible for us to counter plug-ins through mod. I hope that the official can open the methods in the CEApi class, so that we can rewrite it in mod. I need to mark the loot generated by CE or the items generated by dynamic events to distinguish the items directly copied by the plug-in. I hope the authorities will consider this issue. In addition: there are related methods for Http requests. I found that I cannot customize the contents of the header. I also hope that there can be a way for us to customize the contents of the header. -
Keywords: EEOnDamageCalculated
-
okokok
-
emmm ok, Then there is no need for json files to record missionserver.c override void OnEvent(EventType eventTypeId, Param params) case ClientNewEventTypeID: case ClientRespawnEventTypeID: However, this method has a disadvantage, which depends on your specific needs. If the player dies, exit the game directly. Then when he logs in again, he will follow the logic of the new role.
-
登录时根据玩家的 steamid来做个json配置. 有对应ID配置文件的就是老用户. 没有的就是新用户.
-
在楼顶上建造领地旗+瞭望塔的时候, 会触发这个bug, 具体的问题, 请查看视频吧.
-
Transferring a character between servers with different maps.
DcrClub replied to Infernales's topic in Servers
对于我来说, 使用mod来修正这个问题, 比研究官方的这些xml文件 更简单一些...😂😂 -
Transferring a character between servers with different maps.
DcrClub replied to Infernales's topic in Servers
你需要使用一个mod来实现玩家位置的修正, 当玩家在登陆你的服务器时,你需要判断玩家所在的坐标是否安全, 应当排除 [建筑类, 湖水, 海洋, 树木], 当然如果坐标的Y值在空中, 你需要调用 GetGame().SurfaceY( x, z ); 来得到一个安全的坐标高度, 让玩家正确的生成在地面上. 又或者你可以规定一组坐标, 让玩家在切换服务器后, 随机生成到你自定义的坐标上 -
你的linux系统环境没有安装好, 缺少一些依赖, 你必须确保依赖包都安装了. 具体的可以使用 LinuxGSM 的CLI去安装DayZServer