Two animations combined, possible?
#1

Is it possible to combine two animations? Like, add one with Applyanimation and the second one as SetPlayerSpecialAction

I'm trying to pickup a box with ApplyAnimation(playerid, "MISC", "pickup_box" and then hold the box with SetPlayerSpecialAction(playerid,SPECIAL_ACTION_CAR RY);

If it dosen't work, is it possible to like freeze the pickup_box anim the last second when the character is in a holding position?
Reply
#2

As long as you don't intend to show them once at the same time then yes it is possible
Reply
#3

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
As long as you don't intend to show them once at the same time then yes it is possible
I'm not quite sure how to script it with two different animations. Would you mind create an example?
Reply
#4

Sadly, there's no native OnAnimationFinished callback. However, since animations are the same each time, you can time how long it takes and set a timer to set the special action to CARRY when the time the animation takes to finish completes. This is the best way, just make sure you have a safeguard to prevent unlimited timers being created with spamming the animation sequence.
Reply
#5

This should be something good to learn from
pawn Код:
#include <a_samp>
#include <zcmd>

new
    g_PlayerCarryState[MAX_PLAYERS],
    g_PlayerCarryTime[MAX_PLAYERS],
    g_CarryTimer = 0
;

enum {
    CARRY_STATE_OFF,
    CARRY_STATE_PICKUP,
    CARRY_STATE_HOLD,
    CARRY_STATE_DROP
}

public OnFilterScriptInit() {
    g_CarryTimer = SetTimer("CarryTimer", 200, true);
}

public OnFilterScriptExit() {
    KillTimer(g_CarryTimer);
}

public OnPlayerStateChange(playerid, newstate, oldstate) {
    switch(newstate) {
        case PLAYER_STATE_DRIVER, PLAYER_STATE_PASSENGER, PLAYER_STATE_SPECTATING, PLAYER_STATE_WASTED: {
            if( g_PlayerCarryState[playerid] != CARRY_STATE_OFF ) {
                g_PlayerCarryState[playerid] = CARRY_STATE_OFF;
                // Drop package here
            }
        }
    }

    return 1;
}

forward CarryTimer();
public CarryTimer() {
    for(new playerid, max_playerid = GetPlayerPoolSize(); playerid <= max_playerid; playerid ++) {
        if( !IsPlayerConnected(playerid) ) {
            continue;
        }

        if( g_PlayerCarryState[playerid] == CARRY_STATE_OFF ) {
            continue;
        }

        if( g_PlayerCarryTime[playerid] > GetTickCount() ) {
            continue;
        }

        switch( g_PlayerCarryState[playerid] ) {
            case CARRY_STATE_PICKUP: {
                g_PlayerCarryState[playerid] ++;
                SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
                // Apply hold object here with new offsets
            }
            case CARRY_STATE_DROP: {
                g_PlayerCarryState[playerid] = CARRY_STATE_OFF;
                SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
                // Remove hold object here
            }
        }
    }
}

CMD:carry(playerid, params[]) {
    if( g_PlayerCarryState[playerid] == CARRY_STATE_OFF ) {
        g_PlayerCarryState[playerid] = CARRY_STATE_PICKUP;
        g_PlayerCarryTime[playerid] = GetTickCount() + 2000; // Adjust this number until the both animations overlap nicely
        // ApplyAnimation(playerid, "MISC", "pickup_box" ...
        // Apply hold object here
    } else {
        g_PlayerCarryState[playerid] = CARRY_STATE_OFF;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)