animated slot machine

FallingSheep

OpenDayZ Lord!
ok i having trouble getting my slot machine script to work heres what i have so far
slots.sqf
Code:
//display the dialog screen
createDialog= "RscDisplaySlots";
waitUntil {!(isNull (findDisplay 3000))};
//Variables
_credits = 0;
_reelArray = ["cherry","lemon","grape","watermelon","orange","bar","seven","diamond"];
//prizes for payout
_prize1 = "ItemGoldBar";
_prize2 = "ItemGoldBar10oz";
_prize3 = "ItemBriefcase20oz";
_prize4 = "ItemBriefcase40oz";
_prize5 = "ItemBriefcase60oz";
_prize6 = "ItemBriefcase80oz";
_prize7 = "ItemBriefcase100oz";

fnc_add_1_credits = {
   //check if player has required item
   if ("ItemGoldBar" in magazines player) then{
     //remove cost
     player removeMagazine "ItemGoldBar";
     //add credit
     _credits = _credits + 1;
     //Update credits display
     waitUntil {!(isNull (findDisplay 3000))};
     ctrlSetText[1000, format ["%1" ,_credits]];
   }else{
     titleText ["You need 1x Goldbar to add 1 credit!","PLAIN DOWN"];
     titleFadeOut 3;
   };
};

fnc_add_10_credits = {
   //check if player has required item
   if ("ItemGoldBar10oz" in magazines player) then{
     //remove cost
     player removeMagazine "ItemGoldBar10oz";
     //add credits
     _credits = _credits + 10;
     //Update credits display
     waitUntil {!(isNull (findDisplay 3000))};
     ctrlSetText[1000, format ["%1" ,_credits]];
   }else{
     titleText ["You need 1x 10oz Goldbar to add 10 credits!","PLAIN DOWN"]; titleFadeOut 3;
   };
};
fnc_check_credits = {
   if (_credits <= 0) then {
     hasCredits = false;
     titleText ["You have no credits!","PLAIN DOWN"]; titleFadeOut 3;
   }else{
     hasCredits = true;
   };
};

fnc_random_pictures = {
// "cherry","lemon","grape","watermelon","orange","bar","seven","diamond"
//reel1
 ctrlSetText [1200, "pictures\image1.paa"];
 ctrlSetText [1200, "pictures\image2.paa"];

 ctrlSetText [1200, "pictures\image3.paa"];

 ctrlSetText [1200, "pictures\image4.paa"];
 ctrlSetText [1200, "pictures\image5.paa"];
 
 ctrlSetText [1200, "pictures\image6.paa"];

 ctrlSetText [1200, "pictures\image7.paa"];
 ctrlSetText [1200, "pictures\image8.paa"];   

//reel2
 ctrlSetText [1201, "pictures\image1.paa"];
 ctrlSetText [1201, "pictures\image2.paa"];

 ctrlSetText [1201, "pictures\image3.paa"];

 ctrlSetText [1201, "pictures\image4.paa"];
 ctrlSetText [1201, "pictures\image5.paa"];
 
 ctrlSetText [1201, "pictures\image6.paa"];

 ctrlSetText [1201, "pictures\image7.paa"];
 ctrlSetText [1201, "pictures\image8.paa"];  
//reel3
 ctrlSetText [1202, "pictures\image1.paa"];
 ctrlSetText [1202, "pictures\image2.paa"];

 ctrlSetText [1202, "pictures\image3.paa"];

 ctrlSetText [1202, "pictures\image4.paa"];
 ctrlSetText [1202, "pictures\image5.paa"];
 
 ctrlSetText [1202, "pictures\image6.paa"];

 ctrlSetText [1202, "pictures\image7.paa"];
 ctrlSetText [1202, "pictures\image8.paa"];  
};

fnc_spin  = {
   call fnc_check_credits;
   sleep 0.01;
   if (hasCredits) then {
     //remove credit
     _credits = _credits - 1;
     //update credits display     
     waitUntil {!(isNull (findDisplay 3000))};
     ctrlSetText[1000, format ["%1" ,_credits]];
     //randomise reels
     call fnc_random_pictures;
     //wait 5 seconds
     sleep 5;
     _reel1 = _reelArray call BIS_fnc_selectRandom;
     _reel2 = _reelArray call BIS_fnc_selectRandom;
     _reel3 = _reelArray call BIS_fnc_selectRandom;
     //display pictures
     call fnc_display_pictures;
     //wait
     sleep 0.2;
     //check if win or lose
     call fnc_payout;
   };
};
fnc_display_pictures = {
//reel 1
   if (_reel1 = "cherry") then {
    ctrlSetText [1200, "pictures\image1.paa"];
   };
   if (_reel1 = "lemon") then {
    ctrlSetText [1200, "pictures\image2.paa"];
   };
   if (_reel1 = "grape") then {
    ctrlSetText [1200, "pictures\image3.paa"];
   };
   if (_reel1 == "watermelon") then {
    ctrlSetText [1200, "pictures\image4.paa"];
   };
   if (_reel1 = "orange") then {
    ctrlSetText [1200, "pictures\image5.paa"];
   };
   if (_reel1 = "bar") then {
    ctrlSetText [1200, "pictures\image6.paa"];
   };
   if (_reel1 = "seven") then {
    ctrlSetText [1200, "pictures\image7.paa"];
   };
   if (_reel1 = "diamond") then {
    ctrlSetText [1200, "pictures\image8.paa"];
   };
   //reel 2
   if (_reel2 = "cherry") then {
    ctrlSetText [1201,"pictures\image1.paa"];
   };
   if (_reel2 = "lemon") then {
    ctrlSetText [1201,"pictures\image2.paa"];
   };
   if (_reel2 = "grape") then {
    ctrlSetText [1201,"pictures\image3.paa"];
   };
   if (_reel2 = "watermelon") then {
    ctrlSetText [1201,"pictures\image4.paa"];
   };
   if (_reel2 = "orange") then {
    ctrlSetText [1201,"pictures\image5.paa"];
   };
   if (_reel2 = "bar") then {
    ctrlSetText [1201,"pictures\image6.paa"];
   };
   if (_reel2 = "seven") then {
    ctrlSetText [1201,"pictures\image7.paa"];
   };
   if (_reel2 = "diamond") then {
    ctrlSetText [1201,"pictures\image8.paa"];
   };
   //reel 3
   if (_reel3 = "cherry") then {
    ctrlSetText [1202,"pictures\image1.paa"];
   };
   if (_reel3 = "lemon") then {
    ctrlSetText [1202,"pictures\image2.paa"];
   };
   if (_reel3 = "grape") then {
    ctrlSetText [1202,"pictures\image3.paa"];
   };
   if (_reel3 = "watermelon") then {
    ctrlSetText [1202,"pictures\image4.paa"];
   };
   if (_reel3 = "orange") then {
    ctrlSetText [1202,"pictures\image5.paa"];
   };
   if (_reel3 = "bar") then {
    ctrlSetText [1202,"pictures\image6.paa"];
   };
   if (_reel3 = "seven") then {
    ctrlSetText [1202,"pictures\image7.paa"];
   };
   if (_reel3 = "diamond") then {
    ctrlSetText [1202,"pictures\image8.paa"];
   };
};

fnc_payout = {
   if ((_reel1 = _reel2) && (_reel2 = _reel3)) then {
     if (_reel1 = "cherry") then {
       titleText ["You won 1 gold bar!","PLAIN DOWN"]; titleFadeOut 3;
       player addMagazine _prize1;
     };
     if (_reel1 = "lemon") then {
       titleText ["You won 10oz gold!","PLAIN DOWN"]; titleFadeOut 3;
       player addMagazine _prize2;
     };
     if (_reel1 = "grape") then {
       titleText ["You won 20oz gold!","PLAIN DOWN"]; titleFadeOut 3;
       player addMagazine _prize3;
     };
     if (_reel1 = "watermelon") then {
       titleText ["You won 40oz gold!","PLAIN DOWN"]; titleFadeOut 3;
       player addMagazine _prize4;
     };
     if (_reel1 = "orange") then {
       titleText ["You won 60oz gold!","PLAIN DOWN"]; titleFadeOut 3;
       player addMagazine _prize5;
     };
     if (_reel1 = "bar") then {
       titleText ["You won 80oz gold!","PLAIN DOWN"]; titleFadeOut 3;
       player addMagazine _prize6;
     };
     if (_reel1 = "seven") then {
       titleText ["Jackpot! You won 100oz gold!","PLAIN DOWN"]; titleFadeOut 3;
       player addMagazine _prize7;
     };
     if (_reel1 = "diamond") then {
       _credits = _credits + 5;
       titleText ["You won 5 free credits!","PLAIN DOWN"]; titleFadeOut 3;
     };
   }else{
     titleText ["You lost.","PLAIN DOWN"]; titleFadeOut 3;
   };
};
and slots.hpp
Code:
class RscDisplaySlots
{
   idd = 3000;
   movingenable = 0;

   class Controls
   {
     class RscFrame_1800: RscFrame
     {
       idc = 1800;
       x = 0.32375 * safezoneW + safezoneX;
       y = 0.3355 * safezoneH + safezoneY;
       w = 0.367188 * safezoneW;
       h = 0.3055 * safezoneH;
     };
     class credittext_TXT: RscText
     {
       idc = 1000;
       text = "Credits:";
       x = 0.32375 * safezoneW + safezoneX;
       y = 0.3355 * safezoneH + safezoneY;
       w = 0.0440625 * safezoneW;
       h = 0.0235 * safezoneH;
     };
     class credits_TXT: RscText
     {
       idc = 1001;
       text = "0";
       x = 0.367812 * safezoneW + safezoneX;
       y = 0.3355 * safezoneH + safezoneY;
       w = 0.0514062 * safezoneW;
       h = 0.0235 * safezoneH;
     };
     class RscPicture_1201: RscPicture
     {
       idc = 1201;
       text = "#(argb,8,8,3)color(1,1,1,1)";
       x = 0.477969 * safezoneW + safezoneX;
       y = 0.3825 * safezoneH + safezoneY;
       w = 0.05875 * safezoneW;
       h = 0.1175 * safezoneH;
     };
     class RscPicture_1202: RscPicture
     {
       idc = 1202;
       text = "#(argb,8,8,3)color(1,1,1,1)";
       x = 0.573438 * safezoneW + safezoneX;
       y = 0.3825 * safezoneH + safezoneY;
       w = 0.05875 * safezoneW;
       h = 0.1175 * safezoneH;
     };
     class RscPicture_1200: RscPicture
     {
       idc = 1200;
       text = "#(argb,8,8,3)color(1,1,1,1)";
       x = 0.3825 * safezoneW + safezoneX;
       y = 0.3825 * safezoneH + safezoneY;
       w = 0.05875 * safezoneW;
       h = 0.1175 * safezoneH;
     };
     class spin_BTN: RscButton
     {
       idc = 1600;
       text = "SPIN";
       x = 0.338437 * safezoneW + safezoneX;
       y = 0.5705 * safezoneH + safezoneY;
       w = 0.05875 * safezoneW;
       h = 0.0235 * safezoneH;
       action = "_nil=[]Spawn fnc_spin";
     };
     class 1credit_BTN: RscButton
     {
       idc = 1601;
       text = "Add 1 Credit";
       x = 0.419219 * safezoneW + safezoneX;
       y = 0.5705 * safezoneH + safezoneY;
       w = 0.0734375 * safezoneW;
       h = 0.0235 * safezoneH;
       action = "_nil=[]Spawn fnc_add_1_credits";
     };
     class 10credit_BTN: RscButton
     {
       idc = 1602;
       text = "Add 10 Credits";
       x = 0.514687 * safezoneW + safezoneX;
       y = 0.5705 * safezoneH + safezoneY;
       w = 0.0807813 * safezoneW;
       h = 0.0235 * safezoneH;
       action = "_nil=[]Spawn fnc_add_10_credits";
     };
     class cashout_BTN: RscButton
     {
       idc = 1603;
       text = "CASH OUT";
       x = 0.6175 * safezoneW + safezoneX;
       y = 0.5705 * safezoneH + safezoneY;
       w = 0.05875 * safezoneW;
       h = 0.0235 * safezoneH;
       action = "closeDialog 3000;";
     };
   };
};
 
Last edited:
so the problem is get this error in the client RPT
Code:
Error in expression <};
fnc_display_pictures = {

if (_reel1 = "cherry") then {
ctrlSetText [1200, "p>
  Error position: <= "cherry") then {
ctrlSetText [1200, "p>
  Error Missing )
File mpmissions\__CUR_MP.Chernarus\scripts\gambling\slotmachine\slots.sqf, line 135

now i cant figure out what the hell is going wrong, oh this is the first time ive messed with dialogs to so go easy :p


i call the slots.sqf from my admin menu
 
Last edited:
is it out now? i think the problem was, that your if statment gotten only 1 "="
so better use
Code:
if (_reel1 == "cherry") then {
 
is it out now? i think the problem was, that your if statment gotten only 1 "="
so better use
Code:
if (_reel1 == "cherry") then {
its in the repack and your right it was the missing =, i have mad a;ot of changes to the code now to and got it working just right :p ill release it as stand alone script soon :0
 
Back
Top