So I made my own custom chest and I think its pretty good (for my abilities at least). I'm curious as to how I can improve it or if anyone sees anything wrong with it.
Thank you
PHP Code:
function onActionTakeItem() {
player.addweapon(params[0]);
serverr.chestitems.remove(params[0]);
player.chat = "Received " @ params[0] @ "!";
}
function onActionAddItem() {
player.removeweapon(params[0]);
serverr.chestitems.add(params[0]);
player.chat = "Added " @ params[0] @ "!";
}
function onActionAddItemList() {
serverr.chestitems = {"Public/pig132/Strafe", "Personal/pig132/Boots"};
}
//#CLIENTSIDE
function onCreated() {
//triggeraction(this.x + 1, this.y + 1, "AddItemList");
new GuiWindowCtrl("Chest_Main") {
profile = GuiBlueWindowProfile;
visible = false;
x = player.x;
y = player.y;
width = 200;
height = 200;
canmaximize = canminimize = canresize = canclose = false;
destroyonhide = false;
text = "Chest";
new GuiScrollCtrl("Chest_Scroll") {
profile = GuiBlueScrollProfile;
x = 10;
y = 30;
width = 130;
height = 160;
hScrollBar = "dynamic";
vScrollBar = "alwaysOff";
new GuiTextListCtrl("Chest_List") {
profile = GuiBlueTextListProfile;
x = y = 0;
width = 130;
fitparentwidth = true;
clearrows();
addrow(0, serverr.chestitems[0]);
addrow(1, serverr.chestitems[1]);
setSelectedRow(0);
}
}
new GuiButtonCtrl("Button_Take") {
profile = GuiBlueButtonProfile;
x = 145;
y = 30;
width = 40;
height = 25;
text = "Take";
}
new GuiButtonCtrl("Button_Add") {
profile = GuiBlueButtonProfile;
x = 145;
y = 60;
width = 40;
height = 25;
text = "Add";
}
new GuiButtonCtrl("Button_Close") {
profile = GuiBlueButtonProfile;
x = 145;
y = 165;
width = 40;
height = 25;
text = "Close";
}
}// main window (200 x 200)
}
function onPlayerTouchsme() {
Chest_Main.show();
}
function Button_Close.onAction() {
Chest_Main.hide();
}
function Button_Take.onAction() {
this.item = Chest_List.getselectedtext();
this.ritem = Chest_List.getselectedid();
triggeraction(this.x + 1, this.y + 1, "TakeItem", this.item);
Chest_List.removerowbyid(this.ritem);
}
function Button_Add.onAction() {
this.additem = player.weapon.name;
triggeraction(this.x + 1, this.y + 1, "AddItem", this.additem);
Chest_List.addrow(rowcount + 1, this.additem);
}