npcSystem4 = {
["Who are you?"] = {
d_answer = "I am xxxx, etc"
},
["what is this place?"] = {
d_answer = "....text...",
["What happened here?"] = {
d_answer = "...text..."
}
},
["can i help you with something?"] = {
m_any_storage_s = {{storage, value},}, --default value is -1 if nil
answer = " ....text...."
},
["where can i find what you looking for?"] = {
m_any_storage_s = {{storage, value},{storage, value},},
answer = "..text..."
}
-- well good enuf for example i guess
}
--Name: can be anything
--id: start with 0xFF then each modal window in the script add an F so: 0xFFF, 0xFFFF
--title: title --param
--msg: What you want the NPC to say. --param
--cid: Ignore
--choice: Option to say to NPC. --param
--button: Enter button --param
--button2: Exit button --param
--storageKey = storage number to check
--storage: Optional: modal window will only popup if player has the storage value == storage
--choice2-5: Optional, you do not have to enter these unless you want more choices --params
function npcModalWindow(cid, name, id, title, msg, choice, button, button2, storageKey, storage, choice2, choice3, choice4, choice5)
local name = ModalWindow(id, title, msg)
name:addChoice(0x00, choice)
if choice2 then
name:addChoice(0x01, choice2)
end
if choice3 then
name:addChoice(0x02, choice3)
end
if choice4 then
name:addChoice(0x03, choice3)
end
if choice5 then
name:addChoice(0x04, choice4)
end
name:addButton(0x01, button)
name:addButton(0x02, button2)
if storageKey then
if storage then
if getPlayerStorageValue(cid, storageKey) == storage then
name:sendToPlayer(cid)
end
end
else
name:sendToPlayer(cid)
end
end
thats what I ment.The best I can do is make a function for you to use... Other then that you will have to take the time to make them.
Code:--Name: can be anything --id: start with 0xFF then each modal window in the script add an F so: 0xFFF, 0xFFFF --title: title --param --msg: What you want the NPC to say. --param --cid: Ignore --choice: Option to say to NPC. --param --button: Enter button --param --button2: Exit button --param --storageKey = storage number to check --storage: Optional: modal window will only popup if player has the storage value == storage --choice2-5: Optional, you do not have to enter these unless you want more choices --params function npcModalWindow(cid, name, id, title, msg, choice, button, button2, storageKey, storage, choice2, choice3, choice4, choice5) local name = ModalWindow(id, title, msg) name:addChoice(0x00, choice) if choice2 then name:addChoice(0x01, choice2) end if choice3 then name:addChoice(0x02, choice3) end if choice4 then name:addChoice(0x03, choice3) end if choice5 then name:addChoice(0x04, choice4) end name:addButton(0x01, button) name:addButton(0x02, button2) if storageKey then if storage then if getPlayerStorageValue(cid, storageKey) == storage then name:sendToPlayer(cid) end end else name:sendToPlayer(cid) end end
No, i just fill out the table, and the new modal window is automatically generated.Because he has to make all the of modal windows inside creaturescripts.
I don't think it really matters, although I dont even have the second function xD (i deleted all the useless TFS compat functions aka entire compat.lua file (and lib folders))Isnt better to use player:getStorageValue than getPlayerStorageValue(cid) I know its in compat, but reduces some ticks![]()
Doesnt matter at all, but always better to use real functions. Thats just an "interface", and maybe at some point u wont have that compat lib (just as you do nowI don't think it really matters, although I dont even have the second function xD (i deleted all the useless TFS compat functions aka entire compat.lua file (and lib folders))
well you missed the point or i just suck at explaining what I want xDAlright, you could do something like this...
NPC_modals
The npcModals.lua put inside your server file just right in front with the executable.
Then im sure you will figure it out from there.
I'd say you are just poor at explaining what you mean, as usual.well you missed the point or i just suck at explaining what I want xD
because this is not dynamical enough.
I guess i just make the system my own.
RektI'd say you are just poor at explaining what you mean, as usual.![]()
![]()
![]()
Exactly!I think he is saying:
1) scipt checks players storage's
2) Puts new choices in the modal window depending on the storages it calls
--So if player has storage 40100 == 1 then it adds a new choice
--if player has storage 40101 == 1 then it adds another choice
xD not really. that's why I said it takes day if not 2. it requires lot of code writing.impossible as requested
guess you better get started thenExactly!
xD not really. that's why I said it takes day if not 2. it requires lot of code writing.
local config = {
[41000] = {choiceid = 0x00, text = "text to send"},
[41001] = {choiceid = 0x01, text = "text to send"}
}
local window = ModalWindow(0xFF, "NPC", "msg")
for i = 1, #config do
if getPlayerStorageValue(cid, config[i]) == 1 then
window:addChoice(config[i].choiceid, config[i].text)
end
well the npc update wont come that soon. I got some more important things to do before.guess you better get started then
I also have no idea what you're asking for. I made a system for trading with an npc in a modalwindow, allowing limited money and items for each individual npc, but I never bothered making a communication system in the modalwindows because the interface just isn't all that friendly.
i dont like the choiceid in the table itself, i want them generated automatically.In NPC file just do:
Code:local config = { [41000] = {choiceid = 0x00, text = "text to send"}, [41001] = {choiceid = 0x01, text = "text to send"} } local window = ModalWindow(0xFF, "NPC", "msg") for i = 1, #config do if getPlayerStorageValue(cid, config[i]) == 1 then window:addChoice(config[i].choiceid, config[i].text end
Easiest way to implement new choices by storage.
in libs.lua / global.luaIn NPC file just do:
Code:local config = { [41000] = {choiceid = 0x00, text = "text to send"}, [41001] = {choiceid = 0x01, text = "text to send"} } local window = ModalWindow(0xFF, "NPC", "msg") for i = 1, #config do if getPlayerStorageValue(cid, config[i]) == 1 then window:addChoice(config[i].choiceid, config[i].text) end
Easiest way to implement new choices by storage.
function num2hex(num)
local hexstr = '0123456789abcdef'
local s = ''
while num > 0 do
local mod = math.fmod(num, 16)
s = string.sub(hexstr, mod+1, mod+1) .. s
num = math.floor(num / 16)
end
if s == '' then s = '0' end
return
end
local config = {
[41000] = "text to send",
[41001] = "text to send"
}
local window = ModalWindow(0xFF, "NPC", "msg")
for i, text in pairs(config) do
if getPlayerStorageValue(cid, config[i]) == 1 then
window:addChoice(i-41000, text)
end