Перейти к содержанию

Дайджесты за январь-февраль

Обновления гайдов и аддонов

Январь Февраль

Мониторинг серверов и редактор аддонов

Представляем вам две легенды. То, о чем можно было только мечтать, стало реальностью.

Мониторинг серверов Редактор аддонов

Подсказки из игры на вашем сайте

Теперь вы можете отображать сведения о внутриигровых элементах простым наведением курсора мыши.

Подробнее

Апдейтер аддонов

Представляем вам программу для автообновления аддонов и делимся подробностями.

Подробнее Скачать

param 1 not a class


Dragagon

Рекомендуемые сообщения

Question about an error I get often.
Following example is:
 

[15:53:42]Error: addon AutoIreneMasks(0): Game::LuaCheckroomEquipItem: param 1 not a class GMUIHelper::ObjectId (type: nil), details: int __cdecl Game::LuaCheckroomEquipItem(struct lua_State *)
  func: EquipItem, field, line: -1, defined: C, line: -1, [C]
    func: ?, ?, line: 0, defined: Lua, line: 0, [string "Mods/Addons/AutoIreneMasks/Script.luac"]

But there are no guidelines on what line it is, so how do u start debugging this?
param 1 is not a class, a class of what? What can I do about it that it is not a class?
I believe it has a parameter in my code:
 

checkroomLib.EquipItem( WanderingActorMaskId )

and the API reference doesn't say anything specific about parameters.
So what can I do about this error?

Ссылка на комментарий
Поделиться на другие сайты

28 минут назад, Dragagon сказал:

Question about an error I get often.

You pass nil as a parameter to the function

Ссылка на комментарий
Поделиться на другие сайты

14 minutes ago, OLDodin said:

You pass nil as a parameter to the function

Function only runs when parameter has already gotten a value assigned, I wouldn't know how it would ever get a nil. Chatlogs show before running the code everytime that it has a value.

image.png.24fd1cbeefe0e5cd9b73a03e01155e65.png

ChatLog("Is Freebird mask nil?", freeBirdMaskId)
				checkroomLib.EquipItem( freeBirdMaskId )

But the error persists.

Ссылка на комментарий
Поделиться на другие сайты

I think the game can't find object with your id. You can get real existing id only when checkroom is opened and replicated. When you close checkroom your id becomes not real and you can not equip this item. Do your logic in EVENT_CHECKROOM_CHANGED event and check if checkroomLib.IsOpened()

Also check these api references to understand how it works:

checkroomLib.Open()

checkroomLib.Close()

Ссылка на комментарий
Поделиться на другие сайты

Hey Slash, thanks for the reply.
I took a good read at the API's and a few things have me in question.

When I close the wardrobe, why does it expect EVENT_CHECKROOM_CHANGED?
I believe it cannot change costumes while the wardrobe is closed?

Quote

checkroomLib.Close()

Closes wardrobe. The contents of the wardrobe are removed from the client. The EVENT_CHECKROOM_CHANGED event should come .

 

EVENT_CHECKROOM_CHANGED

The event is dispatched when a player has requested checkroomLib.Open() or checkroomLib.Close() and a transfer to the client has occurred or the contents of the wardrobe have been cleared from the client.

And in the code, I only equip pieces after opening the wardrobe. The wardrobe is closed with a delay because the close function would not execute right after equipping an Id.

OpenWardrobe()
		if checkroomLib.IsOpened() then
			checkroomLib.EquipItem( freeBirdMaskId ) --Requipping the Freebirdmask headwear.
		end
		--ChatLog("equipped FreeBird mask")
		common.RegisterEventHandler(CloseWardrobeCustom,"EVENT_SECOND_TIMER") --Starts delay before closing the wardrobe.
function CloseWardrobeCustom()
	--ChatLog("entering event second timer func & timerCount is: ",timerCount)
	if timerCount == 1 then
		--ChatLog("timerCount reached condition")
		CloseWardrobe()
		common.UnRegisterEventHandler(CloseWardrobeCustom,"EVENT_SECOND_TIMER")
		timerCount = 0
		return
	end
	timerCount = timerCount + 1
end

 

Изменено пользователем Dragagon
Ссылка на комментарий
Поделиться на другие сайты

You don't need any timers and EVENT_SECOND_TIMER. If you want to equip item, you should:

1. Call checkroomLib.Open()

2. In EVENT_CHECKROOM_CHANGED handler function check checkroomLib.IsOpened()

3. If it is true then all wardrobe info replicated to the client. Only now you can find the id of your item. And only now you can equip it

4. After equipping call checkroomLib.Close(). By this you tell to the server that you don't need replication anymore. Your id becomes non-synced and you can not use it anymore. Some time later you will receive EVENT_CHECKROOM_CHANGED again, but checkroomLib.IsOpened() will be false. It used by game to know when the wardrobe window must be closed 

Ссылка на комментарий
Поделиться на другие сайты

Hey Slash, thanks again for taking a look.
I have tried what you described but it does not work for me.
THe event seems to only run whenever an item is changed. I already get to open the wardrobe, equip the item and close it without using that event.
THe only bug I have so far is that it doesn't equip the item the first time the player goes to Irene in his playing session. All other times following up to that until a relog works fine.
It runs code that the wardrobe is open, it also closes the wardrobe, it also find the ID of the item. It simply does not checkroomLib.EquipItem(id).
I tried with your if statement wether to see if wardrobe is open or not but that seems to return false even if the wardrobe is opened, so it never equips or closes my wardrobe then. I believe the 1st time it opens the wardrobe for the player, it takes too long to load in all costumes and their id's, that the code is skipped.
Hence I put a delay on closing wardrobe which made it work. Cause if I did it without a delay, it would not close.
So just by adding a small delay, it works.
I will just work with a small delay before equipping the item when opening the wardrobe and I suppose that will fix it for both cases.

Ссылка на комментарий
Поделиться на другие сайты

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Восстановить форматирование

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

×
×
  • Создать...

Важная информация

Пользуясь сайтом, вы принимаете Условия использования