24.03.2016, 22:03
I realised my last thread wasnt informative enough so I decided to create a new one
I have 5 item names. I need to find which of these item values aren't equal zero and then randomly choose one of them (of those that aren't equal 0) and then give that item to player.
maybe I shouldn't use array, I don't know..
example:
chair is 2, box is 0, tv is 0, couch is 1, bed is 0. Since bed, tv and box is 0, I have to randomly choose from chair and couch. Let's say it's chair. Now I have to give item "chair" to player
I have 5 item names. I need to find which of these item values aren't equal zero and then randomly choose one of them (of those that aren't equal 0) and then give that item to player.
Code:
new a[5]; a[0]=GetItemValue(playerid, "chair"); a[1]=GetItemValue(playerid, "box"); a[2]=GetItemValue(playerid, "tv"); a[3]=GetItemValue(playerid, "couch"); a[4]=GetItemValue(playerid, "bed");
example:
chair is 2, box is 0, tv is 0, couch is 1, bed is 0. Since bed, tv and box is 0, I have to randomly choose from chair and couch. Let's say it's chair. Now I have to give item "chair" to player
Code:
GiveItem(playerid, "chair");