[FilterScript] Advanced Animation System[Simple and Effective]
#1

Preface

Hello guys, recently I want open my animation system soure for you but mine is a Chinese verision(there are a lot of Chinese init), so I decided to put my tutorial here.

Suggestion

maybe your server are still using command like "/hide" or "enter", but I think since server can detect KeyChange, we should make players easy to play.

My server has no command, they just move to key-change detect or dialog.

Tutorial

1.Firstly. You must have an animation list which contains ordinary actions and special actions.
pawn Код:
// We need a Enum to show what we will use.
enum AnimItemInfo {
    bool:IsSpecialAction,             // We do this for separating actions and special actions.
    Name[16],                           // Whats name of this animation.
    SpecialAction,                      // If the anim is a special actions, we give him a special action marco.
    animlib[16],                         // {animlib to time} is infomation of ordinary action .
    animname[24],
    Float:fDelta,
    loop,
    lockx,
    locky,
    freeze,
    time
}

// We use constant array to save our animation.
// Because in-game changing animation list is not necessary.
// I give you two examples here. one for special action and another for ordinary action

stock const AnimItem[][AnimItemInfo] = {
  {true,  "hansup",      SPECIAL_ACTION_HANDSUP,    "\0",   "\0",      0.0, 0, 0, 0, 0, 0},
  {false, "hide",          SPECIAL_ACTION_NONE,         "ped", "cower", 3.0, 1, 0, 0, 0, 0}
}
2.Secondly. We initialise this animation list. animation list dont need to create anytime you use it.
(Just for dialog version, and if you want a command verison, please DIY, tips: use "/%s" with for-loop for search animations);
pawn Код:
new AnimationList[2048], // max length of a dialog.

// We make a new function to do this.

InitialiseAnimationSystem() {
  for(new i=0, item[16];i<sizeof(AnimItem);i++) {
        format(item, sizeof(item), "%s\n", AnimItem[i][Name]); // this for every anmation name
        strcat(AnimationList, item, sizeof(AnimationList));        // this insert every anamtion name insert to list.
  }
}
3.Finally. We show the list for player who want do a animation and give actions for player who responsed.

pawn Код:
// We make player can do a animation only onfoot mode.
// if player press 'Y' or other else, we show the dialog.
// and press 'N', we stop his/her animation.

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
    switch(GetPlayerState(playerid)) {
        case PLAYER_STATE_ONFOOT: {
            switch(newkeys) {
                case KEY_YES: ShowPlayerDialog(playerid, DIALOG_ANIM_LIST, DIALOG_STYLE_LIST, "Animation List", AnimationList, "Yes","No");
                case KEY_NO: {
                    ClearAnimForPlayer(playerid);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
                }
            }
        }
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
    switch (dialogid) {
        case DIALOG_ANIM_LIST: {
            if(!response) return 1;
            // listitem is the id of animation;
            // so if the anim is a special aninmation
            if(AnimItem[listitem][IsSpecialAction]) SetPlayerSpecialAction(playerid, AnimItem[listitem][SpecialAction]);
            // or not .
            else ApplyAnimation(playerid, AnimItem[listitem][animlib], AnimItem[listitem][animname], AnimItem[listitem][fDelta], AnimItem[listitem][loop], AnimItem[listitem][lockx], AnimItem[listitem][locky], AnimItem[listitem][freeze], AnimItem[listitem][time]);

            // here  you should give players a point to stop anim.
        }
    }
    return 1;
}
100 lines.
A faster, simpler, Effective dialog THAN your 1000+ lines commands.

DONT USE IT BY COPY.
Reply
#2

I think this must be posted in tutorial section.
Reply
#3

Quote:
Originally Posted by Team_PRO
Посмотреть сообщение
I think this must be posted in tutorial section.
Sorry I posted here.
Because some guy coding a lot of animation script which doesnt effective.
no offense
Reply
#4

It will be good if you will make it in filterscript form rather than posting codes here.
Reply
#5

Nice animations!!!
Reply
#6

Quote:
Originally Posted by Warlord
Посмотреть сообщение
It will be good if you will make it in filterscript form rather than posting codes here.
I will but not now,
I think if i do this, newbies will lose their enthusiasm.
Do you think why ****** or other people not do this ?



TRY IT YOURSELF,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)