Is it possible to have a script delete an item once it's been used?

yea im not sure why he had all that other stuff in there. i do like the case 0, 1, 2 look. though i like having my lines ontop of one another rather than side by side. depending i guess..
and i do the if/then just incase i need to add an if/then/else in one or more of the cases, so i can mentally flow with it.
great working with you today.
 
yea im not sure why he had all that other stuff in there. i do like the case 0, 1, 2 look. though i like having my lines ontop of one another rather than side by side. depending i guess..
and i do the if/then just incase i need to add an if/then/else in one or more of the cases, so i can mentally flow with it.
great working with you today.
I usually put them one statement per line also. When there are multiple statements on a single line its too easy to overlook stuff ... but I thought in this case, it 'looked' better and kind of demonstrated the cleaner and more readable look of the switch statement. I think the 100 positions would be better in this code format,s than using the array and then selecting one randomly like I had suggested initially
And it reduces the chances of forgetting a comma or brace or something else that is hard to find.
 
if (isServer) then {
infoArray = [[8245.4,15465.1,0.0014081],[8248.62,15468.3,0.00139236],[8252.6,15472.2,0.00144339]];

randomloc = infoArray select (round (random 3));
_this = createVehicle ["Infostand_2_EP1", randomloc, [], 0, "CAN_COLLIDE"];

};

Works beautifully! Thank you guys.

Only now, when you exit the trader, it spits you back out at the same place, regardless of where you were when you accessed the stand. Is there anyway to fix that, or do I just live with it?
 
so ... you access the infostand. you get teleported to an area where there is a trader. you click on "buy condoms", exit trader and head towards your zombie girl ... Now do you want to go back to where the infostand was located?

If you used the above code instead of the improved "switch" code (it doesnt matter, end result is the same) .. but in the above code the position is saved in a global variable .. randompos .. so when you exit the trader you will need to do:
player setpos randompos;
 
_this = createVehicle ["Infostand_2_EP1", [0, 0, 0], [], 0, "CAN_COLLIDE"];
_newpos = floor (random 3);
switch(_newpos) do {
case 0:{_this setPos [4590,10145,0];_this setDir -90;};
case 1:{_this setPos [4600,10145,0];_this setDir -180;};
case 2:{_this setPos [4610,10145,0];_this setDir -270;};
};

With this code, can I set the direction like this?

_this = createVehicle ["Infostand_2_EP1", [0, 0, 0], [], 0, "CAN_COLLIDE"];
_newpos = floor (random 3);
switch(_newpos) do {
case 0:{_this setPos [4590,10145,0];_this setDir 131.777;};
case 1:{_this setPos [4600,10145,0];_this setDir 139.382;};
case 2:{_this setPos [4610,10145,0];_this setDir 143.029;};
};
 
yeah, Ideally the return teleport will spit you back out where you were when you accessed the stand.

I know, PITA right? :)
 
If you used the above code instead of the improved "switch" code (it doesnt matter, end result is the same) .. but in the above code the position is saved in a global variable .. randompos .. so when you exit the trader you will need to do this to return to original spot.
player setpos randompos;

The switch version doesnt have the location saved in a global variable ...
 
lets not ever forget about the setvariable command. useful to keep info like that handy on a unit. So in addition to your setpos and setdir (in the switch version) add a line: player setvariable ["infostand_pos", getpos _this ];
Now when you exit the trader, you do : player setpos (player getvariable["infostand_pos", position player]);
 
Ok. This is where I am at the moment.

I originally had one "InfoStand_2_EP1" that spawned in as part of an AI event. You scrolled on this to get access to the trader.

This code teleports you from the "Infostand_2_EP1" to the trader, then deletes the stand.

Code:
titleCut ["", "BLACK", 0];
playsound "tele";
titleText ["Now Accessing Hidden Trader", "PLAIN", 3]; titleFadeOut 4;
_info = getPos player nearestObject "Infostand_2_EP1";
deletevehicle _info;
sleep 2;
player setPos [12463.2, 6758.78, 0.00202942]; <----- Trader Co-Ords
sleep 5;
titleCut ["", "BLACK IN", 0];
titleText ["Hope you brought some cash with you .... ;)", "PLAIN", 3]; titleFadeOut 4;

This code teleports you from the trader, when you scroll on the "Infostand_1_EP1" that is there, back to the original position. but doesn't delete the stand.

Code:
titleCut ["", "BLACK", 0];
playsound "tele";
titleText ["Now Leaving Hidden Trader", "PLAIN DOWN", 3]; titleFadeOut 4;
sleep 2;
player setPos [16426, 18364.6, 3.58737];
sleep 5;
titleCut ["Look after your purchase wisely .... ", "BLACK IN", 0];

In my @DayZ_Epoch_Server\addons\dayz_server\buildings folder, I have a file called random_info.sqf that spawns in another "InfoStand_2_EP1" randomly on the map, out of a possible 50 locations. This is it :

Code:
if (isServer) then {

infoArray = [
[8374.78,15431.3,0.131453],
[9081.77,5452.34,0.00144196],
[9249.63,5522.89,0.00144196],
[etc],
[etc],
[x 50]
];

randomloc = infoArray select (round (random 50));
_this = createVehicle ["Infostand_2_EP1", randomloc, [], 0, "CAN_COLLIDE"];
};

Whenever this random spawned "Infostand_2_EP1" is accessed it also teleports you to the trader and the stand deletes.

But when you scroll to leave the trader, you get teleported BACK to the AI event, regardless of where you were when you accessed the random spawned "Infostand_2_EP1". What would I have to add to that mess above to make it so that no matter where the stand is you access to get to the trader, when you leave it puts you right back where you were?

Also, this is the fn_SelfActions section that deals with the stands :


Code:
if ( cursorTarget isKindOf "Infostand_2_EP1" && (player distance cursorTarget) < 2 ) then {
    if (s_player_bunker < 0) then {
        s_player_bunker = player addaction[("<t color=""#0000ff"">" + ("Enter The Trader") +"</t>"),"scripts\trader\bunkerin.sqf","",5,false,true,"", ""];
    };
} else {
    player removeAction s_player_bunker;
    s_player_bunker = -1;
};

if ( cursorTarget isKindOf "Infostand_1_EP1" && (player distance cursorTarget) < 2 ) then {
    if (s_player_bunkero < 0) then {
        s_player_bunkero = player addaction[("<t color=""#0000ff"">" + ("Leave the Trader") +"</t>"),"scripts\trader\bunkerout.sqf","",5,false,true,"", ""];
    };
} else {
    player removeAction s_player_bunkero;
    s_player_bunkero = -1;
};

When accessing a stand to go to the trader, you get both "Enter the Trader" and "Leave The Trader" options, but when leaving all you get is "Leave the Trader". How can I make it when accessing the trader you only get the one option, and not leave the trader as well?

Thanks guys, I understand this is all a headache but I am trying to learn stuff along the way.
 
omg ..,giving me a headache just THINKING about READING all that and trying to understand what is going on.
can we wait for the movie version?

will take a while to digest all this ... unless there IS a movie?
 
Sorry mate, I tried to make it as concise and factual as possible and still be easy to understand.

I suppose you wat DiCapprio to play your part in the movie? :)
 
to go back to where you came from save that position in a global variable.,,this should all be client side so there will be no confusion with multiple players.
add this BEFORE the player teleports to the trader.
originalLocation = getpos player;
now to go back
player setpos originalLocation;
 
the solution,to,your ENTER and LEAVE,actions ....
you,realize,the issue is that both if statements are true for every infostsnd,you,are,looking at. so,we need,to differentiate between them.

when you create the ENTER type infostand, add this after its created.
_this setvariable[" Entertype", 1];
and same for your EXIT type of stand except setvariable to 0.
now in your selfactions add,in another && clause to check if the type is 1 or 0


if ( cursorTarget isKindOf "Infostand_2_EP1" && (player distance cursorTarget) < 2 && (cursortarget getvariable["Entertype", -1] == 1) ) then {

and,check,for,0,in,the exit action. code
 
Back
Top