Alright, so I am making a shop GUI (in a class) but I can't seem to get the triggers work. For example, when the buy button is clicked, it won't trigger and i've read that you can't triggerserver in classes, but triggeraction won't seem to work either. This is my current code (onaction at the top and the trigger at the bottom)
PHP Code:
function onCreated()
{
setshape(1, 32, 32);
}
function onActionBuy()
{
player.chat = "HELLO";
}
//#CLIENTSIDE
function onActionLeftMouse()
{
onCreated();
}
function onCreated()
{
setshape(1,32,32);
new GuiWindowCtrl("shop_window")
{
profile = GuiBlueWindowProfile;
x = screenwidth / 2.5;
y = screenheight / 2.5;
text = "Zoraa's Shop";
width = 210;
height = 150;
destroyonhide = true;
closequery = true;
canresize =
canminimize =
canclose =
canmaximize = false;
new GuiButtonCtrl("shop_close")
{
profile = GuiBlueButtonProfile;
x = 65;
y = 120;
width = 75;
height = 20;
text = "Close";
}
new GuiButtonCtrl("shop_bomb")
{
profile = GuiBlueButtonProfile;
x = 10;
y = 28;
width = 60;
height = 60;
new GuiShowImgCtrl("shop_disp_bomb")
{
x = 15;
y = 15;
width = 32;
height = 32;
image = "bomb.png";
layer = 4;
}
}
new GuiButtonCtrl("shop_arrow")
{
profile = GuiBlueButtonProfile;
x = 75;
y = 28;
width = 60;
height = 60;
new GuiShowImgCtrl("shop_disp_arrow")
{
x = 25;
y = 15;
width = 10;
height = 30;
image = "arrow.png";
layer = 4;
}
}
new GuiButtonCtrl("shop_fullheart")
{
profile = GuiBlueButtonProfile;
x = 140;
y = 28;
width = 60;
height = 60;
new GuiShowImgCtrl("shop_disp_heart")
{
x = 15;
y = 15;
width = 31;
height = 33;
image = "state.png";
offsetx = -80;
offsety = 0;
layer = 4;
}
}
new GuiTextCtrl("shop_bomb_amount")
{
profile = GuiBlueTextProfile;
x = 25;
y = 85;
text = "Price:";
}
new GuiTextCtrl("shop_bomb_amount2")
{
profile = GuiBlueTextProfile;
x = 10;
y = 98;
text = "25 for 10g";
}
new GuiTextCtrl("shop_arrow_amount")
{
profile = GuiBlueTextProfile;
x = 90;
y = 85;
text = "Price:";
}
new GuiTextCtrl("shop_arrow_amount2")
{
profile = GuiBlueTextProfile;
x = 75;
y = 98;
text = "30 for 10g";
}
new GuiTextCtrl("shop_heart_amount")
{
profile = GuiBlueTextProfile;
x = 155;
y = 85;
text = "Price:";
}
new GuiTextCtrl("shop_heart_amount2")
{
profile = GuiBlueTextProfile;
x = 145;
y = 98;
text = "3 for 25g";
}
} // main window
}
function shop_close.onAction()
{
shop_window.destroy();
player.chat = "Thanks for shopping!";
}
function shop_bomb.onAction()
{
triggeraction(this.x, this.y, "Buy", null);
}
If anyone could help me with this and/or possibly help me optimize my code that would be great. Thanks
