Register for your free account! | Forgot your password?

You last visited: Today at 02:44

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Beginner-Quest-TuT] How To Use Table

Discussion on [Beginner-Quest-TuT] How To Use Table within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.

Reply
 
Old   #1
 
MrLibya's Avatar
 
elite*gold: 30
Join Date: Mar 2012
Posts: 517
Received Thanks: 339
[Beginner-Quest-TuT] How To Use Table

Hallo all

In The Fitst This Is A Beginner Tut

in this tut we going to use
  • table insted of if elseif else
  • ipairs insted of table.getn ( Thanks To Marty <3 )

In What This Will help ? I am Seening To many pepole who want make quest and it's have too many if + elseif and they dont know when they put else or when they put end

in the end u have atleast 20 elseif and quest maybe 300 line

so i will show u how to write it in maybe 20 line and easy to understnad also easy to add new item to it

i will take a e.g for a item trade ( player give items for npc and he take a new item )

e.g For Quest

Code:
quest table_test begin
        state start begin
            when xxx.click begin
            say("chose what u want to give")
            local data01 = {
                -- Name        vnum    count        give_vnum        count
                {"Enargy", 51001, 200, 71159, 1},
                {"Drink", 71054, 1, 71160, 1},
            }
            local menu01 = {}
            for num1,str1 in ipairs(data01) do
                table.insert(menu01, str1[1])
            end
            local seltab01 = select_table(menu01, " Close ")
            local count_check = pc.count_item(data01[seltab01][2])
            if seltab01 == table.getn(menu01) then return end
            say(" Are u Sure U want Give ".. data01[seltab01][1] .." To Get "..item_name(data01[seltab01][4]).." ")
            if select("Yes Sure","No I Dont Want It") == 2 then return end
            if count_check < 1 then syschat("Not possess the required number") return end
            say_reward("You Get : "..item_name(data01[seltab01][3]+1).."")
            pc.removeitem(data01[seltab01][2],data01[seltab01][3])
            pc.give_item2(data01[seltab01][4], data01[seltab01][5])
        end -- when
    end -- state
end -- quest
Code:
[B]
[/B]


Let's Start

Code:
local data01 = {
Thos for Start The Table Items

{"Enargy", 51001, 200, 71159, 1},
Name        vnum    count        give_vnum        count

if u want add Other Item Just Add New Line 
{"Name", vnum, count, give_vnum, count},
Now To The Part That It's Show The Items in game:

Code:
            local menu01 = {}
            for num1,str1 in ipairs(data01) do
                table.insert(menu01, str1[1])
            end

Here As U Can See We Make New  Local And It's empty and we give him name menu01

then
Code:
[B]for num1,str1 in ipairs(data01) do[/B][B] < we here load the first tab from the data01

table.insert(menu01, str1[1])
we here insert the first tab from data01 to the menu01

[/B]


and now the part from quest to show tab for the player :
Code:
local seltab01 = select_table(menu01, " Close ")
the check count for the selected item
Code:
local count_check = pc.count_item(data01[seltab01][2])
Code:
[B][B]pc.count_item = count function[/B][/B]
[B][B][B]data01 = the table[/B][/B][/B]
[B][B][B][B]seltab01 = the [/B][/B][/B][/B][B][B][B][B][B]selected item tab[/B][/B][/B][/B][/B]
[B][B][B][B][B][2] = second tab from the selected item ( the item vnum tab )

[/B][/B][/B][/B][/B]


and i think
The rest code is clear

sry for my bed Engish

I Hope This Help Some Pepole


MrLibya is offline  
Thanks
4 Users
Old 03/20/2015, 16:24   #2

 
elite*gold: 83
Join Date: Nov 2013
Posts: 2,891
Received Thanks: 2,764
Thanks for share, could be very useful for beginners but the better questers in this section should already know this
rollback is offline  
Thanks
1 User
Old 03/20/2015, 16:29   #3
 
elite*gold: 0
Join Date: Jan 2015
Posts: 239
Received Thanks: 585
Maybe you could explain some functions you're using (like ipairs).
Without understanding what you're doing it's useless anyway.
i[Remix] is offline  
Thanks
1 User
Old 03/20/2015, 17:04   #4
 
MrLibya's Avatar
 
elite*gold: 30
Join Date: Mar 2012
Posts: 517
Received Thanks: 339
Quote:
Originally Posted by i[Remix] View Post
Maybe you could explain some functions you're using (like ipairs).
Without understanding what you're doing it's useless anyway.
i think u not noob for asking something like that

anyway here

MrLibya is offline  
Old 03/20/2015, 17:48   #5
 
.Xilent's Avatar
 
elite*gold: 12
Join Date: Jun 2012
Posts: 978
Received Thanks: 860
Actually this thread is better for beginners ,as it contains nearly all information you need to know (as a beginner). However there's no translation of that topic, so i'm pretty sure that your tutorial will help some english-speaking users
.Xilent is offline  
Old 03/20/2015, 19:18   #6
 
Noa_'s Avatar
 
elite*gold: 0
Join Date: May 2013
Posts: 605
Received Thanks: 580
what about generic for loops?
Noa_ is offline  
Reply


Similar Threads Similar Threads
Quest Beginner [ VSRO Files ]
05/09/2017 - SRO Private Server - 9 Replies
Someone could explain me how to remove beginner Assistant quests? http://img215.imageshack.us/img215/2232/sro201111 0112561965.jpg
Adding new table for quest.
04/08/2013 - CO2 Private Server - 1 Replies
hey guys so since my project is going to have alot of quests i was thiking to make a new table in navicat "quest" insited of saving them in enitity table, just to make it more clean. but i been having small problems, last night i coded few stuff which i tested didnt work proper, then thx to sedat we fixed few stuff. now there is this 1 thing i am stuck not sure what will it be and any kind of help will be nice. so first here is the questtable.cs
Quest-Table kaputt
05/03/2012 - Metin2 Private Server - 4 Replies
Hallo ich habe ein problem bei meinem Metin2 Pserver! Wenn ich mich einlogge und auf die Alte Frau klicke, kommt die Meldung "Spiel wird Beendet". Und wenn ich bei Navicat unter Player die Quest Tabelle öffnen will, kommt die Fehlermeldung: "145 - Table'./player/quest' is marked as crashed and should be repaired. Was soll ich tun? Oder kann mir jemand das bitte villeicht über TeamViewer machen? THX im Vorraus ;)
Beginner Quest 105+
10/02/2010 - Silkroad Online - 1 Replies
Having trouble finding the mobs i'm suppose to kill in tomb..
[Tip] Complete Beginner's Gemcutting quest.
06/20/2008 - General Gaming Releases - 1 Replies
Well, I thought Some people would like to know how I completed my quest ( It is bugged at the moment and you will not complete the quest objective if you do not do this. Buy 3 novice gemcutting kits Relog Craft 1 gem Relog Craft 1 more Relog Craft 1 more



All times are GMT +1. The time now is 02:45.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.