SA-MP Forums Archive
/check a cmd to see player's guns [+REP] - 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: /check a cmd to see player's guns [+REP] (/showthread.php?tid=601124)



/check a cmd to see player's guns [+REP] - [SU]Spartan - 17.02.2016

So I was wondering how to make this command,I advised samp wiki but couldnt find a solution,anyone who helps me gets rep.everyone not just the first one.


Re: /check a cmd to see player's guns [+REP] - OneTwoThree - 17.02.2016

Could you provide us with more info?
Which game mode are you using?
Some commands? /stats would help a lot


Re: /check a cmd to see player's guns [+REP] - BiosMarcel - 17.02.2016

https://sampwiki.blast.hk/wiki/GetPlayerWeaponData


Re: /check a cmd to see player's guns [+REP] - iKarim - 17.02.2016

PHP код:
new const shortWeaponNames[48][13] = {
    { 
"Unarmed"      },{ "Knuckles"     },{ "Golfclub"     },{ "Nightstick"   },{ "Knife"        },
    { 
"Bat"          },{ "Shovel"       },{ "Pool Cue"     },{ "Katana"       },{ "Chainsaw"     },
    { 
"Dildo"        },{ "Vibrator"     },{ "Vibrator"     },{ "Vibrator"     },{ "Flowers"      },
    { 
"Cane"         },{ "Grenade"      },{ "Teargas"      },{ "Molotov"      },{ " "            },
    { 
" "            },{ " "            },{ "Colt 45"      },{ "Silenced"     },{ "Deagle"       },
    { 
"Shotgun"      },{ "Sawnoffs"     },{ "Spas"         },{ "Micro UZI"    },{ "MP5"          },
    { 
"AK47"         },{ "M4"           },{ "Tec 9"        },{ "Rifle"        },{ "Sniper"       },
    { 
"Rocket"       },{ "RPG"          },{ "Flamethrower" },{ "Minigun"      },{ "Satchel"      },
    { 
"Detonator"    },{ "Spraycan"     },{ "Extinguisher" },{ "Camera"       },{ "Nightvision"  },
    { 
"Infrared"     },{ "Parachute"    },{ "Fake Pistol"  }
};
stock Ret_PlayerWeapons(playerid) {
    new 
tmp[128]
    for ( new 
slot 0slot 13slot++ )
    {
        
GetPlayerWeaponDataplayeridslotweaponammo );
        if ( 
weapon != && ammo != )
        {
            if(
slot == 1)
            {
                
formattmpsizeoftmp ), "%s(%d)"shortWeaponNamesweapon ] , ammo);
            }
            else
            {
                
formattmpsizeoftmp ), "%s, %s(%d)"tmpshortWeaponNamesweapon ] , ammo);
            }
        }
    }
    return 
tmp;

example:
PHP код:
CMD:myweapons(playerid) {

    new 
tmpstr[128];
    
format(tmpstrsizeof tmpstr"My Weapons: %s"Ret_PlayerWeapons(playerid))
    
SendClientMessage(playerid, -1tmpstr);
    return 
true;




Respuesta: Re: /check a cmd to see player's guns [+REP] - Whillyrez - 17.02.2016

Quote:
Originally Posted by OneTwoThree
Посмотреть сообщение
Could you provide us with more info?
Which game mode are you using?
Some commands? /stats would help a lot
Seriously?... Anyways...
Hi!, Here you have one function that I just made, I wish it helps you.

Код:
CheckPlayerWeaps(playerid)
{
	new weap, ammo, string[64];
	for (new i = 0; i <= 12; i++)
	{
    	GetPlayerWeaponData(playerid, i, weap, ammo);
    	format(string,sizeof(string),"SLOT: %i. WEAPON: %i, AMMO: %i",i, weap, ammo);
	SendClientMessage(playerid,-1,string);
	}
	return 1;
}
This is not tested!... Here an example of using it, using sscanf and zcmd.
Код:
CMD:checkweaps(playerid, params[])
{
	new player;
	if(!sscanf(params, "r", player))
	{
		CheckPlayerWeaps(player);
	}
        else SendClientMessage(playerid, -1 "[USAGE]: /checkweaps [ID player]");
	return 1;
}
EDIT: I started posting this before all the answers, sorry. And also sorry for my bad english:V


Re: /check a cmd to see player's guns [+REP] - [SU]Spartan - 17.02.2016

Thanks you PawnHunter and Whillyrez,both repped