Quote:
Originally Posted by scriptless
So I am trying to pass a variable with an event.. Not sure if it's possible? Or if I am way wrong on how to do it? I am planning to have let's say 10 images, and clicking on them will make the player chat the number of the image it clicked on..
PHP Code:
//#CLIENTSIDE
function onCreated() {
for ( i = 0; i < 10; i++ ) {
new GuiShowImgCtrl("test" @ i) {
y = 55;
x = 50 + i * 40;
image = "block.png";
thiso.catchevent(this, "onMouseDown", "onSelect", i);
}
}
}
function onSelect() {
player.chat = "a" SPC params[0];
}
Didn't work.
Removing i from catchevent(), however, shows the name of the Control.
|
The parameter received is actually the GUI object rather than its name. You can just write this. variables to the GUI object itself then use the object as reference:
PHP Code:
//#CLIENTSIDE
function onCreated() {
for ( i = 0; i < 10; i++ ) {
new GuiShowImgCtrl("test" @ i) {
y = 55;
x = 50 + i * 40;
image = "block.png";
this.num = i;
thiso.catchevent(this, "onMouseDown", "onSelect", i);
}
}
}
function onSelect(temp.gui) {
player.chat = temp.gui.num;
}