• 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!

Lua Unfocus all players NPC

mackerel

Well-Known Member
Joined
Apr 26, 2017
Messages
398
Solutions
18
Reaction score
74
I have this script to cancel dialogs between all players with this specific npc but its not really working and not sure why. its for tfs 1.0

LUA:
    local player = Player(cid)
    local people = Game.getSpectators(player:getPosition(), false, true, 6, 6, 5, 5)
    for i = 1, #people do
        if npcHandler:isFocused(people[i].cid) then
            npcHandler:releaseFocus(people[i].cid)
        end
    end
 
Solution
userdata = Game.getSpectators(player:getPosition(), false, true, 6, 6, 5, 5)

I can releaseFocus for main character:

npcHandler:releaseFocus(cid)

And goes getSpectators return userdata or creature id?
If it's creature id you need to do as I posted above;
LUA:
Player(people[i])
I have this script to cancel dialogs between all players with this specific npc but its not really working and not sure why. its for tfs 1.0

LUA:
    local player = Player(cid)
    local people = Game.getSpectators(player:getPosition(), false, true, 6, 6, 5, 5)
    for i = 1, #people do
        if npcHandler:isFocused(people[i].cid) then
            npcHandler:releaseFocus(people[i].cid)
        end
    end

Have you tested;
LUA:
Player(people[i])
You should move to 1.2 since 1.0 and 1.1 isn't support anymore.
 
Have you tested;
LUA:
Player(people[i])
You should move to 1.2 since 1.0 and 1.1 isn't support anymore.

tested, not working- no errors

I should but the tools provided for 1.2 are limited


//edit

npcHandler:releaseFocus(cid) -- stopped working completely *facepalm*
 
Last edited:
tested, not working- no errors

I should but the tools provided for 1.2 are limited


//edit

npcHandler:releaseFocus(cid) -- stopped working completely *facepalm*

All you need to do is use Player(player) if you wanna use 1.x scripts in w/e 1.x version (above 1.1).
Check if it uses creature id or creature userdata.
 
All you need to do is use Player(player) if you wanna use 1.x scripts in w/e 1.x version (above 1.1).
Check if it uses creature id or creature userdata.

userdata = Game.getSpectators(player:getPosition(), false, true, 6, 6, 5, 5)
userdata = Player(cid)

I can releaseFocus for main character:

npcHandler:releaseFocus(cid)
 
userdata = Game.getSpectators(player:getPosition(), false, true, 6, 6, 5, 5)

I can releaseFocus for main character:

npcHandler:releaseFocus(cid)

And goes getSpectators return userdata or creature id?
If it's creature id you need to do as I posted above;
LUA:
Player(people[i])
 
Solution
And goes getSpectators return userdata or creature id?
If it's creature id you need to do as I posted above;
LUA:
Player(people[i])

OF course GetID ! omg THX

if someone needs one

LUA:
    local people = Game.getSpectators(player:getPosition(), false, true, 6, 6, 5, 5)
    for i = 1, #people do
        if npcHandler:isFocused(Player(people[i]):getId()) then
            npcHandler:releaseFocus(Player(people[i]):getId())
        end
    end
 
Back
Top