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

ElDubya

Well-Known Member
Hey all,

I have a trader setup that requires accessing an infostand to be teleported to it. What I wanted to know is, what would I have to add to this to make the infostand delete after it's been accessed once?

titleCut ["","BLACK",0];
playsound "tele";
titleText ["Now Accessing Hidden Trader","PLAIN",3]; titleFadeOut 4;
sleep 2;
player setPos [12463.2,6758.78,0.00202942];
sleep 5;
titleCut ["","BLACK IN",0];
titleText ["Hope you brought some cash with you .... ;)","PLAIN",3]; titleFadeOut 4;

Thanks in advance for any help you could provide.
 
Last edited:
you could ad a trigger to the area that spawns the 'stand' based on conditinos such as UUID or if player has item in inventory. so when the player is TPed away from the area, the trigger no longer sees the conditions and removes the 'stand'
 
OR ... in the code that teleports the player use this
deletevehicle infostand;
of course using the name of the infostand as it was saved when you created it such as
infostand = "Infostand_2_EP1" createVehicle [7500,7500,0];
If you create the infostand on the server, this variable will not be visible on the client, you will need to pass the delete request to the server using an publicvariable and have it deleted on the server.
https://community.bistudio.com/wiki/deleteVehicle

So your code might look like this
Code:
titleCut ["","BLACK",0];
playsound "tele";
titleText ["Now Accessing Hidden Trader","PLAIN",3]; titleFadeOut 4;
sleep 2;
player setPos [12463.2,6758.78,0.00202942];
deletevehicle infostand;
sleep 5;
titleCut ["","BLACK IN",0];
titleText ["Hope you brought some cash with you .... ;)","PLAIN",3]; titleFadeOut 4;
 
OR ... in the code that teleports the player use this
deletevehicle infostand;
of course using the name of the infostand as it was saved when you created it such as
infostand = "Infostand_2_EP1" createVehicle [7500,7500,0];
If you create the infostand on the server, this variable will not be visible on the client, you will need to pass the delete request to the server using an publicvariable and have it deleted on the server.
https://community.bistudio.com/wiki/deleteVehicle

So your code might look like this
Code:
titleCut ["","BLACK",0];
playsound "tele";
titleText ["Now Accessing Hidden Trader","PLAIN",3]; titleFadeOut 4;
sleep 2;
player setPos [12463.2,6758.78,0.00202942];
deletevehicle infostand;
sleep 5;
titleCut ["","BLACK IN",0];
titleText ["Hope you brought some cash with you .... ;)","PLAIN",3]; titleFadeOut 4;

The infostand and the rest of the trader funiture is created on the server :

Code:
    _vehicle_157 = objNull;
    if (true) then
    {
     _this = createVehicle ["Infostand_2_EP1", [16423.408, 18363.781, 3.6052532], [], 0, "CAN_COLLIDE"];
     _vehicle_157 = _this;
     _this setDir -107.81516;
     _this setPos [16423.408, 18363.781, 3.6052532];
    };
 
After that script is run, and the neccessary stuff spawns in (including the infostand), I need that particular infostand to delete after being accessed once.
 
My previous suggestion about using a public variable event handler would have put this code on the server and have it called using the event handler. But you can insert this code just above where the player is teleported to the new position in your posted code
Code:
_info = getPos player nearestObject "Infostand_2_EP1";
deletevehicle _info;

you will need to add
!"Infostand_2_EP1"
to your deletevehicle BE filter ... if you use such garbage.
 
Last edited:
Thanks man, that worked a treat. :)

One last question. How would I make an Infostand appear randomly every restart from a list of predetermined co-ordinates? I want to create about 100 possible locations and have the server randomly choose one and place an infostand there.
 
easy method would be create an array of positions.
then round (random 100)
then select the index of the array.
Code:
infoArray [] = {
[1,1],[2,2], ... ...[100,100] };

randomloc = infoArray select (round (random 100));
 
Thanks, gives me somewhere to start looking, unless you wanna write it for me? I can do the co-ords part :)
 
you just want a 'vehicle' to spawn randomly across the map? Or did you want the entire, spawn it randomly then delete it once it's been used? Then what? It never respawns again until the server restarts? When I say vehicle I mean whatever item or object you want to spawn.
 
I want an infostand to spawn in every restart somewhere out of a list of 100 possible locations, and delete once it's been accessed.

Basically, I have an AI event on an island. When the event furniture spawns, so does an infostand. I have a trader hidden on the map. The only way in is to scroll on the infostand on the AI island and then it will teleport you to the trader and delete the infostand. The only way out of the trader is to scroll on the infostand inside the trader area and it takes you back to where the other infostand was.

I have all this working great so far.

Now I want to make an infostand appear randomly every restart somewhere on the map that I can set up to also give a player access to this hidden trader that once scrolled on and used, gets deleted.

I just haven't got the faintest idea how :)
 
So the objective is for the player to find the infostand, when they interact with the stand it tps them to another location not accessible, deletes the stand. Then when they are ready to leave, they interact with another stand, and it tps them back to the old stand location? Is there a condition for making the leap or just stumble across it? Since it's a one time thing, should there be a condition set?
 
No condition, just find the random stand, interact with it, get teleported, stand gets deleted. Once they are ready to leave the hidden trader area, they interact with the permanent infostand there and get teleported back to where they started from.
 
the code i wrote above is all you need. just insert your list of coordinates into where i put [1,1] etc.
then replace the current spawn of,your infostand with those 2 lines.
 
This is the way the infostand I have now spawns :

_vehicle_157 = objNull;
if (true) then
{
_this = createVehicle ["Infostand_2_EP1", [16423.408, 18363.781, 3.6052532], [], 0, "CAN_COLLIDE"];
_vehicle_157 = _this;
_this setDir -107.81516;
_this setPos [16423.408, 18363.781, 3.6052532];
};

This is the infostand I want to be part of the AI event, not include it in the list of random ones. So should I add this under it?

_vehicle_158 = objNull;
if (true) then
{

infoArray [] = {
[1,1],
[2,2], ... ...[100,100] };

randomloc = infoArray select (round (random 100));

_this = createVehicle ["Infostand_2_EP1", [], [], 0, "CAN_COLLIDE"];
_vehicle_158 = _this;
};

If so, how do I make the random one delete once accessed?
 
simply replace your pos array with randomloc variable. the same code we,had befire will,delete it


_this = createVehicle ["Infostand_2_EP1", randomloc, [], 0, "CAN_COLLIDE"];
 
Back
Top