How to check if a player has items
#1

When someone buys something at the shop
Ex: medikit,

It will set

Medikit[playerid] = 1;

But how would i check to see if a player has items, If he dont then it returns a message

And would i be able to put all the items in something like this

pawn Код:
enum Items
{
Medikit,
Armour
}
Reply
#2

pawn Код:
if(!Medikit[playerid] /* The Same like this Medikit[playerid] == 1 */ )return SendClientMessage(...);
//else do something
Reply
#3

Ok,
And would i be able to put all items ex: medikit, ect into a enum?
And then like check to see if he has any items in the enum.
Rather than seeing if he has each individual item
Reply
#4

Quote:
Originally Posted by Torran
Ok,
And would i be able to put all items ex: medikit, ect into a enum?
And then like check to see if he has any items in the enum.
Rather than seeing if he has each individual item
then it looks like this:

enum Items
{
Medikit,
Armour
}
new PlayerInfo[MAX_PLAYERS][Items];

PlayerInfo[playerid][Medikit]=1;
PlayerInfo[playerid][Armour]=1;

if(PlayerInfo[playerid][Armour]==1){ //do something } else SendClientMassage(...);
Reply
#5

Is there a way to check if all the items in enum Items are 0?
Reply
#6

Quote:
Originally Posted by Torran
Is there a way to check if all the items in enum Items are 0?
i think it works with something like this, but not sure

for (new i; i<2; i++){
if(PlayerInfo[playerid][i == 1){ //do something } else SendClientMassage(...);
}

but he will do the if twice... so its better u use

if(PlayerInfo[playerid][Medikit]==1 && PlayerInfo[playerid][Armour]==1){ //do something } else SendClientMassage(...);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)