// 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}
}
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.
}
}
// 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;
}
It will be good if you will make it in filterscript form rather than posting codes here.
|