Jump to content

Release/Tutorial - Vending Machine


Recommended Posts

ZeroK00L, thanks

Question and not trying to be smart, but why would you charge for sodas when in my chernarus server i am tripping over them?

 

On my server, the vending machines have a little under a 10% chance to spawn an orange sherbert. You pay 10oz silver and if you get the orange sherbert, you can sell it to the rare food and drinks trader I created and sell it for 1oz of gold. It's kind of like gambling. :)

Link to comment
Share on other sites

On my server, the vending machines have a little under a 10% chance to spawn an orange sherbert. You pay 10oz silver and if you get the orange sherbert, you can sell it to the rare food and drinks trader I created and sell it for 1oz of gold. It's kind of like gambling. :)

See, endless possebilities! :D

Like the way you think BetterDeadThanZed

Link to comment
Share on other sites

See, endless possebilities! :D

Like the way you think BetterDeadThanZed

 

After installing this script, I had another idea... place an object, such as a cash register, and players have to pay a set amount and in return they get some money back. It might be more than they paid, or it might be less, or it might be something useless like a tin can or a razor. A sort-of slot machine.

Link to comment
Share on other sites

On my server, the vending machines have a little under a 10% chance to spawn an orange sherbert. You pay 10oz silver and if you get the orange sherbert, you can sell it to the rare food and drinks trader I created and sell it for 1oz of gold. It's kind of like gambling. :)

I like that ideal

Link to comment
Share on other sites

So if all i want to sell is Beer (ItemSodaRabbit) in the machines, what would the script  be then and i mean ZeroKOOL's script. In the mean time i will be looking in the forums for the anwser. I thank you in advance for any help.

Link to comment
Share on other sites

//by ZeroK00L
private["_playerPos","_canVend"];

call gear_ui_init;
_playerPos = getPosATL player;
_canVend = count nearestObjects [_playerPos, ["MAP_vending_machine"], 4] > 0;
_soda = ["ItemSodaRabbit","ItemSodaOrangeSherbet","ItemSodaLvg","ItemSodaClays","ItemSodaSmasht","ItemSodaPepsi","ItemSodaMdew","ItemSodaCoke","ItemSodaLemonade"];

if (_canVend) then {
            
            playsound "vendingmachine";
            sleep 2;
            player playActionNow "PutDown";
            player addMagazine 'ItemSodaRabbit';
            cutText ["You received a Soda from the Vending Machine!", "PLAIN DOWN"];
};

I think the original script from ZeroK00l only puts ItemSodaRabbit in the players inv. (look at the player addMagazine line)

The version BetterDeadThanZed posted randomly picks a soda defined in the list

Link to comment
Share on other sites

//by ZeroK00L
private["_playerPos","_canVend"];

call gear_ui_init;
_playerPos = getPosATL player;
_canVend = count nearestObjects [_playerPos, ["MAP_vending_machine"], 4] > 0;
_soda = ["ItemSodaRabbit","ItemSodaOrangeSherbet","ItemSodaLvg","ItemSodaClays","ItemSodaSmasht","ItemSodaPepsi","ItemSodaMdew","ItemSodaCoke","ItemSodaLemonade"];

if (_canVend) then {
            
            playsound "vendingmachine";
            sleep 2;
            player playActionNow "PutDown";
            player addMagazine 'ItemSodaRabbit';
            cutText ["You received a Soda from the Vending Machine!", "PLAIN DOWN"];
};

I think the original script from ZeroK00l only puts ItemSodaRabbit in the players inv. (look at the player addMagazine line)

The version BetterDeadThanZed posted randomly picks a soda defined in the list

 

//by ZeroK00L
private["_playerPos","_canVend"];

call gear_ui_init;
_playerPos = getPosATL player;
_canVend = count nearestObjects [_playerPos, ["MAP_vending_machine"], 4] > 0;
_soda = ["ItemSodaRabbit","ItemSodaOrangeSherbet","ItemSodaLvg","ItemSodaClays","ItemSodaSmasht","ItemSodaPepsi","ItemSodaMdew","ItemSodaCoke","ItemSodaLemonade"] call BIS_fnc_selectRandom;

if (_canVend) then {
            
            playsound "vendingmachine";
            sleep 2;
            player playActionNow "PutDown";
            player addMagazine _soda;
            cutText ["You received a Soda from the Vending Machine!", "PLAIN DOWN"];
};

done

Link to comment
Share on other sites

  • 1 month later...

Modified this a bit ;)

Only for SingleCurrency

 

SelfActions:

private["_playerPos","_nearVend"];

_playerPos = getPosATL player;
_nearVend = count nearestObjects [_playerPos, ["MAP_vending_machine"], 4] > 0;
 
if (_nearVend) then {
        if (s_player_buySoda < 0) then {
            s_player_buySoda = player addaction[("<t color=""#00C732"">" + ("Buy Drinks") +"</t>"),"Vending\vending_drinks.sqf"];
        };
		if (s_player_buyFood < 0) then {
			s_player_buyFood = player addaction[("<t color=""#00C732"">" + ("Buy Food") +"</t>"),"Vending\vending_foods.sqf"];
        };
    } else {
        player removeAction s_player_buySoda;
        s_player_buySoda = -1;
		player removeAction s_player_buyFood;
        s_player_buyFood = -1;
    };

Vending\vending_foods.sqf:

private["_playerPos","_canVend","_costs"];

call gear_ui_init;
_playerPos = getPosATL player;
_canVend = count nearestObjects [_playerPos, ["MAP_vending_machine"], 4] > 0;
_food = ["FoodNutmix","FoodPistachio","FoodSteakCooked","FoodMRE"] call BIS_fnc_selectRandom;
_costs = 5;

if (_canVend) then {
	if !([ player,_costs] call SC_fnc_removeCoins) then {
		titleText [format["You need %1 %2 to buy food.",_costs,CurrencyName] , "PLAIN DOWN", 1];
	} else {
		sleep 1;
		player playActionNow "PutDown";
		player addMagazine _food;
		titleText [format["Bought a %1 for %2 %3",_food,_costs,CurrencyName] , "PLAIN DOWN", 1];
	};
};

Vending\vending_drinks.sqf:

private["_playerPos","_canVend","_costs"];

call gear_ui_init;
_playerPos = getPosATL player;
_canVend = count nearestObjects [_playerPos, ["MAP_vending_machine"], 4] > 0;
_soda = ["ItemSodaOrangeSherbet","ItemSodaPepsi","ItemSodaMdew","ItemSodaCoke","ItemSodaLemonade"] call BIS_fnc_selectRandom;
_costs = 2;

if (_canVend) then {
	if !([ player,_costs] call SC_fnc_removeCoins) then {
		titleText [format["You need %1 %2 to buy a soda.",_costs,CurrencyName] , "PLAIN DOWN", 1];
	} else {
		sleep 1;
		player playActionNow "PutDown";
		player addMagazine _soda;
		titleText [format["Bought %1 for %2 %3",_soda,_costs,CurrencyName] , "PLAIN DOWN", 1];
	};
};

Will this work with Zupas V3 coin? Would all i have to do is change CurrencyName to cashMoney?

Link to comment
Share on other sites

  • 2 weeks later...

Hey did anyone have a problem with the sound for the vending machine? Everything else works. I just don't hear anything when i buy.

I have the file vendingmachine.ogg in the vending folder. All my other sounds work i.e. Origins doors, metal gates.

This is what i have in my description.ext

 
#include "custom\extra_rc.hpp"
 
class CfgSounds
{
sounds[] = {};
 
class DoorCreak
    {
name="DoorCreak";
sound[]={sounds\doorCreak.ogg, 0.1, 1};
titles[] = {};
    };
class metalGates
    {
name="metalGates";
sound[]={sounds\metalGates.ogg, 0.1, 1};
titles[] = {};
    };
class stronghold
{
name = "stronghold";
sound[] = {sounds\vrata_sound.ogg,0.1,1};
titles[] = {};
    };
class vendingmachine
    {
    name="vendingmachine";
    sound[]={Vending\vendingmachine.ogg,0.9,1};
    titles[] = {};
};
};
 
#include "custom\snap_pro\snappoints.hpp"
Link to comment
Share on other sites

 

Hey did anyone have a problem with the sound for the vending machine? Everything else works. I just don't hear anything when i buy.

I have the file vendingmachine.ogg in the vending folder. All my other sounds work i.e. Origins doors, metal gates.

This is what i have in my description.ext

 

 

this is how I have sounds 

 

class CfgSounds
{
sounds[] ={doorCreak,metalGates,vrata_sound,vendingmachine};


class DoorCreak
    {
name="DoorCreak";
sound[]={sounds\doorCreak.ogg, 0.1, 1};
titles[] = {};
    };
class metalGates
    {
name="metalGates";
sound[]={sounds\metalGates.ogg, 0.1, 1};
titles[] = {};
    };
class stronghold
{
name = "stronghold";
sound[] = {sounds\vrata_sound.ogg,0.1,1};
titles[] = {};
    };
class vendingmachine
    {
    name="vendingmachine";
    sound[]={Vending\vendingmachine.ogg,0.9,1};
    titles[] = {};
};
};

shows in instructions to have a \vending\

 

sound[]={\Vending\vendingmachine.ogg,0.9,1};

 

not so sure why there is that \vending

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...