Skip to content

onElementModelChange can't be cancelled using setElementModel #948

@Lord-Henry

Description

@Lord-Henry

Describe the bug
Using the script below doesn't work.

Steps to reproduce
Create a server-side script with this: (sorry, this website doesn't support indentation nor highlights)

addEventHandler ("onElementModelChange", root, function (oldModel, newModel)
        if (getElementType (source) == "player") then
            if (newModel == 12) then
                outputChatBox ("Skin locked! You can't use it.", source, 255, 30, 30)
                setElementModel (source, oldModel) -- According to Wiki, this should work.
            end
        end
end)

Expected behaviour
Skin should change back.

How to "fix" the issue
Just make setElementModel inside a timer, like this:

addEventHandler ("onElementModelChange", root, function (oldModel, newModel)
        if (getElementType (source) == "player") then
            if (newModel == 12) then
                outputChatBox ("Skin locked! You can't use it.", source, 255, 30, 30)
                setTimer (function (thePlayer)
                    setElementModel (thePlayer, oldModel)
                end, 100, 1, source)
            end
        end
end)

Version
Both v1.5.6-release-16616

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions