Howdy Forums, there happens to be something wrong with my custom chest script, when it updates the chest as I put something in, it just leaves a blank line in the (Inside the chest textlist). When I take that out of the chest, THEN it removes it from my inventory. Its really weird, can someone please help me, I've posted my current script below.
NOTE TO OTHER SERVERS: Please do not take this script with my approval.
Heres the chest class:
PHP Code:
//#CLIENTSIDE
function onCreated() {
this.image = "woodenchest.png";
setimgpart("woodenchest.png",0,0,32,32);
}
function onPlayerTouchsMe() {
openChestGui(this.inside);
( @ "Chests_Window_" @ this.chestid).show();
}
function openChestGui(inside) {
new GuiWindowCtrl("Chests_Window_"@this.chestid) {
profile = GuiBlueWindowProfile;
clientrelative = true;
clientextent = "498,302";
canmaximize = false;
canminimize = false;
canmove = true;
canresize = false;
closequery = false;
destroyonhide = false;
text = "Chests";
x = 423;
y = 198;
new GuiButtonCtrl("Chests_Window_Button1") {
profile = GuiBlueButtonProfile;
height = 42;
text = "Put in Chest";
width = 498;
y = 218;
}
new GuiButtonCtrl("Chests_Window_Button2") {
profile = GuiBlueButtonProfile;
height = 42;
text = "Take from Chest";
width = 498;
y = 260;
}
new GuiScrollCtrl("Chests_Window_TextList1_Scroll") {
profile = GuiBlueScrollProfile;
height = 171;
hscrollbar = "alwaysOff";
vscrollbar = "dynamic";
width = 181;
x = 21;
y = 24;
new GuiTextListCtrl("Chests_Window_TextList1") {
profile = GuiBlueTextListProfile;
height = 34;
horizsizing = "width";
sortcolumn = 181348608;
width = 177;
clearrows();
for (temp.i = 0; temp.i < inside.size(); temp.i ++) {
addrow(temp.i,inside[(@temp.i)]);
sort();
}
}
}
new GuiTextCtrl("Chests_Window_Text1") {
profile = GuiBlueTextProfile;
height = 20;
text = "Chest";
width = 34;
x = 89;
y = 4;
}
new GuiScrollCtrl("Chests_Window_TextList2_Scroll") {
profile = GuiBlueScrollProfile;
height = 173;
hscrollbar = "alwaysOff";
vscrollbar = "dynamic";
width = 192;
x = 282;
y = 23;
new GuiTextListCtrl("Chests_Window_TextList2") {
profile = GuiBlueTextListProfile;
height = 34;
horizsizing = "width";
sortcolumn = 181345792;
width = 188;
clearrows();
for (temp.e = 0; temp.e < player.weapons.size(); temp.e ++) {
if (!(player.weapons[(@temp.e)].name.starts("-") || player.weapons[(@temp.e)].name in this.notallowed) || player.weapons[(@temp.e)].name.starts("Astram")) {
addrow(temp.e,player.weapons[(@temp.e)].name);
sort();
}
}
}
}
new GuiTextCtrl("Chests_Window_Text2") {
profile = GuiBlueTextProfile;
height = 20;
text = "My Items";
width = 51;
x = 355;
y = 4;
}
}
}
function Chests_Window_Button1.onAction() {
triggerserver( "gui", "Astram/Chests", "PutIn", Chests_Window_TextList2.getSelectedText());
this.inside.add(Chests_Window_TextList2.getSelectedText());
openChestGui(this.inside);
}
function Chests_Window_Button2.onAction() {
triggerserver( "gui", "Astram/Chests", "TakeOut", Chests_Window_TextList1.getSelectedText());
this.inside.remove(Chests_Window_TextList1.getSelectedText());
openChestGui(this.inside);
}
Heres the NPC Code:
PHP Code:
this.chestid = 0947479;
join("chest");
Heres the weapon Coding:
PHP Code:
function onActionServerSide() {
if (params[0] == "PutIn") {
player.removeweapon(params[1]);
}
if (params[0] == "TakeOut") {
player.addweapon(params[1]);
}
}