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

fraronk

Members
  • Content Count

    3
  • Joined

  • Last visited

Everything posted by fraronk

  1. fraronk

    Help in scripting

    Hello all, i'm new in scripting, with some friends we have a public DayZ server and we would like add some commands for admins, i found this script on internet: but it doesn't woork completly. we've have notice on testing that in the execution of any command, thake the following as example: case "spawn": { if(count != 2) { SendMessageToPlayer(player, "/spawn [object]"); return; } GetGame().CreateObject(tokens[1], player.GetPosition(), false, true ); SendMessageToPlayer(player, "[ObjectSpawn] Object spawned: " + tokens[1]); break; } the variable player is not set properly, cause is not the player that write the command, but it's always the first player that joined the server Do you guys think that the problem is the names of players? Should i change in all this code instead using names should i use IDs? bool IsPlayer(string name) { PlayerBase p; array<Man> players = new array<Man>; GetGame().GetPlayers(players); for ( int i = 0; i < players.Count(); ++i ) { p = players.Get(i); if(p.GetIdentity().GetName() == name) return true; } return false; } PlayerBase GetPlayer(string name) { PlayerBase p; array<Man> players = new array<Man>; GetGame().GetPlayers(players); for ( int i = 0; i < players.Count(); ++i ) { p = players.Get(i); if(p.GetIdentity().GetName() == name) return p; } return NULL; } override void OnEvent(EventType eventTypeId, Param params) { super.OnEvent(eventTypeId,params); int i; PlayerBase player, temp_player; array<Man> players = new array<Man>; GetGame().GetPlayers(players); if(eventTypeId != ChatMessageEventTypeID) return; // Is chat message ChatMessageEventParams chat_params = ChatMessageEventParams.Cast( params ); if(chat_params.param1 != 0 || chat_params.param2 == "") return; player = GetPlayer(chat_params.param2); if(player == NULL) return; if(verify_admins && !IsPlayerAnAdmin(player)) { GetGame().AdminLog("[ADMCMD] (Unauthorized) " + player.GetIdentity().GetName() +" ("+player.GetIdentity().GetPlainId()+", "+player.GetIdentity().GetId()+") tried to execute "+ chat_params.param3); return; } string message = chat_params.param3, prefix, param0, command; TStringArray tokens = new TStringArray; message.Replace("` ", "&SPCESC!"); //Escape spaces before splitting message.Split(" ", tokens); int count = tokens.Count(); for ( i = 0; i < count; ++i ) { message = tokens[i]; message.Replace("&SPCESC!", " "); //.Replace doesn't work directly on TStringArray elements for some reason :( tokens[i] = message; }
  2. fraronk

    Help in scripting

    is there any code for set as default name instead Survivor the Steam ID or something like it?
  3. fraronk

    Help in scripting

    i'm talking about the executing player, when we test it on our server i type the command like /spawn apple, and the apple spawn to another player, so the executing player is taken wrong, is there any way for debug it or know why it's happen
×