• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved [TFS 1.0] Unsafe script

Syryniss

Member
Joined
Feb 13, 2014
Messages
206
Reaction score
20
Hi there. I have just ported mine old outfit talkaction, which is changing player outfit and then restore old one if time specified. It works well so far, but if I use time event it gives me error in console, which is about unsafe scripts. I don't even know what does it mean, so I'm asking what I've done wrong?

Link to scipt
Lgivmd0.png
 
You need to pass the targetId not the target metatable !!!

So what you need to do is basicaly this:

addEvent(revertOutfit, split[3]*1000, target:getId(), oldOutfit)


function revertOutfit(targetId, oldOutfit)
local target = Creature(targetId)
if target then
target:setOutfit(oldOutfit)
end
end
 
Ok thanks. So, I shouldn't ever pass metatable or is there some rule? I'm asking, because today I also have done (well, not on my own) a spy equipment talkaction. And as you can see, I'm passing item metatable (as shown below) to another function and there are no errors here.
Code:
local item = target:getSlotItem(i)
[...]
text = text..slotName[i]..": "..item:getName()..getItemsInContainer(item, 1)
[...]
function getItemsInContainer(cont, sep)
 
You shouldn't pass metatable in addEvent, because the thing (player / creature / item) could not exist when the event is called, so you need to verify this before doing any action.
 
Back
Top