Portal SAMP
[Tutorial] fazer o ped sentar e se alimentar igual ao singplayer - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Guias e Tutoriais (https://portalsamp.com/forumdisplay.php?fid=7)
+--- Tópico: [Tutorial] fazer o ped sentar e se alimentar igual ao singplayer (/showthread.php?tid=3994)



fazer o ped sentar e se alimentar igual ao singplayer - zBreno - 23/09/2023



se ficou confuso pra alguém você primeiro tem que aplicar a animação do ped sentando depois você liga o air bake ativa o modo lento dele e arrasta o ped pra cadeira depois aplica a animação do ped levantando seu ped vai ficar na posição certa de sentar e levantar você salva a sua posição e já era na animação da comida você tem que usar a posição do objeto da cadeira pra o ped poder ficar sentado

o que foi usado no video

Código PHP:
CMD:r(playeridparams[]) return ApplyAnimation(playerid"FOOD""FF_Sit_In_R"4.100010);
CMD:rout(playeridparams[]) return ApplyAnimation(playerid"FOOD""FF_Sit_Out_R_180"4.001100);
CMD:l(playeridparams[]) return ApplyAnimation(playerid"FOOD""FF_Sit_In_L"4.100010);
CMD:lout(playeridparams[]) return ApplyAnimation(playerid"FOOD""FF_Sit_Out_L_180"4.001100);
CMD:f(playeridparams[]) return ApplyAnimation(playerid"FOOD""FF_Sit_Eat1"4.100010);


ApplyAnimation(playerid"FOOD""FF_Sit_In_R"4.100010);
ApplyAnimation(playerid"FOOD""FF_Sit_Out_R_180"4.001100);

ApplyAnimation(playerid"FOOD""FF_Sit_In_L"4.100010);
ApplyAnimation(playerid"FOOD""FF_Sit_Out_L_180"4.001100);

SetPlayerAttachedObject(playerid,0,2880,6,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,1.000000,1.000000,1.000000);

new 
eating0[MAX_PLAYERS];
forward eat0(playerid);
new 
eating1[MAX_PLAYERS];
forward eat1(playerid);
new 
eating2[MAX_PLAYERS]; 
forward eat2(playerid);
new 
eating3[MAX_PLAYERS];
forward eat3(playerid);
new 
eating4[MAX_PLAYERS];
forward eat4(playerid);

new 
Sentado[MAX_PLAYERS];
new 
contar[MAX_PLAYERS];

CMD:comer(playeridparams[])
{
Sentado[playerid] = 1;
SetPlayerPos(playerid812.16058, -1612.0012213.07880); // posição do objeto da cadeira na rua
ApplyAnimation(playerid"FOOD""FF_Sit_Eat1"4.100010);
SetPlayerAttachedObject(playerid,0,2880,6,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,1.000000,1.000000,1.000000);
eating0[playerid] = SetTimerEx("eat0"1000true"i"playerid);
return 
1;
}


CMD:sentar(playeridparams[])
{
if(
Sentado[playerid] == 0)
{
if(
IsPlayerInRangeOfPoint(playerid2.0812.0838, -1612.968813.5873))
{
SetPlayerPos(playerid812.0838, -1612.968813.5873);
SetPlayerFacingAngle(playerid265.0771);
ApplyAnimation(playerid"FOOD""FF_Sit_In_R"4.100010);
Sentado[playerid] = 1;
}
}
return 
1;
}

CMD:levantar(playeridparams[])
{
if(
Sentado[playerid] == 1)
{
ApplyAnimation(playerid"FOOD""FF_Sit_Out_R_180"4.001100);
RemovePlayerAttachedObject(playerid0);
Sentado[playerid] = 0;
}
return 
1;
}


public 
eat0(playerid)
{
contar[playerid]++;
ApplyAnimation(playerid"FOOD""FF_Sit_Eat1"4.100010);
if(
contar[playerid] >= 20
{
contar[playerid] = 0;
KillTimer(eating0[playerid]);
eating1[playerid] = SetTimerEx("eat1"2000true"i"playerid);
new 
Float:XFloat:YFloat:Z;
GetPlayerPos(playerid,XYZ);
PlayerPlaySound(playerid32200XYZ);
}
return 
1;
}

public 
eat1(playerid)
{
contar[playerid]++;
ApplyAnimation(playerid"FOOD""FF_Sit_Eat2"4.100010);
if(
contar[playerid] >= 20
{
contar[playerid] = 0;
KillTimer(eating1[playerid]);
eating2[playerid] = SetTimerEx("eat2"2000true"i"playerid);
new 
Float:XFloat:YFloat:Z;
GetPlayerPos(playerid,XYZ);
PlayerPlaySound(playerid32200XYZ);
}
return 
1;
}

public 
eat2(playerid)
{
contar[playerid]++;
ApplyAnimation(playerid"FOOD""FF_Sit_Eat3"4.100010);
if(
contar[playerid] >= 20
{
contar[playerid] = 0;
KillTimer(eating2[playerid]);
eating3[playerid] = SetTimerEx("eat3"2000true"i"playerid);
new 
Float:XFloat:YFloat:Z;
GetPlayerPos(playerid,XYZ);
PlayerPlaySound(playerid32200XYZ);
}
return 
1;
}

public 
eat3(playerid)
{
contar[playerid]++;
ApplyAnimation(playerid"FOOD""FF_Sit_Look"4.000010);
if(
contar[playerid] >= 10
{
contar[playerid] = 0;
KillTimer(eating3[playerid]);
eating4[playerid] = SetTimerEx("eat4"2000true"i"playerid);
}
return 
1;
}

public 
eat4(playerid)
{
contar[playerid]++;
ApplyAnimation(playerid"FOOD""FF_Sit_Loop"4.000010);
if(
contar[playerid] >= 10
{
contar[playerid] = 0;
KillTimer(eating4[playerid]);
RemovePlayerAttachedObject(playerid,0);
iseating[playerid] = false;
new 
Float:XFloat:YFloat:Z;
GetPlayerPos(playerid,XYZ);
PlayerPlaySound(playerid6401XYZ); //
}
return 
1;