How to check if a player has items - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to check if a player has items (
/showthread.php?tid=130200)
How to check if a player has items -
Torran - 25.02.2010
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
}
Re: How to check if a player has items -
BlackFoX - 25.02.2010
pawn Код:
if(!Medikit[playerid] /* The Same like this Medikit[playerid] == 1 */ )return SendClientMessage(...);
//else do something
Re: How to check if a player has items -
Torran - 25.02.2010
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
Re: How to check if a player has items -
Carlito - 25.02.2010
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(...);
Re: How to check if a player has items -
Torran - 25.02.2010
Is there a way to check if all the items in enum Items are 0?
Re: How to check if a player has items -
Carlito - 25.02.2010
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(...);