[Ajuda] Modo de segurar arma como CJ sem UsePlayerPedAnims();
#1

As animaзхes que faz qnd estб com UsePlayerPedAnims(); e AK,SHOTGUN,M4 sгo muito foda, mas eu queria que os jogadores corressem de vagar, como os pedestres entгo tirei UsePlayerPedAnims();...

Mas queria que quando eles segurassem armas pesadas, eles fizessem as animaзхes que tem em UsePlayerPedAnims();

Entгo fiz esse script:
Код:
	if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) 
	{
		new w = GetPlayerWeapon(playerid);
		if(w == 25 || w == 27 || w == 30 || w == 31 || w == 33 || w == 34) {
			if(GetPlayerSpeed(playerid, true) >= 1) {
				if(GetPlayerAnimationIndex(playerid) != 1223) ApplyAnimation(playerid, "PED", "RUN_ARMED", 4.1, 0, 1, 1, 0, 0);
			}
			else {
				if(GetPlayerAnimationIndex(playerid) != 1183) ApplyAnimation(playerid, "PED", "IDLE_ARMED", 4.1, 0, 1, 1, 0, 0);
			}
		}
	}
O problema й que parece que nгo ta caindo nas verificaзхes se o player jб estб usando a animaзгo
if(GetPlayerAnimationIndex(playerid) != 1183)

Aн fica repitindo varias vezes, sem parar, mal da pra andar pq fica tudo bugado
Alguйm sabe como arrumar isso?
Reply
#2

Para correr use assim:

PHP код:
if(newkeys == KEY_SPRINT)
{
   new 
GetPlayerWeapon(playerid);
   if(
== 25 || == 27 || == 30 || == 31 || == 33 || == 34)
   {
         if(
IsPlayerInAnyVehicle(playerid)) return 1;
         
ApplyAnimation(playerid"PED""RUN_ARMED"4.111111);
   }

Testei e funciona!
Reply
#3

Quote:
Originally Posted by Cheleber_Pausini
Посмотреть сообщение
Para correr use assim:

PHP код:
if(newkeys == KEY_SPRINT)
{
   new 
GetPlayerWeapon(playerid);
   if(
== 25 || == 27 || == 30 || == 31 || == 33 || == 34)
   {
         if(
IsPlayerInAnyVehicle(playerid)) return 1;
         
ApplyAnimation(playerid"PED""RUN_ARMED"4.111111);
   }

Testei e funciona!
Nossa boa ideia, sу umas coisas que teria que arrumar

Код:
if(newkeys == KEY_SPRINT)
Й se o player apertar sу espaзo e nгo tipo espaзo e W, mas da pra arrumar isso fбcil usando:
Код:
else if(newkeys & KEY_SPRINT)
Mas ainda tem um problema...
Como detectar se o player ta apertando sу W,A,S,D... Pq nos keys sу pega se apertar SPACE ou ALT
Reply
#4

Quote:
Originally Posted by weex
Посмотреть сообщение
Nossa boa ideia, sу umas coisas que teria que arrumar

Код:
if(newkeys == KEY_SPRINT)
Й se o player apertar sу espaзo e nгo tipo espaзo e W, mas da pra arrumar isso fбcil usando:
Код:
else if(newkeys & KEY_SPRINT)
Mas ainda tem um problema...
Como detectar se o player ta apertando sу W,A,S,D... Pq nos keys sу pega se apertar SPACE ou ALT
https://sampwiki.blast.hk/wiki/GetPlayerKeys
Reply
#5

Quote:
Originally Posted by weex
Посмотреть сообщение
Nossa boa ideia, sу umas coisas que teria que arrumar

Код:
if(newkeys == KEY_SPRINT)
Й se o player apertar sу espaзo e nгo tipo espaзo e W, mas da pra arrumar isso fбcil usando:
Код:
else if(newkeys & KEY_SPRINT)
Mas ainda tem um problema...
Como detectar se o player ta apertando sу W,A,S,D... Pq nos keys sу pega se apertar SPACE ou ALT
Tente assim...
PHP код:
if(newkeys == KEY_SPRINT

   new 
GetPlayerWeapon(playerid); 
   if(
== 25 || == 27 || == 30 || == 31 || == 33 || == 34
   { 
         if(
IsPlayerInAnyVehicle(playerid)) return 1
         
ApplyAnimation(playerid"PED""RUN_ARMED"4.111111); 
   } 
}
if(
oldkeys == KEY_SPRINT)

   new 
GetPlayerWeapon(playerid); 
   if(
== 25 || == 27 || == 30 || == 31 || == 33 || == 34
   { 
         
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
     
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
   } 

@Ele estava correndo quando clicava no W, assim nгo esta mais.
Reply
#6

Quote:
Originally Posted by Cheleber_Pausini
Посмотреть сообщение
Tente assim...
PHP код:
if(newkeys == KEY_SPRINT

   new 
GetPlayerWeapon(playerid); 
   if(
== 25 || == 27 || == 30 || == 31 || == 33 || == 34
   { 
         if(
IsPlayerInAnyVehicle(playerid)) return 1
         
ApplyAnimation(playerid"PED""RUN_ARMED"4.111111); 
   } 
}
if(
oldkeys == KEY_SPRINT)

   new 
GetPlayerWeapon(playerid); 
   if(
== 25 || == 27 || == 30 || == 31 || == 33 || == 34
   { 
         
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
     
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
   } 

@Ele estava correndo quando clicava no W, assim nгo esta mais.
Te dei um REP aqui, mas mano, desse jeito funciona sу de apertar espaзo...
Curti a ideia, queria fazer pra assim que apertar qualquer tecla de andar com uma dessas armas na mгo jб fazer a animaзгo...
Sabe me dizer oq fiz de errado?

Код:
		if(newkeys == KEY_UP || newkeys == KEY_DOWN || newkeys == KEY_LEFT || newkeys == KEY_RIGHT) 
		{
			new w = GetPlayerWeapon(playerid); 
			if(w == 25 || w == 27 || w == 30 || w == 31 || w == 33 || w == 34) 
			{
				if(IsPlayerInAnyVehicle(playerid)) return 1; 
				ApplyAnimation(playerid, "PED", "RUN_ARMED", 4.1, 1, 1, 1, 1, 1); 
			}
		}
		if(oldkeys == KEY_UP || newkeys == KEY_DOWN || newkeys == KEY_LEFT || newkeys == KEY_RIGHT)
		{
			new w = GetPlayerWeapon(playerid); 
			if(w == 25 || w == 27 || w == 30 || w == 31 || w == 33 || w == 34) 
			{
				ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0);
				ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0);
			}
		}
Reply
#7

De nada...
Use no OnPlayerUpdate

PHP код:
public OnPlayerUpdate(playerid)
{
    new 
Keys,ud,lr;
    
GetPlayerKeys(playerid,Keys,ud,lr);
    if(
ud != || ud != || lr != || lr != 0)
    {
          if(
Andando[playerid] == false)
          {
             new 
GetPlayerWeapon(playerid);
             if(
== 25 || == 27 || == 30 || == 31 || == 33 || == 34)
             {
                if(
IsPlayerInAnyVehicle(playerid)) return 1;
                
ApplyAnimation(playerid"PED""RUN_ARMED"4.111111);
                
Andando[playerid] = true;
             }
          }
    }
    else
    {
          if(
Andando[playerid] == true)
          {
             new 
GetPlayerWeapon(playerid);
             if(
== 25 || == 27 || == 30 || == 31 || == 33 || == 34)
             {
                if(
IsPlayerInAnyVehicle(playerid)) return 1;
                
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
                
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
                
Andando[playerid] = false;
             }
          }
    } 
e nгo se esqueзa disso no inicio do gm (:
PHP код:
new bool:Andando[MAX_PLAYERS]; 
Reply
#8

Eu nгo quero sу vim tentar ajudar eu uso UsePlayerPedAnims();
Mas achei legal a ideia de vcs...

Pq nгo posta o cуdigo aqui para todos que gostaram e nгo sabem como adaptar tbm nгo possam usar?
Reply
#9

Quote:
Originally Posted by pedrotvr
Посмотреть сообщение
Eu nгo quero sу vim tentar ajudar eu uso UsePlayerPedAnims();
Mas achei legal a ideia de vcs...

Pq nгo posta o cуdigo aqui para todos que gostaram e nгo sabem como adaptar tbm nгo possam usar?
Й para o ubuntu me adicionar se quiser...

Mas bem, decidi passar o cуdigo, experimentem...

Aqui vai uma dica:
PHP код:
//#define KEY_AIM KEY_HANDBRAKE
// HOLDING(keys)
#define HOLDING(%0) \
    
((newkeys & (%0)) == (%0))
    
// PRESSING(keyVariable, keys)
#define PRESSING(%0,%1) \
    
(%& (%1))
    
// RELEASED(keys)
#define RELEASED(%0) \
    
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0))) 
PHP код:
forward TimerAndando(playerid);
forward TimerAndandoDisparando(playerid);
new 
bool:Andando[MAX_PLAYERS];
new 
bool:ALTPress[MAX_PLAYERS];
new 
bool:Disparando[MAX_PLAYERS];
new 
TimerDisparando[MAX_PLAYERS]; 
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
HOLDING(KEY_FIRE) || PRESSING(newkeysKEY_FIRE))
    {
       
KillTimer(TimerDisparando[playerid]);
    }
    if(
RELEASED(KEY_FIRE))
    {
       
TimerDisparando[playerid] = SetTimerEx("TimerAndandoDisparando"5000"i"playerid);
    }
    if(
RELEASED(KEY_AIM))
    {
       
Andando[playerid] = false;
    }
    if(
HOLDING(KEY_JUMP) || PRESSING(newkeysKEY_JUMP ))
    {
//AQUI SERIA IDEAL CALCULAR O TEMPO DE SALTO!
       
SetTimerEx("TimerAndando"9000"i"playerid);
    }
    if(
HOLDING(KEY_WALK))
    {
        
ALTPress[playerid] = true;
    }
    if(
RELEASED(KEY_WALK))
    {
        
ALTPress[playerid] = false;
        
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
        
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
        
Andando[playerid] = false;
    }
    return 
1;

PHP код:
public OnPlayerUpdate(playerid)
{
    new 
Keys,ud,lr;
    
GetPlayerKeys(playerid,Keys,ud,lr);
    if(
ud != || ud != || lr != || lr != 0)
    {
          if(
Andando[playerid] == false && ALTPress[playerid] == false)
          {
                if(!
IsPlayerInAnyVehicle(playerid))
                {
                   
ApplyAnimation(playerid"PED""RUN_ARMED"4.111111);
                   
Andando[playerid] = true;
                }
          }
          if(
ALTPress[playerid] == true)
          {
                if(!
IsPlayerInAnyVehicle(playerid))
                {
                   
ApplyAnimation(playerid"PED""WALK_armed"4.111111);
                   
Andando[playerid] = true;
                }
          }
    }
    else
    {
          if(
Andando[playerid] == true)
          {
             if(!
IsPlayerInAnyVehicle(playerid) || Disparando[playerid] == false)
             {
                
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
                
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
                
Andando[playerid] = false;
             }
          }
    }
    return 
1;

PHP код:
public TimerAndandoDisparando(playerid)
{
  
Andando[playerid] = false;
  
Disparando[playerid] = false;
  return 
1;
}
public 
TimerAndando(playerid)
{
  
Andando[playerid] = false;
  return 
1;

E atenзгo nгo pedi para me adicionar para vender alguma coisa.
Reply
#10

Quote:
Originally Posted by Cheleber_Pausini
Посмотреть сообщение
Й para o ubuntu me adicionar se quiser...

Mas bem, decidi passar o cуdigo, experimentem...

Aqui vai uma dica:
PHP код:
//#define KEY_AIM KEY_HANDBRAKE
// HOLDING(keys)
#define HOLDING(%0) \
    
((newkeys & (%0)) == (%0))
    
// PRESSING(keyVariable, keys)
#define PRESSING(%0,%1) \
    
(%& (%1))
    
// RELEASED(keys)
#define RELEASED(%0) \
    
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0))) 
PHP код:
forward TimerAndando(playerid);
forward TimerAndandoDisparando(playerid);
new 
bool:Andando[MAX_PLAYERS];
new 
bool:ALTPress[MAX_PLAYERS];
new 
bool:Disparando[MAX_PLAYERS];
new 
TimerDisparando[MAX_PLAYERS]; 
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
HOLDING(KEY_FIRE) || PRESSING(newkeysKEY_FIRE))
    {
       
KillTimer(TimerDisparando[playerid]);
    }
    if(
RELEASED(KEY_FIRE))
    {
       
TimerDisparando[playerid] = SetTimerEx("TimerAndandoDisparando"5000"i"playerid);
    }
    if(
RELEASED(KEY_AIM))
    {
       
Andando[playerid] = false;
    }
    if(
HOLDING(KEY_JUMP) || PRESSING(newkeysKEY_JUMP ))
    {
//AQUI SERIA IDEAL CALCULAR O TEMPO DE SALTO!
       
SetTimerEx("TimerAndando"9000"i"playerid);
    }
    if(
HOLDING(KEY_WALK))
    {
        
ALTPress[playerid] = true;
    }
    if(
RELEASED(KEY_WALK))
    {
        
ALTPress[playerid] = false;
        
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
        
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
        
Andando[playerid] = false;
    }
    return 
1;

PHP код:
public OnPlayerUpdate(playerid)
{
    new 
Keys,ud,lr;
    
GetPlayerKeys(playerid,Keys,ud,lr);
    if(
ud != || ud != || lr != || lr != 0)
    {
          if(
Andando[playerid] == false && ALTPress[playerid] == false)
          {
                if(!
IsPlayerInAnyVehicle(playerid))
                {
                   
ApplyAnimation(playerid"PED""RUN_ARMED"4.111111);
                   
Andando[playerid] = true;
                }
          }
          if(
ALTPress[playerid] == true)
          {
                if(!
IsPlayerInAnyVehicle(playerid))
                {
                   
ApplyAnimation(playerid"PED""WALK_armed"4.111111);
                   
Andando[playerid] = true;
                }
          }
    }
    else
    {
          if(
Andando[playerid] == true)
          {
             if(!
IsPlayerInAnyVehicle(playerid) || Disparando[playerid] == false)
             {
                
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
                
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
                
Andando[playerid] = false;
             }
          }
    }
    return 
1;

PHP код:
public TimerAndandoDisparando(playerid)
{
  
Andando[playerid] = false;
  
Disparando[playerid] = false;
  return 
1;
}
public 
TimerAndando(playerid)
{
  
Andando[playerid] = false;
  return 
1;

E atenзгo nгo pedi para me adicionar para vender alguma coisa.
Bem foda mano, obrigadгo... +REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)