Frisk command
#1

How can i make a /frisk command to get all weapons on a player?
with the weapons name

|_ This person has _|

Items:
-list

Weapons:
-list
Reply
#2

Use a for loop to loop trough the weapons/items of the player, then format a string with all found stuff, and send it in a client message.
Reply
#3

And how would i do that?
Reply
#4

Код:
 	}
 	if(strcmp(cmd,"/frisk",true)==0)
    {
        if(IsPlayerConnected(playerid))
	    {
	       	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /frisk [playerid/PartOfName]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			if(IsPlayerConnected(giveplayerid))
			{
				if(giveplayerid != INVALID_PLAYER_ID)
				{
				    if(ProxDetectorS(8.0, playerid, giveplayerid))
      				{
      				    if(playerid == giveplayerid) return SendClientMessage(playerid,COLOR_GREY,"   You cannot frisk yourself.");
      				    if(PlayerTied[giveplayerid] || PlayerCuffed[giveplayerid])
      				    {
      				        new WeaponName[65];
						    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
							GetPlayerName(playerid, sendername, sizeof(sendername));
							SendClientMessage(playerid, COLOR_GREEN,"_______________________________________");
		     				format(string, sizeof(string), "*** %s's Items ***", giveplayer);
						    SendClientMessage(playerid, COLOR_WHITE, string);
	                        if(PlayerInfo[giveplayerid][pCash] > 0) format(string,sizeof(string),"Money (%d)",PlayerInfo[giveplayerid][pCash]); SendClientMessage(playerid,COLOR_GREY,string);
							if(PlayerInfo[giveplayerid][pPot] > 0) format(string,sizeof(string),"Marijuana (%dg)",PlayerInfo[giveplayerid][pPot]); SendClientMessage(playerid,COLOR_BITEM,string);
						    if(PlayerInfo[giveplayerid][pCrack] > 0) format(string,sizeof(string),"Crack Cocaine (%dg)",PlayerInfo[giveplayerid][pCrack]); SendClientMessage(playerid,COLOR_BITEM,string);
							if(PlayerInfo[giveplayerid][pPotSeeds] > 0) format(string,sizeof(string),"Seeds (%dg)",PlayerInfo[giveplayerid][pPotSeeds]); SendClientMessage(playerid,COLOR_BITEM,string);
						    if(PlayerInfo[giveplayerid][pMats] > 0) format(string,sizeof(string),"Materials (%d)",PlayerInfo[giveplayerid][pMats]); SendClientMessage(playerid,COLOR_BITEM,string);
						    if(Packages[playerid] > 0) SendClientMessage(playerid, COLOR_BITEM, "Materials Packages");
						    if(Crates[playerid] > 0) SendClientMessage(playerid, COLOR_BITEM, "Drug Crates");
						    if(Fishes[giveplayerid][pWeight1] > 0 || Fishes[giveplayerid][pWeight2] > 0 || Fishes[giveplayerid][pWeight3] > 0 || Fishes[giveplayerid][pWeight4] > 0 || Fishes[giveplayerid][pWeight5] > 0) SendClientMessage(playerid, COLOR_GRAD3, "Fish");
						    if(PlayerInfo[giveplayerid][pPhoneBook] > 0) SendClientMessage(playerid, COLOR_GRAD3, "Phone Book");
						    if(PlayerInfo[giveplayerid][pCDPlayer] > 0) SendClientMessage(playerid, COLOR_GRAD3, "CD Player");
						    if(PlayerInfo[giveplayerid][pPnumber] > 0) SendClientMessage(playerid, COLOR_GRAD3, "Cellphone");
						    if(PlayerInfo[giveplayerid][pSpraycan] > 0) format(string,sizeof(string),"Spraycans (%d)",PlayerInfo[giveplayerid][pSpraycan]); SendClientMessage(playerid,COLOR_GREY,string);
						    if(PlayerInfo[giveplayerid][pScrew] > 0) format(string,sizeof(string),"Screwdrivers (%d)",PlayerInfo[giveplayerid][pScrew]); SendClientMessage(playerid,COLOR_GREY,string);
						    if(PlayerInfo[giveplayerid][pDice] > 0) SendClientMessage(playerid, COLOR_GRAD3, "Dice");
						    if(PlayerInfo[giveplayerid][pRope] > 0) format(string,sizeof(string),"Rope (%d)",PlayerInfo[giveplayerid][pRope]); SendClientMessage(playerid,COLOR_GREY,string);
						    if(PlayerInfo[giveplayerid][pCigars] > 0) format(string,sizeof(string),"Cigars (%d)",PlayerInfo[giveplayerid][pCigars]); SendClientMessage(playerid,COLOR_GREY,string);
						    if(PlayerInfo[giveplayerid][pSprunk] > 0) format(string,sizeof(string),"Sprunk (%d)",PlayerInfo[giveplayerid][pSprunk]); SendClientMessage(playerid,COLOR_GREY,string);
						    if(PlayerInfo[giveplayerid][pBombs] > 0) SendClientMessage(playerid, COLOR_BITEM, "C4 Explosives");
						    if(HasBoughtMask[giveplayerid] > 0) SendClientMessage(playerid, COLOR_GRAD3, "Ski-Mask");
						    if(PlayerInfo[giveplayerid][pBlindfolds] > 0) format(string,sizeof(string),"Blindfolds (%d)",PlayerInfo[giveplayerid][pBlindfolds]); SendClientMessage(playerid,COLOR_GREY,string);
						    if(PlayerInfo[giveplayerid][pGun0] != 0) { GetWeaponName(PlayerInfo[giveplayerid][pGun0], WeaponName, 64); format(string, sizeof(string), "%s", WeaponName); SendClientMessage(playerid, COLOR_BITEM, string); }
						    if(PlayerInfo[giveplayerid][pGun1] != 0) { GetWeaponName(PlayerInfo[giveplayerid][pGun1], WeaponName, 64); format(string, sizeof(string), "%s", WeaponName); SendClientMessage(playerid, COLOR_BITEM, string); }
						    if(PlayerInfo[giveplayerid][pGun2] != 0) { GetWeaponName(PlayerInfo[giveplayerid][pGun2], WeaponName, 64); format(string, sizeof(string), "%s", WeaponName); SendClientMessage(playerid, COLOR_BITEM, string); }
						    if(PlayerInfo[giveplayerid][pGun3] != 0) { GetWeaponName(PlayerInfo[giveplayerid][pGun3], WeaponName, 64); format(string, sizeof(string), "%s", WeaponName); SendClientMessage(playerid, COLOR_BITEM, string); }
						    if(PlayerInfo[giveplayerid][pGun4] != 0) { GetWeaponName(PlayerInfo[giveplayerid][pGun4], WeaponName, 64); format(string, sizeof(string), "%s", WeaponName); SendClientMessage(playerid, COLOR_BITEM, string); }
						    if(PlayerInfo[giveplayerid][pGun5] != 0) { GetWeaponName(PlayerInfo[giveplayerid][pGun5], WeaponName, 64); format(string, sizeof(string), "%s", WeaponName); SendClientMessage(playerid, COLOR_BITEM, string); }
						    if(PlayerInfo[giveplayerid][pGun6] != 0) { GetWeaponName(PlayerInfo[giveplayerid][pGun6], WeaponName, 64); format(string, sizeof(string), "%s", WeaponName); SendClientMessage(playerid, COLOR_BITEM, string); }
						    if(PlayerInfo[giveplayerid][pGun7] != 0) { GetWeaponName(PlayerInfo[giveplayerid][pGun7], WeaponName, 64); format(string, sizeof(string), "%s", WeaponName); SendClientMessage(playerid, COLOR_BITEM, string); }
						    if(PlayerInfo[giveplayerid][pGun8] != 0) { GetWeaponName(PlayerInfo[giveplayerid][pGun8], WeaponName, 64); format(string, sizeof(string), "%s", WeaponName); SendClientMessage(playerid, COLOR_BITEM, string); }
						    if(PlayerInfo[giveplayerid][pGun9] != 0) { GetWeaponName(PlayerInfo[giveplayerid][pGun9], WeaponName, 64); format(string, sizeof(string), "%s", WeaponName); SendClientMessage(playerid, COLOR_BITEM, string); }
						    if(PlayerInfo[giveplayerid][pGun10] != 0) { GetWeaponName(PlayerInfo[giveplayerid][pGun10], WeaponName, 64); format(string, sizeof(string), "%s", WeaponName); SendClientMessage(playerid, COLOR_BITEM, string); }
							if(PlayerInfo[giveplayerid][pGun11] == 44) { SendClientMessage(playerid, COLOR_GRAD3, "Nightvision Goggles"); }
							if(PlayerInfo[giveplayerid][pGun11] == 45) { SendClientMessage(playerid, COLOR_GRAD3, "Infared Goggles"); }
							if(PlayerInfo[giveplayerid][pGun12] != 0) { GetWeaponName(PlayerInfo[giveplayerid][pGun12], WeaponName, 64); format(string, sizeof(string), "%s", WeaponName); SendClientMessage(playerid, COLOR_BITEM, string); }
						    for (new weap = 1; weap < 47; weap++)
					        {
					            if(HaveAdminWeapon(giveplayerid, weap) == weap)
					            {
					                GetWeaponName(weap, WeaponName, 64);
								    format(string, sizeof(string), "Admin Given %s", WeaponName);
						            SendClientMessage(playerid, COLOR_WHITE, string);
					            }
					        }
						    SendClientMessage(playerid, COLOR_GREEN,"_______________________________________");
						    format(string, sizeof(string), "* %s has frisked %s.", PlayerName(playerid),PlayerName(giveplayerid));
							ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
						}
						else
						{
						    format(string, sizeof(string), "* You offered to frisk %s.",PlayerName(giveplayerid));
							SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
							format(string, sizeof(string), "* %s wants to frisk you, (type /accept frisk) to accept.",PlayerName(playerid));
							SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
							FriskOffer[giveplayerid] = playerid;
						}
 					}
					else
					{
					    return SendClientMessage(playerid, COLOR_GREY, "   That player is not near you.");
					}
				}
			}
	       	else
	       	{
	       		 return SendClientMessage(playerid, COLOR_GREY, "   That player is offline.");
	      	}
		}
	    return 1;
 	}
================================================== =================
Enjoy, I hope that I helped you! a reputation would make me able to reach up my destination! I really just appreciate it
Reply
#5

This should do what you need it to:

pawn Код:
CMD:frisk(playerid, params[])
{
    new
        iID
    ;
   
    if(sscanf(params, "u", iID))
        return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /frisk [nick/id]"), 1;
    if(iID == INVALID_PLAYER_ID)
        return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid nickname/ID specified."), 1;
   
    new
        weaponData[13][2],
        szString[128],
        szName[MAX_PLAYER_NAME]
    ;
   
    GetPlayerName(iID, szName, sizeof(szName));
   
    format(szString, sizeof(szString), "* %s's weapon information:", szName);
    SendClientMessage(playerid, COLOR_YELLOW, szString);
    SendClientMessage(playerid, COLOR_YELLOW, " ");
       
    for(new i = 0; i < 13; i++)
    {
        GetPlayerWeaponData(iID, i, weaponData[i][0], weaponData[i][1]);
       
        format(szString, sizeof(szString), "- Slot ID: %d   Weapon ID: %d   Ammo: %d", i, weaponData[i][0], weaponData[i][1]);
        SendClientMessage(playerid, COLOR_YELLOW, szString);
    }
    return 1;
}
Reference: https://sampwiki.blast.hk/wiki/GetPlayerWeaponData
Reply
#6

How could i name the weapons eg - Weapon: Deagle
Reply
#7

Try this:

pawn Код:
new eWeaponNames[][32] =
{
    {"Unarmed"}, {"Brass Knuckles"}, {"Golf Club"}, {"Night Stick"}, {"Knife"}, {"Baseball Bat"}, {"Shovel"}, {"Pool Cue"}, {"Katana"}, {"Chainsaw"},
    {"Purple Dildo"}, {"Big White Vibrator"}, {"Medium White Vibrator"}, {"Small White Vibrator"}, {"Flowers"}, {"Cane"}, {"Grenade"}, {"Teargas"}, {"Molotov"},
    {" "}, {" "}, {" "}, {"Colt 45"}, {"Colt 45 (Silenced)"}, {"Desert Eagle"}, {"Normal Shotgun"}, {"Sawnoff Shotgun"}, {"Combat Shotgun"}, {"Micro Uzi (Mac 10)"},
    {"MP5"}, {"AK47"}, {"M4"}, {"Tec9"}, {"Country Rifle"}, {"Sniper Rifle"}, {"Rocket Launcher"}, {"Heat-Seeking Rocket Launcher"}, {"Flamethrower"}, {"Minigun"},
    {"Satchel Charge"}, {"Detonator"}, {"Spray Can"}, {"Fire Extinguisher"}, {"Camera"}, {"Night Vision Goggles"}, {"Infrared Vision Goggles"}, {"Parachute"}, {"Fake Pistol"}
};

CMD:frisk(playerid, params[])
{
    new
        iID
    ;
   
    if(sscanf(params, "u", iID))
        return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /frisk [nick/id]"), 1;
    if(iID == INVALID_PLAYER_ID)
        return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid nickname/ID specified."), 1;
   
    new
        weaponData[13][2],
        szString[128],
        szName[MAX_PLAYER_NAME]
    ;
   
    GetPlayerName(iID, szName, sizeof(szName));
   
    format(szString, sizeof(szString), "* %s's weapon information:", szName);
    SendClientMessage(playerid, COLOR_YELLOW, szString);
    SendClientMessage(playerid, COLOR_YELLOW, " ");
       
    for(new i = 0; i < 13; i++)
    {
        GetPlayerWeaponData(iID, i, weaponData[i][0], weaponData[i][1]);
       
        format(szString, sizeof(szString), "- Slot ID: %d   Weapon ID: %s   Ammo: %d", i, eWeaponNames[weaponData[i][0]], weaponData[i][1]);
        SendClientMessage(playerid, COLOR_YELLOW, szString);
    }
    return 1;
}
Reply
#8

Fixed
Reply
#9

In order to effectively do this define your weapon names and ammo amounts. Another good feature would be to make it so the other user has to /accept frisk.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)