WIP tagging script

SmokeyMeadow

Well-Known Member
Hi there. it's been a while since I posted, but I'm getting back into DayZ and have a new script I'm working on. Basically, this script allows players to tag certain signs with their choice of picture from a preset menu. I have a number of bases on my server with signs out front, and signs on the roadside all over the map. Tagging the signs allows players to "claim" these areas. At least it would, but I'm having some problems with the signs being persistent after the player leaves the session.

Does anyone know why this might be? I'm using the setobjecttexture command, which executes perfectly and skins the sign with a paa file just how I want it. I believe the problem may lie in the script executing on the client side but not the server side.

Here's my fn_selfaction to activate the signs:

Code:
//SIGN START
if (cursorTarget isKindOf "WarfareBunkerSign" && (player distance cursorTarget < 5)) then {
            if (s_player_sign < 0) then {
            s_player_sign = player addAction ["Alter Sign","scripts\tagit\tagmenu.sqf",cursorTarget, 0, false, true, "",""];
        };
    } else {
        player removeAction s_player_sign;
        s_player_sign = -1;
    } ;
   
//SIGN END

That goes in fn_selfactions, obviously.

Here is a sample menu:

Code:
//Tagit! by Smokey Meadow

tagchoice = nil;
myTag =
[
    ["",true],
    ["Please select your tag:", [-1], "", -5, [["expression", ""]], "1", "1"],
    ["", [], "", -5, [["expression", ""]], "1", "1"],
    ["Tag 1", [], "", -5, [["expression", "tagchoice = 1;"]], "1", "1"],
    ["Tag 2", [], "", -5, [["expression", "tagchoice = 2;"]], "1", "1"],
    ["Tag 3", [], "", -5, [["expression", "tagchoice = 3;"]], "1", "1"],
    ["Tag 4", [], "", -5, [["expression", "tagchoice = 4;"]], "1", "1"],   
    ["", [], "", -5, [["expression", ""]], "1", "0"],   
    ["Exit", [], "", -3, [["expression", ""]], "1", "1"]
];

showCommandingMenu "#USER:myTag";

waitUntil {!isNil ("tagchoice")};

if (tagchoice == 1) then {execVM "scripts\tagit\tag1.sqf";};

if (tagchoice == 2) then {execVM "scripts\tagit\tag2.sqf";};

if (tagchoice == 3) then {execVM "scripts\tagit\tag3.sqf";};

if (tagchoice == 4) then {execVM "scripts\tagit\tag4.sqf";};

Make a folder called scripts in your mission folder, then make a folder called tagit in there, and finally put the above code into an sqf file called tagmenu sqf which goes in the tagit folder.

Here's a sample of the actual sqf that does the skinning. This is where the problem is occurring.

Code:
private ["_tagsign"];
if (isServer) exitwith {};
player playActionNow "Medic";
sleep 1;
//titleText ["Sign claimed for target practice!","PLAIN DOWN"]; titleFadeOut 5;

_tagsign = nearestObject [player, "WarfareBunkerSign"];

_tagsign setObjectTexture [0,"paa\t1.paa"]
sleep 1;

You name that tag1.sqf, or tag2, whatever you want it to be. Then you put this paa file into a folder called "paa" in your mission folder. It's just a sample image, a classic menacing badguy target from a shooting range in one of my bases. Feel free to use your own paa images.

As for my original question, does anyone know why this wouldn't be persistent until at least the server restarts?
 
Going and looking up the command gets you the following. I would suggest going and looking up the command is a first step to using it.

Code:
In MP this command has only local effect. If you want to change a texture on all clients, you have to execute this command on each client (or setObjectTextureGlobal). This command has also a bug: when a saved game is loaded the texture you have set will disappear and needs to be reset.

You need to send the change to the server, let the server broadcast to each player. Then you need to record the change on the server. Each time a new player logs in or dies, you need to resend those changes to that player.
 
Drat. That sounds complicated. I guess I'm a bit out of my depth on this one. Would using this server side command require changes to the database?

There are dozens of signs, so I imagine it will be difficult to have the server track each one of them.

I'm just thinking out loud here, but I guess what I need is another script to run in the init.sqf to keep track of all the previously tagged signs. Maybe each placed sign could be given a vehicle number in the unit's init, and each tag could be given a serial number. So then when each player logged in, the server would check each sign for the various serial numbers and paint them accordingly. Of course that would do nothing for tags painted in session.

I think I'm starting to realize why no one had done this previously. It's much more intricate than my texture skinning sqf that looks for vehicles of a certain type on init and applies setobjecttexture to give them their proper liveries.
 
Back
Top