06.03.2014, 00:18
(
Последний раз редактировалось mahardika; 07.03.2014 в 07:01.
Причина: Big Image
)
Player Walk Style by Mahardika
This Tutorial Will Change The Walk Style not use the UsePlayerPedAnims();
Sorry For The Bad English, if u found bug or somethin' Reply!
Okay Lets Go
First Of All We Need to include The Includes!
Add Some define For the walking Style
And The Next We Need To Crate Player Variables
You Can Put it under all Defines
Strcmp Version, if you want to use this ( IF YOU WANT TO USE ZCMD DONT USE THIS LINE )
put under public OnPlayerCommandText(playerid, cmdtext[])
( IF YOU WANT TO USE ZCMD DONT USE THIS LINE )
so it will be like this
ZCMD version ( no need public OnPlayerCommandText(playerid, cmdtext[]) )
Old : http://pastebin.com/1RjeqCm3
Put When The Player Spawning ( by default = OnPlayerSpawn )
To Load The Anim Lib
put in public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) to check player is walking
So it Will be like this
Stocks and Timer
Put it Under all The script
Reseting The Player Variable
Put On OnPlayerConnect and on player dissconnect
Is That All?
Yep!
if You Make This as FilterScript
it will look like
This! (With ZCMD)
Thanks For Thanks To CrazyFrenzy To the Feedback
This Tutorial Will Change The Walk Style not use the UsePlayerPedAnims();
Sorry For The Bad English, if u found bug or somethin' Reply!
Okay Lets Go
First Of All We Need to include The Includes!
pawn Код:
//You cant do anything without this
#include <a_samp> //by Samp Team
// For Command Process (if you want to use it )
#include <zcmd> //by ZeeX
pawn Код:
//walkstyle defines by NewDIvine
#define WALK_DEFAULT (0)
#define WALK_NORMAL (1)
#define WALK_PED (2)
#define WALK_GANGSTA (3)
#define WALK_GANGSTA2 (4)
#define WALK_OLD (5)
#define WALK_FAT_OLD (6)
#define WALK_FAT (7)
#define WALK_LADY (8)
#define WALK_LADY2 (9)
#define WALK_WHORE (10)
#define WALK_WHORE2 (11)
#define WALK_DRUNK (12)
#define WALK_BLIND (13)
// Define The Color
#define COLOR_WHITE 0xFFFFFFFF //0xRRGGBBAA
You Can Put it under all Defines
pawn Код:
new walktime[MAX_PLAYERS]; // for timer
new PlayerWalkStyle[MAX_PLAYERS]; // for the walk style
put under public OnPlayerCommandText(playerid, cmdtext[])
pawn Код:
new cmd[128], idx;
cmd = strtok(cmdtext, idx); //This (strtok) is used to search a string and find a variable typed after a " " (space), then return it as a string.
if (strcmp(cmd, "/walkstyle", true) == 0) // checking if he typed /walkstyle
{
new tmp[128];
tmp = strtok(cmdtext, idx);
if(strval(tmp) < 1 || strval(tmp) > 11) //Check if the params is not lower then 1 and bigger then 11
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /walkstyle [1-11]"); // Send A Error Message
SetPlayerWalkingStyle(playerid, strval(tmp)); // if Sucsess, Set The Player Walking Style
return 1;
}
so it will be like this
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx); //This (strtok) is used to search a string and find a variable typed after a " " (space), then return it as a string.
if (strcmp(cmd, "/walkstyle", true) == 0) // checking if he typed /walkstyle
{
new tmp[128];
tmp = strtok(cmdtext, idx);
if(strval(tmp) < 1 || strval(tmp) > 11) //Check if the params is not lower then 1 and bigger then 11
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /walkstyle [1-11]"); // Send A Error Message
SetPlayerWalkingStyle(playerid, strval(tmp)); // if Sucsess, Set The Player Walking Style
return 1;
}
return 0;
}
Old : http://pastebin.com/1RjeqCm3
pawn Код:
//UPDATED Thanks To CrazyFrenzy
CMD:walkstyle(playerid, params[])
{
if(strval(params) < 1 || strval(params) > 11) //Check if the params is not lower then 1 and bigger then 11
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /walkstyle [1-11]"); // Send A Error Message
SetPlayerWalkingStyle(playerid, strval(params)); // if Sucsess, Set The Player Walking Style
return 1;
}
To Load The Anim Lib
pawn Код:
PreloadAnimLib(playerid, "PED");
pawn Код:
//Check if player Pressing The Key
if (((newkeys & KEY_WALK && newkeys & KEY_UP) || (newkeys & KEY_WALK && newkeys & KEY_DOWN) || (newkeys & KEY_WALK && newkeys & KEY_LEFT) || (newkeys & KEY_WALK && newkeys & KEY_RIGHT))
|| ((oldkeys & KEY_WALK && newkeys & KEY_UP) || (oldkeys & KEY_WALK && newkeys & KEY_DOWN) || (oldkeys & KEY_WALK && newkeys & KEY_LEFT) || (oldkeys & KEY_WALK && newkeys & KEY_RIGHT))
|| ((newkeys & KEY_WALK && oldkeys & KEY_UP) || (newkeys & KEY_WALK && oldkeys & KEY_DOWN) || (newkeys & KEY_WALK && oldkeys & KEY_LEFT) || (newkeys & KEY_WALK && oldkeys & KEY_RIGHT))
&& GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) { // if player are on foot, not at vehs
walktime[playerid] = SetTimerEx("WalkAnim",200,0,"d",playerid); // set the timer
}
PHP код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
//Check if player Pressing The Key
if (((newkeys & KEY_WALK && newkeys & KEY_UP) || (newkeys & KEY_WALK && newkeys & KEY_DOWN) || (newkeys & KEY_WALK && newkeys & KEY_LEFT) || (newkeys & KEY_WALK && newkeys & KEY_RIGHT))
|| ((oldkeys & KEY_WALK && newkeys & KEY_UP) || (oldkeys & KEY_WALK && newkeys & KEY_DOWN) || (oldkeys & KEY_WALK && newkeys & KEY_LEFT) || (oldkeys & KEY_WALK && newkeys & KEY_RIGHT))
|| ((newkeys & KEY_WALK && oldkeys & KEY_UP) || (newkeys & KEY_WALK && oldkeys & KEY_DOWN) || (newkeys & KEY_WALK && oldkeys & KEY_LEFT) || (newkeys & KEY_WALK && oldkeys & KEY_RIGHT))
&& GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) { // if player are on foot, not at vehs
walktime[playerid] = SetTimerEx("WalkAnim",200,0,"d",playerid); // set the timer
}
return 1;
}
Put it Under all The script
pawn Код:
stock SetPlayerWalkingStyle(playerid, style) // set the player walking style
{
PlayerWalkStyle[playerid] = style;
}
stock GetPlayerWalkingStyle(playerid) // get the player walking style
{
return PlayerWalkStyle[playerid];
}
stock PreloadAnimLib(playerid, animlib[])
{
ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
}
//UPDATED Thanks To CrazyFrenzy
//Old : http://pastebin.com/8W2Hzfsg
forward WalkAnim(playerid); // forwarding the timer function
public WalkAnim(playerid) // Function of The Timer
{
new keys, updown, leftright;
GetPlayerKeys(playerid,keys,updown,leftright); // Get The Player Pressed Key
if ((keys & KEY_WALK && updown & KEY_UP) || (keys & KEY_WALK && updown & KEY_DOWN) || (keys & KEY_WALK && leftright & KEY_LEFT) || (keys & KEY_WALK && leftright & KEY_RIGHT)) // if player pressed Key to Walk
{
KillTimer(walktime[playerid]); // kill the walk timer if player was walked before
switch(GetPlayerWalkingStyle(playerid)) // switching The PlayerWalkStyle
{
//Aplly The Walk Anim
case 1: ApplyAnimation(playerid,"PED","WALK_player",4.1,1,1,1,1,1);
case 2: ApplyAnimation(playerid,"PED","WALK_civi",4.1,1,1,1,1,1);
case 3: ApplyAnimation(playerid,"PED","WALK_gang1",4.1,1,1,1,1,1);
case 4: ApplyAnimation(playerid,"PED","WALK_gang2",4.1,1,1,1,1,1);
case 5: ApplyAnimation(playerid,"PED","WALK_old",4.1,1,1,1,1,1);
case 6: ApplyAnimation(playerid,"PED","WALK_fatold",4.1,1,1,1,1,1);
case 7: ApplyAnimation(playerid,"PED","WALK_fat",4.1,1,1,1,1,1);
case 8: ApplyAnimation(playerid,"PED","WOMAN_walknorm",4.1,1,1,1,1,1);
case 9: ApplyAnimation(playerid,"PED","WOMAN_walkbusy",4.1,1,1,1,1,1);
case 10: ApplyAnimation(playerid,"PED","WOMAN_walkpro",4.1,1,1,1,1,1);
case 11: ApplyAnimation(playerid,"PED","WOMAN_walksexy",4.1,1,1,1,1,1);
case 12: ApplyAnimation(playerid,"PED","Walk_Wuzi",4.1,1,1,1,1,1);
default: ClearAnimations(playerid); // if player not choosed a Walk Style, Not Playing Anim
}
walktime[playerid] = SetTimerEx("WalkAnim",200,0,"d",playerid); //Set The Timer For Looping The Anims
}
return true;
}
strtok(const string[], &index) //This (strtok) is used to search a string and find a variable typed after a " " (space), then return it as a string.
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
Put On OnPlayerConnect and on player dissconnect
pawn Код:
PlayerWalkStyle[playerid] = 0;
Yep!
if You Make This as FilterScript
it will look like
This! (With ZCMD)
PHP код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
//You cant do anything without this
#include <a_samp> //by Samp Team
// For Command Process (if you want to use it )
#include <zcmd> //by ZeeX
//walkstyle defines by NewDIvine
#define WALK_DEFAULT (0)
#define WALK_NORMAL (1)
#define WALK_PED (2)
#define WALK_GANGSTA (3)
#define WALK_GANGSTA2 (4)
#define WALK_OLD (5)
#define WALK_FAT_OLD (6)
#define WALK_FAT (7)
#define WALK_LADY (8)
#define WALK_LADY2 (9)
#define WALK_WHORE (10)
#define WALK_WHORE2 (11)
#define WALK_DRUNK (12)
#define WALK_BLIND (13)
// Define The Color
#define COLOR_WHITE 0xFFFFFFFF //0xRRGGBBAA
new walktime[MAX_PLAYERS]; // for timer
new PlayerWalkStyle[MAX_PLAYERS]; // for the walk style
#if defined FILTERSCRIPT // if this is a Filterscript
public OnFilterScriptInit() // func when filterscript was started
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print(" With Player Walking Style System By Mahardika!");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
PlayerWalkStyle[playerid] = 0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
PlayerWalkStyle[playerid] = 0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx); //This (strtok) is used to search a string and find a variable typed after a " " (space), then return it as a string.
if (strcmp(cmd, "/walkstyle", true) == 0) // checking if he typed /walkstyle
{
new tmp[128];
tmp = strtok(cmdtext, idx);
if(strval(tmp) < 1 || strval(tmp) > 11) //Check if the params is not lower then 1 and bigger then 11
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /walkstyle [1-11]"); // Send A Error Message
SetPlayerWalkingStyle(playerid, strval(tmp)); // if Sucsess, Set The Player Walking Style
return 1;
}
return 0;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
//Check if player Pressing The Key
if (((newkeys & KEY_WALK && newkeys & KEY_UP) || (newkeys & KEY_WALK && newkeys & KEY_DOWN) || (newkeys & KEY_WALK && newkeys & KEY_LEFT) || (newkeys & KEY_WALK && newkeys & KEY_RIGHT))
|| ((oldkeys & KEY_WALK && newkeys & KEY_UP) || (oldkeys & KEY_WALK && newkeys & KEY_DOWN) || (oldkeys & KEY_WALK && newkeys & KEY_LEFT) || (oldkeys & KEY_WALK && newkeys & KEY_RIGHT))
|| ((newkeys & KEY_WALK && oldkeys & KEY_UP) || (newkeys & KEY_WALK && oldkeys & KEY_DOWN) || (newkeys & KEY_WALK && oldkeys & KEY_LEFT) || (newkeys & KEY_WALK && oldkeys & KEY_RIGHT))
&& GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) { // if player are on foot, not at vehs
walktime[playerid] = SetTimerEx("WalkAnim",200,0,"d",playerid); // set the timer
}
return 1;
}
CMD:walkstyle(playerid, params[])
{
if(strval(params) < 1 || strval(params) > 11) //Check if the params is not lower then 1 and bigger then 11
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /walkstyle [1-11]"); // Send A Error Message
SetPlayerWalkingStyle(playerid, strval(params)); // if Sucsess, Set The Player Walking Style
return 1;
}
stock SetPlayerWalkingStyle(playerid, style) // set the player walking style
{
PlayerWalkStyle[playerid] = style;
}
stock GetPlayerWalkingStyle(playerid) // get the player walking style
{
return PlayerWalkStyle[playerid];
}
stock PreloadAnimLib(playerid, animlib[])
{
ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
//UPDATED Thanks To CrazyFrenzy
//Old : http://pastebin.com/8W2Hzfsg
forward WalkAnim(playerid); // forwarding the timer function
public WalkAnim(playerid) // Function of The Timer
{
new keys, updown, leftright;
GetPlayerKeys(playerid,keys,updown,leftright); // Get The Player Pressed Key
if ((keys & KEY_WALK && updown & KEY_UP) || (keys & KEY_WALK && updown & KEY_DOWN) || (keys & KEY_WALK && leftright & KEY_LEFT) || (keys & KEY_WALK && leftright & KEY_RIGHT)) // if player pressed Key to Walk
{
KillTimer(walktime[playerid]); // kill the walk timer if player was walked before
switch(GetPlayerWalkingStyle(playerid)) // switching The PlayerWalkStyle
{
//Aplly The Walk Anim
case 1: ApplyAnimation(playerid,"PED","WALK_player",4.1,1,1,1,1,1);
case 2: ApplyAnimation(playerid,"PED","WALK_civi",4.1,1,1,1,1,1);
case 3: ApplyAnimation(playerid,"PED","WALK_gang1",4.1,1,1,1,1,1);
case 4: ApplyAnimation(playerid,"PED","WALK_gang2",4.1,1,1,1,1,1);
case 5: ApplyAnimation(playerid,"PED","WALK_old",4.1,1,1,1,1,1);
case 6: ApplyAnimation(playerid,"PED","WALK_fatold",4.1,1,1,1,1,1);
case 7: ApplyAnimation(playerid,"PED","WALK_fat",4.1,1,1,1,1,1);
case 8: ApplyAnimation(playerid,"PED","WOMAN_walknorm",4.1,1,1,1,1,1);
case 9: ApplyAnimation(playerid,"PED","WOMAN_walkbusy",4.1,1,1,1,1,1);
case 10: ApplyAnimation(playerid,"PED","WOMAN_walkpro",4.1,1,1,1,1,1);
case 11: ApplyAnimation(playerid,"PED","WOMAN_walksexy",4.1,1,1,1,1,1);
case 12: ApplyAnimation(playerid,"PED","Walk_Wuzi",4.1,1,1,1,1,1);
default: ClearAnimations(playerid); // if player not choosed a Walk Style, Not Playing Anim
}
walktime[playerid] = SetTimerEx("WalkAnim",200,0,"d",playerid); //Set The Timer For Looping The Anims
}
return true;
}