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

TFS 1.1 NPC

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,435
Solutions
68
Reaction score
1,083
Alright guys, I have hit a point in my server development that I need a code I am unsure how to make.

So, when the player is at a certain point in a quest I need an NPC to pop up and talk to him. The NPC cannot be talked to by anyone other then the person doing the quest.

The good news is the chances of multiple people being on the same quest and the NPC needs to pop up more then once at a time is impractical.

So, my question is how do I get the NPC to only allow the certain player to talk to him.

Here are some things I have tried:

1) Adding focus to the player and checking the focus
-Create NPC
-Set the NPC to focus the player
-Only talk to the player it is focused on
*unsuccessful attempt

2) Setting a storage to the player so the NPC will only talk to people with that storage
-Create NPC
-NPC will talk to anyone with the correct storage in the area.
*Preferably not the way to have the NPC set up.

I can use the second method however, I would prefer another way. As I said it wont be common for 2 players to be in the same quest at the same point, but if it did ever happen I wouldn't want a problem to come up. If anyone knows a way to make this work please let me know.
 
Alright guys, I have hit a point in my server development that I need a code I am unsure how to make.

So, when the player is at a certain point in a quest I need an NPC to pop up and talk to him. The NPC cannot be talked to by anyone other then the person doing the quest.

The good news is the chances of multiple people being on the same quest and the NPC needs to pop up more then once at a time is impractical.

So, my question is how do I get the NPC to only allow the certain player to talk to him.

Here are some things I have tried:

1) Adding focus to the player and checking the focus
-Create NPC
-Set the NPC to focus the player
-Only talk to the player it is focused on
*unsuccessful attempt

2) Setting a storage to the player so the NPC will only talk to people with that storage
-Create NPC
-NPC will talk to anyone with the correct storage in the area.
*Preferably not the way to have the NPC set up.

I can use the second method however, I would prefer another way. As I said it wont be common for 2 players to be in the same quest at the same point, but if it did ever happen I wouldn't want a problem to come up. If anyone knows a way to make this work please let me know.
are you not able to check player userdata to make sure its equal to the one that the npc is focused on, if not then the npc will do nothing?
 
Alright guys, I have hit a point in my server development that I need a code I am unsure how to make.

So, when the player is at a certain point in a quest I need an NPC to pop up and talk to him. The NPC cannot be talked to by anyone other then the person doing the quest.

The good news is the chances of multiple people being on the same quest and the NPC needs to pop up more then once at a time is impractical.

So, my question is how do I get the NPC to only allow the certain player to talk to him.

Here are some things I have tried:

1) Adding focus to the player and checking the focus
-Create NPC
-Set the NPC to focus the player
-Only talk to the player it is focused on
*unsuccessful attempt

2) Setting a storage to the player so the NPC will only talk to people with that storage
-Create NPC
-NPC will talk to anyone with the correct storage in the area.
*Preferably not the way to have the NPC set up.

I can use the second method however, I would prefer another way. As I said it wont be common for 2 players to be in the same quest at the same point, but if it did ever happen I wouldn't want a problem to come up. If anyone knows a way to make this work please let me know.
what you can do, is set storagevalues based on cid, and compare them when talking to the npc.

something like this;

Code:
<npc name="Example Npc" script="Example Npc.lua" walkinterval="0" speechbubble="3">
<look typeex="111" />
<parameters>
<parameter key="message_greet" value="hello" />
<parameter key="message_walkaway" value="cya" />
<parameter key="message_farewell" value="cya" />
</parameters>
</npc>

Code:
local function greetCallback(cid)
    local player = Player(cid)
    if player:getStorageValue(player:getId()) ~= x then -- x being whatever you're interested in doing. player:getId() can be changed to whatever.
        npcHandler:say("Sorry, I don't talk with strangers.", cid)
        return false
    end
    return true
end

local function creaturesayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

-- rest of script
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

there u have ur full script for what you want to do (almost)
 
I was trying my best to stay away from storages but I guess it will be the easiest way.

I decided to do it this way:

1)Player is at correct quest progress
2)Player walks on certain tiles (he has to for the quest) to get where he needs to go
3)The tile sets a storage value to the players id
4)NPC uses that storage to work

Ty for help guys.

Why don't you want to use the storage way?
I have a few systems that use storages a lot and I am trying to keep as much lag out as possible.
 
Back
Top