Im struggeling to make this work. When im trying to pickpocket someone, it says You fail to pick their pockets.item
Means, when item = 0, it send that message.
But the player has items, but i dont know how to get this to work propertly.
any ideas?
Code:
public void pickPlayerPocket(int index) {
Client p = (Client)PlayerHandler.players[index];
c.pickingPlayer = false;
if(p == null) return;
if (p.inDuelArena() || p.inCw() || p.isBanking || p.inTrade) {
c.sendMessage("This player is busy.");
return;
}
c.sendMessage("You attempt to pick " + p.playerName + "'s pockets...");
if (c.playerLevel[17] < p.playerLevel[17]) {
c.sendMessage("You need to have a theiving level of " + p.playerLevel[17] + " to pick this person pockets.");
return;
}
if (Misc.random(4) == 2) {
c.sendMessage("You fail to pick their pockets random.");
return;
}
int item = 0, amount = 0, trys = 0;
while(item == 0 && trys < 10) {
for (int i = 0; i < p.playerItems.length; i++) {
if ((p.playerItems[i]-1) > 0) {
int v = c.getShops().getItemShopValue(p.playerItems[i] - 1);
if (v > 10000) continue; // higher than 1 million? skip that shit :)
if (Misc.random(4) == 4) {
int player = 0;
item = player;
if(p.playerItemsN[i] > 1)
amount = Misc.random((p.playerItemsN[i] > 1000000 ? 1000000 : p.playerItemsN[i]));
else
amount = 1;
}
}
}
trys++;
}
if (item == 0) {
c.sendMessage("You fail to pick their pockets.item");
return;
}
p.getItems().deleteItem(item, amount);
c.getItems().addItem(item, amount);
c.sendMessage("You successfully picked " + p.playerName + "'s pockets!");
}