OnDynamicListItemChanged

From GT-MP
Jump to: navigation, search
OnDynamicListItemChanged
Client-Side Function
System-users.png Client-Side Javascript.png JavaScript

Called when a dynamic list item's value is changed.

Usage example(s)

In Javascript
Client-Side Function

var menuItem = API.createDynamicListItem("Left Label", "Description", "0");

menuItem.OnDynamicListItemChanged.connect(function (item, goRight) {
    var v = Number(item.CurrentListItem);
    if (goRight)
        v++;
    else
        v--;
    return '' + v;
});
var menuItem = null;
API.onResourceStart.connect(function() {
    menuItem = API.createDynamicListItem("Left Label", "Description", "0");

    menuItem.OnDynamicListItemChanged.connect(function (item, goRight) {
        API.triggerServerEvent("DYNMICLISTITEM", item.Text, goRight);
        return item.CurrenListItem; // no change
    });
});

API.onServerEventTrigger.connect(function (eventName , args) {
    if (eventName == "UPDATELISTITEM") {
        menuItem.CurrentListItem = args[0]; // Change Text betweeen < >
    }
});

References