Here's a betting spar.
Change the "this.boxName" to 1 or 2 [Only two per level, could add more on slight modifications]. Add two of these in the level.
HTML Code:
function onCreated() {
this.setShape(1, 32, 32);
this.boxName = 1;
}
//Function called to pick up an item
function onActionFound(id) {
if (level.("objectOwner" @ this.boxName) != null) {
return false;
}
for (temp.i: findnearestnpcs(this.x - 2, this.y - 2, 4, 4) {
if (temp.i.itemid == temp.id) {
level.("objectOwner" @ this.boxName) = player;
level.("objectItem1" @ this.boxName) = {temp.i.mudid, temp.i.mudquantity};
temp.i.destroy();
return;
}
}
}
Here's the main control, on the GK system this will probably need ajusting more than anything
HTML Code:
function onCreated() {
this.setShape(1, 32, 32);
this.boxModes = {1, 2};
level.deathAction = {this.x, this.y};
//Maybe there's a public function for when a person dies in a level!
//If not, I could add a timeout, just better to send an action once someone dies
}
//If there is, here's how it'd work
function onActionDeathAction(accountName) {
for (temp.i: this.boxModes) {
temp.ownerAccounts.add(level.("objectOwner" @ temp.i).account);
temp.itemDetails.add(level.("objectItem1" @ temp.i));
}
if (temp.ownerAccounts == null) {
return false;
}
if (temp.accountName in temp.ownerAccounts) {
temp.winner = temp.ownerAccounts.remove(temp.accountName);
temp.winner.chat = "You've won the bet by slain thy opponent!";
for (temp.i: temp.itemDetails) {
//addinvobject(int, int) - I assue id/quantity
temp.winner.addinvobject(temp.i[0], temp.i[1]);
}
level.objectOwner1 = null;
level.objectOwner2 = null;
}
}