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

i am sure some of those ideas and code i put up doesnt make sense because its not complete code or examples. can post full code at home,later,if,needed
 
When you say check for 0 or 1 :

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

that checks for 1.

Would this check for 0 then?

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

Because I have tried different placements of "0" in that second one and it doesn't work at all when I mess with it?

I even tried to do it myself and look up on the wiki, but I started developing a brain haemmorage.
 
Yes that is the general idea. Let me point out that there is no such thing as negative zero, 0 is 0. In the brackets you are checking for enter type in the number in get variable is the default that will be assigned if that variable does not exist which is why we use -1. If we set a number is 0 or at 1 -1 doesn't fit either of our equations so we know that it's not one of the info stands.
When you spawn the info stands in your scripts are you setting 1 at the info stand that teleports to the trader and are you setting 0 at the info stand at the trader that let you leave?
 
"Infostand_1_EP1" <<---- exit from trader is set to _this setvariable[" Exittype", 0];
"Infostand_2_EP1" <<--- entry to trader is set to _this setvariable[" Entertype", 1];
 
Code:
if ( cursorTarget isKindOf "Infostand_2_EP1" && (player distance cursorTarget) < 2 && (cursortarget getvariable["Entertype", -1] == 1) ) 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 && (cursortarget getvariable["Exittype", 0] == 0) ) 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;
};

Just tested. This configuration give me "Leave the Trader" on both the Infostand_1_EP1 and the Infostand_2_EP1?
 
"Infostand_1_EP1" <<---- exit from trader is set to _this setvariable[" Exittype", 0];
all infostsnds set and check a single variable .. Entertype. we just set it to 1 on enter stand and,0 on exit stand

and there is a logic error. above you are setting it to 0.
and then in your LEAVE action code you have this
getvariable["Exittype", 0] == 0
so, it checks if exittype ==0 and if exittype is not defined it returns 0 ... which is ==0 therefore the leave clause will always be true.
thats why we set the default value to -1, its not a valid value for either ...

its a bit confusing, especially with me not using,complet code. after noon i can do the entire block if,needed
 
if you get ehat i mean ... on your ENTER stands, you do not have the EXITTYPE set ... therefore,getvariable exittype,0 will always return,0 because,it dont exist on the enterstands. and,then we,compare 0==0 to show the leave action incorrsctly

so, set same,variable,name,on all infostands. just set 1 on enters, 0 on exits, and set -1,as default in the getvariable lines.
 
Code:
if ( cursorTarget isKindOf "Infostand_2_EP1" && (player distance cursorTarget) < 2 && (cursortarget getvariable["Entertype", -1] == 1) ) 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 && (cursortarget getvariable["Entertype", -1] == 0) ) 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;
};
 
Yeah, I am lost mate. If you could sort it for me, perhaps I can see what the proper WORKING outcome is from your code and deduce exactly what is going on and what you are trying to explain. I appreciate the help.
 
Ahhhhh! See, back here you said :

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

I missread it and created entertype AND exittype variables. Totally my bad. I can see what's supposed to happen now.
 
Just tested it out quickly and it doesn't appear to work? Will check it out more in the morning, it's after 1am here. Thanks for everything thus far though. :)
 
Ok. I can't figure this sh#t out. :(

All my infostands are created on the server in 3 files.

A random ENTER one out of 50 possible locations :

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"];
_this setvariable[" Entertype", 1];
};

An ENTER one as part of the AI mission :

Code:
if (isServer) then {

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

And the EXIT one as part of the hidden trader :

Code:
    _vehicle_39 = objNull;
    if (true) then
    {
      _this = createVehicle ["Infostand_1_EP1", [12466.351, 6759.3394, 0.00061482762], [], 0, "CAN_COLLIDE"];
      _vehicle_39 = _this;
      _this setvariable[" Entertype", 0];
      _this setDir 78.223656;
      _this setPos [12466.351, 6759.3394, 0.00061482762];
    };

I have this in my fn_selfActions :

Code:
if ( cursorTarget isKindOf "Infostand_2_EP1" && (player distance cursorTarget) < 2 && (cursortarget getvariable["Entertype", -1] == 1) ) 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 && (cursortarget getvariable["Entertype", -1] == 0) ) 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;
};

With this further down the fn_selfActions :

Code:
    .....................
    player removeAction s_garage_dialog;
    s_garage_dialog = -1;   
    player removeAction s_givemoney_dialog;
    s_givemoney_dialog = -1;
    player removeAction s_bank_dialog;
    s_bank_dialog = -1;
    player removeAction s_bank_dialog2;
    s_bank_dialog2 = -1;
    player removeAction s_player_bunker;
    s_player_bunker = -1;
    player removeAction s_player_bunkero;
    s_player_bunkero = -1;

This is in my variables.sqf, under dayz_resetSelfActions = {

Code:
   ............... 
    s_player_bunker = -1;
    s_player_bunkero = -1; 
    ...............
 
OKAY .. for future reference, the issue is PROBABLY that the setvariable is being called on the server and in order to broadcast that variable to all computers (ie. the clients) which are checking the value via selfactions, you need to add a true at the end.
_this setvariable[" Entertype", 1,true];
And my apologies for possibly causing much stress to you because of an oversight of mine ..
.. looking at the complete code on my computer instead of cellphone .. I did not realize there are two separate types of infostands (Infostand_1_EP1, Infostand_2_EP1 ), and you already have one type for enters and one type for exits. Your selfactions are checking for the appropriate classnames .. so if you remove all the setvariable and getvariable crap your infostands will work.

delete the _this setvariable[" Entertype", ]; from your your spawn scripts.
your fn_selfactions
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;
};
 
That's okay man, I appreciate the help. And I'm learning stuff along the way, so it's all good.

Although, this has taken me back to my original issue.

When I scroll on an ENTER infostand, I see this :

enter_zpsr9unyoil.jpg


When I scroll on the infostand in the trader to LEAVE, I see this :

leave_zpsnnyypzwd.jpg


How do I make it so the only option on the ENTER infostands is " Enter The Trader" and not have both options there?
 
Back
Top