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

Scripter Itutorial scripting service

@whitevo

This one can be configured pretty easily.... You will of course have to make a creature script... 1 for every NPC running this so you can use the same data like 0x00

Code:
local adv_config = {
["text1"] = {
storages = {[1] = {storage = 40000, value = 1, data = 0x00, text = "text1"}, [2] = {storage = 40001, value = 1, data = 0x01, text = "text2"}},

["text2"] = {
storages = {[1] = {storage = 40000, value = 2, data = 0x10, text = "text1"}, [2] = {storage = 40001, value = 2, data = 0x11, text = "text2"}}
}}}

local WINDOW = ModalWindow(0xFF, "NPC", "msg")

if msg == "text1" then
    EXECUTE = adv_config[msg]
        if not EXECUTE then
        return true
        end
     
    for i = 1, #EXECUTE.storages[i] do
        if getPlayerStorageValue(cid, EXECUTE.storages[i].storage) == EXECUTE.storages[i].value then
            WINDOW:addChoice(EXECUTE.storages[i].data, EXECUTE.storages[i].text)
        end
    end
 
    WINDOW:sendToPlayer(cid)
end
 
@whitevo

This one can be configured pretty easily.... You will of course have to make a creature script... 1 for every NPC running this so you can use the same data like 0x00

Code:
local adv_config = {
["text1"] = {
storages = {[1] = {storage = 40000, value = 1, data = 0x00, text = "text1"}, [2] = {storage = 40001, value = 1, data = 0x01, text = "text2"}},

["text2"] = {
storages = {[1] = {storage = 40000, value = 2, data = 0x10, text = "text1"}, [2] = {storage = 40001, value = 2, data = 0x11, text = "text2"}}
}}}

local WINDOW = ModalWindow(0xFF, "NPC", "msg")

if msg == "text1" then
    EXECUTE = adv_config[msg]
        if not EXECUTE then
        return true
        end
    
    for i = 1, #EXECUTE.storages[i] do
        if getPlayerStorageValue(cid, EXECUTE.storages[i].storage) == EXECUTE.storages[i].value then
            WINDOW:addChoice(EXECUTE.storages[i].data, EXECUTE.storages[i].text)
        end
    end

    WINDOW:sendToPlayer(cid)
end
well first off, you should use metatables and scrap all the old functions :p
 
@whitevo

This one can be configured pretty easily.... You will of course have to make a creature script... 1 for every NPC running this so you can use the same data like 0x00

Code:
local adv_config = {
["text1"] = {
storages = {[1] = {storage = 40000, value = 1, data = 0x00, text = "text1"}, [2] = {storage = 40001, value = 1, data = 0x01, text = "text2"}},

["text2"] = {
storages = {[1] = {storage = 40000, value = 2, data = 0x10, text = "text1"}, [2] = {storage = 40001, value = 2, data = 0x11, text = "text2"}}
}}}

local WINDOW = ModalWindow(0xFF, "NPC", "msg")

if msg == "text1" then
    EXECUTE = adv_config[msg]
        if not EXECUTE then
        return true
        end
    
    for i = 1, #EXECUTE.storages[i] do
        if getPlayerStorageValue(cid, EXECUTE.storages[i].storage) == EXECUTE.storages[i].value then
            WINDOW:addChoice(EXECUTE.storages[i].data, EXECUTE.storages[i].text)
        end
    end

    WINDOW:sendToPlayer(cid)
end
Thank you for your effort, but this config doesn't look similar the way I presented the example table for you.
I will just do the system myself to get what I want.


well first off, you should use metatables and scrap all the old functions :p
I don't like metatables at all.
Yesterday was second time I tried to use it.
Wanted to implement regular damage metatable for my spellcreating system. And after 2 hours trying to figure out how to use it.. I deleted entire script and started over without metatable.
I completed my new table in mere minutes.
And simply used these type of lines to make missing variables:
Code:
local tempType = spellName:match("t=%u+") or "PHYSICAL"
local Type = tempType:match("%u+")
 
Meta tables are simple...

local first = {
[1] = "hi"

Now to get the info its

first[1] (would call "hi")

local first = {
[1] = {storage = 41000}
}

Now to get storage you would do: first[1].storage

To use a loop in it:

first = {
[1] = {storage = 41000},
[2] = {storage = 41001}
}

for i = 1, #first do --For each value in the meta_table: first (there are 2 values so it will loop 2x)
if getStorage(first) == 1 then --first will be first[1] the first loop calling 41000 then it will loop again and call first[2] for 41001
--script
end

You can also do:
for i = 1, #first do
if first == first[1] then
--script
elseif first == first[2] then
--script
end

if you have:

local first = {
["second"] = {third = {[1] = "hi", [2] = "bye"}}
}

As you can see there is 3 table values
1) first
2)["second"]
3)third

If you want to call "hi" you do:

first["second"].third[1]

to call "bye you would do

first["second"].third[2]

or if you had it set like this:

first = {
second = {["third"] = {[1] = "hi", [2] = "bye"}}
}

then it would be:

first.second["third"][1] --would call "hi"

or

first.scrond["third"][2] -- would call "bye"
 
Last edited:
Back
Top