SA-MP Forums Archive
Need little help - 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: Need little help (/showthread.php?tid=599552)



Need little help - Shinja - 27.01.2016

Can anyone script for me a command /weaps id to see a player's all weapons:

I already started but im stuck in GetPlayerWeaponData

Код:
COMMAND:weaps(playerid, params[])
	{
	    new id, name[100], string[100], weapon, ammo;
	    GetPlayerName(id, name, sizeof(name));
		if(pInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "{FF0000}You're not allowed to use this command!");
		if(sscanf(params, "ui", id)) return SendClientMessage(playerid, -1, "{FF00A2}Administration: {990061}Usage: {707070}/WEAPS [ID]");
        format(string, sizeof(string), "{FF00A2}Administration: {DB029A}%s[%d]'s Weapons:", name, id);
		SendClientMessage(playerid, -1, string);
		for(new i=0;i<13;i++)
		{
		    GetPlayerWeaponData(id, i, weapon, ammo);
      		new message[100];
			if(weapon != 0)
			{
				format(message, sizeof(message), "{00B7FF}Weapon:{006EFF}(%d) {00B7FF}Ammo{006EFF}(%d)", weapon, ammo);
				SendClientMessage(playerid, -1, message);
				return 1;
			}
		}
}



Re: Need little help - Jefff - 27.01.2016

pawn Код:
COMMAND:weaps(playerid, params[])
{
    new id;
    if(pInfo[playerid][pAdmin] < 1) SendClientMessage(playerid, -1, "{FF0000}You're not allowed to use this command!");
    else if(sscanf(params, "u", id)) SendClientMessage(playerid, -1, "{FF00A2}Administration: {990061}Usage: {707070}/WEAPS [ID]");
    else if(id > MAX_PLAYERS) SendClientMessage(playerid, -1, "{FF0000}Not connected!");
    else
    {
        new name[MAX_PLAYER_NAME + 1], string[100], weapon, ammo;
        GetPlayerName(id, name, sizeof(name));
        format(string, sizeof(string), "{FF00A2}Administration: {DB029A}%s[%d]'s Weapons:", name, id);
        SendClientMessage(playerid, -1, string);
        for(new i=0; i < 13; i++)
        {
            GetPlayerWeaponData(id, i, weapon, ammo);
            if(weapon != 0)
            {
                format(string, sizeof(string), "{00B7FF}Weapon:{006EFF}(%d) {00B7FF}Ammo{006EFF}(%d)", weapon, ammo);
                SendClientMessage(playerid, -1, string);
            }
        }
    }
    return 1;
}
You can also see
https://sampforum.blast.hk/showthread.php?tid=571253


Re: Need little help - Shinja - 27.01.2016

Its not about brackets or unused variables. The code is true 100%
But i just ex:
Код:
Weapon(5) Ammo(1)
Like if "weapon" stores just slots. and idk about "ammo" stores what

I need to send
Код:
Weapon: M4 Ammo (100)
...ect
Anyway thanks for attention +Rep


Re: Need little help - lucamsx - 27.01.2016

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


Re: Need little help - KillerDVX - 27.01.2016

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

Example of use:

Quote:

new weaponid, ammo;
GetPlayerWeaponData(playerid, 2, weaponid, ammo);
if(weaponid == WEAPON_DEAGLE && ammo == 50)
{

}




Re: Need little help - Shinja - 28.01.2016

Quote:
Originally Posted by KillerDVX
Посмотреть сообщение
Now understood, ty +Rep