Checking inventory?
#1

Is there a way to check to see if a player has a gun?

I know the base but what about the function?

My goal is to show it in a message
Reply
#2

Do you use some sort of saving system for weapons? If so you can check if the variable for the weapon is there and then, I will use a enum for the example:
pawn Код:
if(gPlayerInfo[playerid][pGun02] == 24)
{
SendClientMessage(playerid, COLOR, "You have a deagle");
return 1;
}
Reply
#3

I made this for you:

pawn Код:
#include <a_samp>


#define FILTERSCRIPT

#if defined FILTERSCRIPT

#define COLOR_RED 0xFF0000AA

new banning[MAX_PLAYERS];

forward banningtimer();//timer for when getting banned
forward weaponanti();//checks if a player has an illegal weapon


#endif
public banningtimer()
{
    for (new i = 0; i < MAX_PLAYERS; i++)
        {
       if(banning[i] == 1)
     {

     }
    }
}

public weaponanti()
{
    for (new i = 0; i < MAX_PLAYERS; i++)
     {
       if (GetPlayerWeapon(i) == 38)
    {
           new pname[200];
           new string[200];
           new ammo = GetPlayerAmmo(i);
           new plrIP[16];
           GetPlayerIp(i, plrIP, sizeof(plrIP));
           GetPlayerName(i, pname, sizeof(pname));
           format(string,sizeof(string),"%s [ID: %d] [IP:%s] is suspected of having Minigun Hacks (Ammo: %i) [Use /getinfo %d]",pname,i,plrIP,ammo,i);
           SendClientMessage(i, COLOR_RED, string);
           SetTimer("banningtimer",15000,0);
           banning[i] =1;
       }
       
          }
}
Reply
#4

No saving for guns. The Gun system is Via Ranks
Reply
#5

Maybe this is what you are looking for?

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

GetPlayerWeapon(playerid)
Reply
#7

Quote:
Originally Posted by Dr
Посмотреть сообщение
Maybe this is what you are looking for?

https://sampwiki.blast.hk/wiki/GetPlayerWeaponData
That would be the function you should use.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)