Jump to content

Jewpiter

Member
  • Content Count

    2
  • Joined

  • Last visited

  • Medals

Posts posted by Jewpiter


  1. I am trying to make a script that will allow me to start dancing to a music and stop dancing whenever I would like (multiplayer compatible).

    I made 2 scripts, one for the dancing action and another one which controls the "stop dancing" action

    this is dance.sqf

    _caller= _this select 1;
    _id = _this select 2;
    playmusic "song";
    _caller removeAction _id;
    _stopdance = _caller addaction ["Stop Dancing","stopdance.sqf"];
    _caller setVariable ["dance",true];
    
    _caller playmove "ActsPercMstpSnonWnonDnon_DancingDuoStefan";
    _dance=_caller getvariable "dance";
    for [{_x=1},{((_x<=42) and (_dance))},{_x=_x+1}] do 
    {
    sleep 1;
    _dance=_caller getvariable "dance";
    };
    _dance=_caller getvariable "dance";
    if (_dance) then {
    _caller playmove "ActsPercMstpSnonWnonDnon_DancingDuoIvan";	
    for [{_x=1},{((_x<=39) and (_dance))},{_x=_x+1}] do 
    {
    	sleep 1;
    	_dance=_caller getvariable "dance";
    };
    };
    _dance=_caller getvariable "dance";
    if (_dance) then {
    _caller playmove "ActsPercMstpSnonWnonDnon_DancingDuoIvan";	
    for [{_x=1},{((_x<=39) and (_dance))},{_x=_x+1}] do 
    {
    	sleep 1;
    	_dance=_caller getvariable "dance";
    };
    };
    _dance=_caller getvariable "dance";
    if (_dance) then {
    _caller playmove "ActsPercMstpSnonWnonDnon_DancingDuoStefan";	
    for [{_x=1},{((_x<=35) and (_dance))},{_x=_x+1}] do 
    {
    	sleep 1;
    	_dance=_caller getvariable "dance";
    };
    };
    _dance=_caller getvariable "dance";
    if (_dance) then {
    _caller playmove "ActsPercMstpSnonWnonDnon_DancingDuoIvan";	
    for [{_x=1},{((_x<=30) and (_dance))},{_x=_x+1}] do 
    {
    	sleep 1;
    	_dance=_caller getvariable "dance";
    };
    };
    
    playmusic ["song",206];
    _caller switchmove "";
    try
    {
    _caller removeaction _stopdance;
    };
    _caller addaction ["Dance","dance.sqf"];

    and this is stopdance.sqf:

    _caller= _this select 1;
    _id = _this select 2;
    _caller setVariable ["dance",false];
    _caller removeaction _id;

    If I push the stop dancing action or the entire dancing ends the character should return to normal status (as in standing with weapon in hand)

    I have tried using this code:

    _caller switchmove "";

    but whenever this code executes the character returns to normal status and a dancing animation is restarted (not the entire script,just the one animation which played right before the switchmove command)

    this brings me to my question:

    How can I stop the character performing an animation?

×