10.11.2014, 09:45
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.
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);
3.Finally. We show the list for player who want do a animation and give actions for player who responsed.
100 lines.
A faster, simpler, Effective dialog THAN your 1000+ lines commands.
DONT USE IT BY COPY.
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}
}
(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.
}
}
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;
}
A faster, simpler, Effective dialog THAN your 1000+ lines commands.
DONT USE IT BY COPY.