Announcement

Collapse
No announcement yet.

Ticket Script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [GUIDE] Ticket Script

    Place these in the "Init.sqf"

    [] execVM "tvttickets.sqf";
    [] execVM "playerDeath.sqf";
    "tvttickets.sqf"
    Yellow colour denotes customisation to the mission needs

    ////////////////////////////////////////////////////////////////////////////
    // Name: tvttickets.sqf
    // Purpose: Handles the basic behavior of tickets in tvt. Does not
    // handle ticket modification outside of player deaths. to
    // modify those, use westTickets and eastTickets outside of
    // this script. to modify the number of tickets, change the
    // value of the constants below.
    // Author: Original author unknown, expanded, modified for TvT, and
    // commented by Zonr_0.
    /////////////////////////////////////////////////////////////////////////////

    //Modify these values to change the ticket count.
    TICKETS_WEST = 1000;
    TICKETS_EAST = 1000;


    //If the player is not the server, then wait until they join,
    //then, add an event handler to fire whenever that player is killed.
    //This fires a CBA global event which is caught by the "playedKilled"
    //block.
    if (!isDedicated) then {
    waitUntil {!isNull player};


    sleep 1;

    if (side player == WEST) then
    {
    player addEventHandler["killed", {
    ["playedKilled", WEST] call cba_fnc_globalEvent;
    }];
    };

    //Kludgy, but private variables don't work for some reason.
    if (side player == EAST) then
    {
    player addEventHandler["killed", {
    ["playedKilled", EAST] call cba_fnc_globalEvent;
    }];
    };
    };

    if (isServer) then {
    westTickets = TICKETS_WEST;
    eastTickets = TICKETS_EAST;

    //This whole block is an event handler for the server to
    //deal with the global event raised above. It is defining
    //the response to the "playedKilled" event.
    ["playedKilled", {
    private ["_killedSide"];
    _killedSide = _this;

    if (_killedSide == WEST) then {
    westTickets = westTickets - 1;
    };
    if (_killedSide == EAST) then {
    eastTickets = eastTickets - 1;
    };
    publicVariable("westTickets");
    publicVariable("eastTickets");
    if (eastTickets <= 0) then {
    [-2, {
    hint "OPFOR is out of tickets";
    sleep 10;
    endMission "END1";
    }] call cba_fnc_globalExecute; //Execute on all machines
    };
    if (westTickets <= 0) then {
    [-2, {
    hint "BLUFOR is out of tickets";
    sleep 10;
    endmission "END2";
    }] call cba_fnc_globalExecute;
    }
    }] call cba_fnc_addEventHandler;
    };
    "playerDeath.sqf"
    if (!isDedicated) then {
    waitUntil {!isNull player};
    player addEventHandler ["killed", {
    ["playedKilled"] call cba_fnc_globalEvent;
    }];
    };

    if (isServer) then {
    tickets = 1000;

    ["playedKilled", {
    tickets = tickets -1;
    if (tickets <= 0) then {
    [-2, { hint "no more tickets, mission failed"; sleep 10; endMission "loser"; }] call cba_fnc_globalExecute;
    };
    }] call cba_fnc_addEventHandler;
    };
    Then add a trigger in mission editor, with:
    Condition: tickets = 0
    Type: Loose
    *no need to touch the rest of the options.
    Last edited by LowSpeedHighDrag; 03-29-2012, 08:57 PM. Reason: edit

    TGU Instructor TG Pathfinder

    Former TGU Dean Former ARMA Admin Former Irregulars Officer

    "Do not seek death. Death will find you. But seek the road which makes death a fulfillment." - Dag Hammarskjold

  • #2
    Re: Ticket Script

    I was wondering how to do tickets...very cool, thanks!
    sigpic
    [squadl][conduct]



    Comment


    • #3
      Re: Ticket Script

      no problems

      TGU Instructor TG Pathfinder

      Former TGU Dean Former ARMA Admin Former Irregulars Officer

      "Do not seek death. Death will find you. But seek the road which makes death a fulfillment." - Dag Hammarskjold

      Comment


      • #4
        Re: Ticket Script

        So the second one is a ticket system for a coop mission? doenst matter what side the players are on?

        My name: Adept a skilled or proficient person Abyss a deep, immeasurable space, gulf, or cavity
        So I'm a very skilled deep hole :D

        Comment


        • #5
          Re: Ticket Script

          Yeppers

          TGU Instructor TG Pathfinder

          Former TGU Dean Former ARMA Admin Former Irregulars Officer

          "Do not seek death. Death will find you. But seek the road which makes death a fulfillment." - Dag Hammarskjold

          Comment


          • #6
            Re: Ticket Script

            So trying this code out and cant get it to work right

            Code:
            if (!isDedicated) then {
            waitUntil {!isNull player};
            player addEventHandler ["killed", {
            ["playedKilled"] call cba_fnc_globalEvent;
            }];
            };
            
            if (isServer) then {
            tickets = 53;
            
            ["playedKilled", {
            tickets = tickets -1;
            if (tickets <= 0) then {
            [-2, { hint "no more tickets, mission failed"; sleep 10; endMission "loser"; }] call cba_fnc_globalExecute;
            };
            }] call cba_fnc_addEventHandler;
            };
            Have this in tickets.sqf and [] execVM "tickets.sqf"; in int file but when the game runs the first time someone dies it ends the mission with, no more tickets mission failed hint. any idea what I've done wrong?

            Does placed AI effect the script?

            My name: Adept a skilled or proficient person Abyss a deep, immeasurable space, gulf, or cavity
            So I'm a very skilled deep hole :D

            Comment


            • #7
              Re: Ticket Script

              You need BOTH scripts running.

              TGU Instructor TG Pathfinder

              Former TGU Dean Former ARMA Admin Former Irregulars Officer

              "Do not seek death. Death will find you. But seek the road which makes death a fulfillment." - Dag Hammarskjold

              Comment


              • #8
                Re: Ticket Script

                It'd be nice to have a script that just stops respawns after you run out of tickets, rather than just ending the mission.

                Pepper

                "If you find yourself in a fair fight, you didn't plan your mission properly." David Hackworth

                Comment


                • #9
                  Originally posted by Athanasa View Post
                  It'd be nice to have a script that just stops respawns after you run out of tickets, rather than just ending the mission.
                  Cool

                  Sent thru the ether via Tapatalk.
                  |TG-189th| Unkl
                  ArmA 3 Game Officer
                  Dean of Tactical Gamer University
                  189th Infantry Brigade Member
                  SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
                  "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

                  Comment


                  • #10
                    Re: Ticket Script

                    Still having problems with the code, I copied the exact code from above, got the trigger and init file but still no luck, ends after the first death, What am I missing?


                    Does it need to be run on a dedicated server?
                    Last edited by AdeptAbyss; 03-30-2012, 03:18 PM.

                    My name: Adept a skilled or proficient person Abyss a deep, immeasurable space, gulf, or cavity
                    So I'm a very skilled deep hole :D

                    Comment


                    • #11
                      Re: Ticket Script

                      Originally posted by AdeptAbyss View Post
                      Still having problems with the code, I copied the exact code from above, got the trigger and init file but still no luck, ends after the first death, What am I missing?


                      Does it need to be run on a dedicated server?
                      Glancing at the code, it looks like it doesn't need to be run on a dedicated server.

                      Assuming you correctly followed the instructions in implementing this script into your mission, the next thing I would try to do is debugging the code. My assumption (and I might be wrong since it's been a while since I've looked at .sqf coding) is that when the player dies, it continues to trigger the cba function (cba_fnc_globalExecute) in which case that will decrement the ticket count until it reaches less than or equal to 0 which then triggers the end of mission. Try and see if you can display the value of the global ticket variable on the screen with a simple hint message.
                      Code:
                      if (isServer) then {
                      tickets = 53;
                      
                      ["playedKilled", {
                      tickets = tickets -1;
                      hint format["tickets = %1", tickets];
                      if (tickets <= 0) then {
                      [-2, { hint "no more tickets, mission failed"; sleep 10; endMission "loser"; }] call cba_fnc_globalExecute;
                      };
                      }] call cba_fnc_addEventHandler;
                      };
                      This will allow you to see how many ticket counts there are left after a player dies.


                      IN GAME ARMA: |TG-Irr| Lq.Snake

                      Comment

                      Connect

                      Collapse

                      TeamSpeak 3 Server

                      Collapse

                      Advertisement

                      Collapse

                      Twitter Feed

                      Collapse

                      Working...
                      X