Dimosha Posted February 17, 2016 Share Posted February 17, 2016 Доброго времени суток. Помогите, пожалуйста, с решением ошибки. Обработчик с внешней функцией: -- Server Events addEventHandler ( "onPlayerWasted", getRootElement(), Round:OnPlayerDie ) Ошибка: [2016-02-17 13:57:45] SCRIPT ERROR: zp\Scripts\server\Events.lua:2: function arguments expected near ')' [2016-02-17 13:57:45] ERROR: Loading script failed: zp\Scripts\server\Events.lua:2: function arguments expected near ')' Функция в другом файле: Round = {} function Round:OnPlayerDie(ammo, attacker, weapon, bodypart) -- ammo - количество патрон умершего человека -- attacker - кто убил (player или vehicle). getElementType ( attacker ) == "player" или "vehicle" -- weapon - ИД оружия -- bodypart - часть тела Player:OnDie(source, attacker) end Голову сломал, понять не могу... Link to comment
Kenix Posted February 17, 2016 Share Posted February 17, 2016 Если хочешь привязать событие к классу, то нужно это сделать в конструкторе класса function self.__OnPlayerDie( ... ) self:OnPlayerDie( ... ); end addEventHandler ( "onPlayerWasted", root, self.__OnPlayerDie ); Или в твоем случае это: function Round.__OnPlayerDie( ... ) Round:OnPlayerDie( ... ); end addEventHandler ( "onPlayerWasted", root, Round.__OnPlayerDie ); или addEventHandler ( "onPlayerWasted", root, function( ... ) Round:OnPlayerDie( ... ); end ); Link to comment
Dimosha Posted February 17, 2016 Author Share Posted February 17, 2016 Понял, буду знать. Огромное спасибо Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now