ITr1ckst3rI
Member
So, i have been trying to mess around with adding actions to in-game objects. Specifically the vending machine. I know addAction has conditions that, if met, will add the action. I also know that if the action is added to the object, and not the player, then the player has to be looking at the object and within 15 meters.
My issue is I have no clue how to execute any of this xD
lets say i have "vending.sqf" in a folder called "custom".
i would add the code
to my init file.
Now contained within this vending.sqf would be this
Know i have the following attempts in these lines.
1) The check for distance with ( ) and without
2) Cursor Target iskindof (this shouldn't be needed because it object has the action)
3) MAP_vending_machine and vending_machine.
I know addaction is a local command but because this is executed on the client side (downloaded with mission) there shouldn't be an issue.
annnnnnnd none of them work *facepalm* need help.
EDIT: Success. The Following code worked to add the action to the vending machine.
HOWEVER
Where i had my vending machine, its very very hard to target it. SO!
I made this to give players the option when near it. So even if I can't target it, i will still get the option
My issue is I have no clue how to execute any of this xD
lets say i have "vending.sqf" in a folder called "custom".
i would add the code
Code:
[] execVM "custom\vending.sqf";
Now contained within this vending.sqf would be this
Code:
_vm1 = "MAP_vending_machine";
_vm1 addAction ["Buy A Drink ", "path\to\menu.sqf", "cursorTarget isKindOf 'MAP_vending_machine' && _target distance cursorTarget < 5"];
_vm1 addAction ["Buy A Drink 1", "path\to\menu.sqf", "cursorTarget isKindOf 'MAP_vending_machine' && (_target distance cursorTarget) < 5"];
_vm1 addAction ["Buy A Drink 2", "path\to\menu.sqf", "(_target distance cursorTarget) < 5"];
_vm1 addAction ["Buy A Drink 3", "path\to\menu.sqf", "_target distance cursorTarget < 5"];
_vm = "vending_machine";
_vm addAction ["Buy A Drink 4", "path\to\menu.sqf", "cursorTarget isKindOf 'vending_machine' && _target distance cursorTarget < 5"];
_vm addAction ["Buy A Drink 5", "path\to\menu.sqf", "cursorTarget isKindOf 'vending_machine' && (_target distance cursorTarget) < 5"];
_vm addAction ["Buy A Drink 6", "path\to\menu.sqf", "(_target distance cursorTarget) < 5"];
_vm addAction ["Buy A Drink 7", "path\to\menu.sqf", "_target distance cursorTarget < 5"];
Know i have the following attempts in these lines.
1) The check for distance with ( ) and without
2) Cursor Target iskindof (this shouldn't be needed because it object has the action)
3) MAP_vending_machine and vending_machine.
I know addaction is a local command but because this is executed on the client side (downloaded with mission) there shouldn't be an issue.
annnnnnnd none of them work *facepalm* need help.
EDIT: Success. The Following code worked to add the action to the vending machine.
Code:
//====================Vending Machine===============
if ((cursorTarget isKindOf "MAP_vending_machine") && (player distance cursorTarget < 5) && (speed player <= 1)) then {
if (s_player_vending < 0) then {
s_player_vending = player addaction[("<t color=""#ff0000"">" + ("Buy Drink") +"</t>"),"custom\buydrink.sqf","",5,false,true,"", ""];
};
} else {
player removeAction s_player_vending;
s_player_vending = -1;
};
//==================================================
Where i had my vending machine, its very very hard to target it. SO!
I made this to give players the option when near it. So even if I can't target it, i will still get the option
Code:
_list0 = position player nearObjects ["MAP_vending_machine",3];
_amount = count _list0;
if ((_amount >= 1) && (speed player <= 1)) then {
if (s_player_vending < 0) then {
s_player_vending = player addaction[("<t color=""#ff0000"">" + ("Buy Drink") +"</t>"),"admintools\AdminToolsMain.sqf","",5,false,true,"", ""];
};
} else {
player removeAction s_player_vending;
s_player_vending = -1;
};
Last edited: