[Ajuda] Usei certo a GetPlayerWeaponData?
#1

Код:
	
new WeaponID, Ammo;
	GetPlayerWeaponData(playerid, 1, WeaponID, Ammo);  
	if(WeaponID == 2) {
		// esta usando a arma golf club
	}
Reply
#2

Sim, mas pode usar um switch tambйm.

https://sampwiki.blast.hk/wiki/GetPlayerWeaponData
Reply
#3

Em switch como dito acima vocк pode usar assim
PHP код:
    new Str[128],WeaponID, Ammo;
    switch(
GetPlayerWeaponData(playerid, 1, WeaponID, Ammo))
    {
       case 
2: Str = "Esta usando a arma golf club";
           case 
3: Str = "Esta usando alguma arma";
    }
    return 
Str; 
Mas testa antes de usar porque nгo testei.
Reply
#4

Nгo se esqueзa de checar se a muniзгo й maior que 0, pois mesmo se sua muniзгo acabar e vocк nгo poder usar mais a arma o servidor ainda diz que vocк a tem. Mas isso nгo se aplica a armas corpo-a-corpo pois nunca acabam a muniзгo mas se vocк usar SetPlayerAmmo(weaponid, 0) entгo se aplica.
Reply
#5

PHP код:
TemArma(playerid, arma)
{
    new 
WeaponID, Ammo;
    for (new 
i = 0; i <= 12; i++)
    {
        
GetPlayerWeaponData(playerid, i, WeaponID, Ammo);
        if(
WeaponID == arma)
        {
            return 
true;
        }
    }
    return 
false;
} 

Uso
PHP код:
if(TemArma(playerid, WEAPON_GOLFCLUB))
{
    
/** Tem Arma**/
}
else
{
    
/** Nгo tem Arma**/
} 
Reply
#6

Quote:
Originally Posted by Day_
Посмотреть сообщение
PHP код:
TemArma(playerid, arma)
{
    new 
WeaponID, Ammo;
    for (new 
i = 0; i <= 12; i++)
    {
        
GetPlayerWeaponData(playerid, i, WeaponID, Ammo);
        if(
WeaponID == arma)
        {
            return 
true;
        }
    }
    return 
false;
} 

Uso
PHP код:
if(TemArma(playerid, WEAPON_GOLFCLUB))
{
    
/** Tem Arma**/
}
else
{
    
/** Nгo tem Arma**/
} 
Uй mano o jeito que ele fez nгo ta certo?
Reply
#7

Quote:
Originally Posted by pedrotvr
Посмотреть сообщение
Uй mano o jeito que ele fez nгo ta certo?
Sim, porйm no mйtodo dele ele teria que saber qual slot cada arma usa, eu sу deixei esta funзгo por que recebi um MP dele, e vi alguns tуpicos dele.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)