SA-MP Forums Archive
Help - Check weapons a player - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help - Check weapons a player (/showthread.php?tid=576763)



Help - Check weapons a player - JoshNudock - 06.06.2015

Good day! need some help urgently, I have a code below to check weapons a player, more is not showing the name of arms, someone has a solution to the problem? or code that has been done here in the forum, an issue that has been resolved here in the forum, is not showing the name of guns, only random numbers .. follows the code below:

PHP код:
stock Weapon_Name(Arma_ID)
{
    new 
Arma[30];
    switch(
Arma_ID) {
        case 
1:         Arma "Soco Inglкs";
        case 
2:        Arma "Taco de Golfe";
        case 
3:         Arma "Cacetete";
        case 
4:         Arma "Faca";
        case 
5:         Arma "Taco de Beisebol";
        case 
6:         Arma "Pб";
        case 
7:         Arma "Taco de Sinuca";
        case 
8:         Arma "Katana";
        case 
9:         Arma "Serra Elйtrica";
        case 
10:         Arma "Pкnis De Borracha";
        case 
11:     Arma "Vibrador";
        case 
12:     Arma "Vibrador";
        case 
13:     Arma "Vibrador";
        case 
14:         Arma "Buquк de Flores";
        case 
15:         Arma "Bengala";
        case 
16:        Arma "Granada";
        case 
17:         Arma "Granada de Gбs";
        case 
18:         Arma "Motolov";
        case 
22:        Arma "Pistola 9mm";
        case 
23:         Arma "Pistola 9mm com Silenciador";
        case 
24:        Arma "Pistola Desert Eagle";
        case 
25:        Arma "Calibre-12";
        case 
26:        Arma "Shotgun Cano Cerrado";
        case 
27:        Arma "Combat Shotgun";
        case 
28:         Arma "Metralhadora Micro SMG/Uzi";
        case 
29:         Arma "Metralhadora MP5";
        case 
30:         Arma "Fuzil AK-47";
        case 
31:        Arma "Fuzil M4";
        case 
32:         Arma "Metralhadora Tec-9";
        case 
33:        Arma "Country Rifle";
        case 
34:         Arma "Sniper Rifle";
        case 
35:        Arma "Bazuca RPG";
        case 
36:        Arma "Bazuca de Alvo";
        case 
37:        Arma "Lanзa-Chamas";
        case 
38:        Arma "Minigun";
        case 
39:        Arma "Carga Explosiva";
        case 
40:        Arma "Detonador";
        case 
41:        Arma "Lata de Spray";
        case 
42:        Arma "Extintor";
        case 
43:        Arma "Cвmara Fotogrбfica";
        case 
44:        Arma "Уculos de Visгo Noturna";
        case 
45:         Arma "Уculos de proteзгo tйrmica";
        case 
46:        Arma "Pбra-quedas";
        default:        
Arma "Desconhecido";
    }
    return 
Arma;
}
    if (
strcmp(cmd"/checkweapons"true) == || strcmp(cmd"/checkw"true) == 0)
    {
        if (
IsPlayerConnected(playerid))
        {
            if (
PlayerInfo[playerid][pAdmin] < 0)
            {
                return 
SendClientMessage(playeridCOLOR_GRAD1"ERRO: Vocк nгo tem nнvel administrativo suficiente.");
            }
            if (
PlayerInfo[playerid][pAdminStats] != && PlayerInfo[playerid][pAdmin] <= 5)
            {
                return 
SendClientMessage(playeridCOLOR_GRAD1"ERRO: Vocк nгo estб no modo admin! (/trabalhar)");
            }
            
temp2 strtok(cmdtextidx);
            if (!
strlen(temp2))
            {
                return 
SendClientMessage(playerid, -1"USE: (/checkw)eapons [ID/Nome]");
            }
            new 
targetid ReturnUser(temp2);
            if (
targetid == INVALID_PLAYER_ID)
            {
                return 
SendClientMessage(playeridCOLOR_GRAD1"ERRO: ID/Nome Invбlido.");
            }
            new 
weapons[2][13];
            
SendClientMessage(playeridCOLOR_ADMIN_INFO"===========================");
            
format(stringsizeof(string), "Armas de %s:"GetPlayerNameRP(targetid));
            
SendClientMessage(playeridCOLOR_GRAD1string);
            for (new 
0<= 12i++)
            {
                
GetPlayerWeaponData(targetidiweapons[0][i], weapons[1][i]);
                if (
weapons[0][i] != 0)
                {
                    
format(stringsizeof(string), "Slot: %d (%d) Muniзгo: %d"iWeapon_Name(weapons[0][i]), weapons[1][i]);
                    
SendClientMessage(playerid, -1string);
                }
            }
        }
        return 
true;
    } 



Re: Help - Check weapons a player - Face9000 - 06.06.2015

Try this: (edit it based on your admin system):

PHP код:
CMD:getweps(playerid,params[])
{
      
      if(
PlayerInfo[playerid][Admin] >= 1)
      {
            new 
Target;
            new 
TW;
            if(!
sscanf(params"u"Target))
            {
                if(
Target == INVALID_PLAYER_ID) return SCM(playerid,red,"Wrong player ID.");
                new 
msg1[250], string2[64];
                new 
ammo;
                new 
name[MAX_PLAYER_NAME];
                
GetPlayerName(Target,name,sizeof(name));
                
format(string2,sizeof(string2),"_______ %s (%d)'s Weapons _______",name,Target);
                
SCM(playerid,COLOR_YELLOW,string2);
                for(new 
a=0<= 9a++)
                {
                    new 
weapon;
                    
GetPlayerWeaponData(Target,a,weapon,ammo);
                    if(
ammo != && weapon != 0)
                    {
                        new 
WeaponName[50], Ammo;
                        if(
ammo == -1Ammo 1;
                        else 
Ammo ammo;
                        if(
weapon == 18WeaponName "Molotov";
                        else 
GetWeaponName(weaponWeaponName64);
                        
format(msg1,128,"%s (ID:%d) - Ammo: %d"WeaponNameweaponAmmo);
                        
SCM(playerid,LIGHTBLUE,msg1);
                        
PlayerInfo[Target][AdminActions]++;
                        
TW++;
                    }
                }
                if(
TW == 0) return SCM(playerid,red,"This player is disarmed.");
                else {
                    
format(msg1,128,"Total Weapons: %d"TW);
                    
SCM(playerid,COLOR_YELLOW,msg1);
                }
                }
            else 
SCM(playerid,-1,"{F70505}Usage: {FFFFFF}/getweps <playerid>");
        }
        return 
1;

EDIT: Forgot the stock:

PHP код:
stock GetWeaponNameByID(wid)
{
    new 
gunname[32];
    switch (
wid)
    {
        case    
.. 17,
                
22 .. 43,
                
46 :        GetWeaponName(wid,gunname,sizeof(gunname));
        case    
0:          format(gunname,32,"%s","Fist");
        case    
18:         format(gunname,32,"%s","Molotov Cocktail");
        case    
44:         format(gunname,32,"%s","Night Vis Goggles");
        case    
45:         format(gunname,32,"%s","Thermal Goggles");
        default:            
format(gunname,32,"%s","Invalid Weapon Id");
    }
    return 
gunname;