Jump to content
Forgot your email address? ×
×
×
  • Create New...
  • 0

Pet Change Name System


MrLibya

Question

  • Premium

Hallo

 

I Am Try To Make Pet Change Name System .

 

Function:

function pet_name_read()
    local mysql_read = mysql_query("SELECT pet_name FROM player.player where id = ('".. pc.get_player_id() .."')")
    return mysql_read.pet_name[1]
end
 

 

MySql Function:

mysql_query = function(query)
    if not pre then
        local rt = io.open('CONFIG', 'r'):read('*all')
        pre = string.gsub(rt, '.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+', '-h%1 -u%2 -p%3 -D%4')
    end

    math.randomseed(os.time())

    local fi, t, out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{}
    os.execute('mysql '..pre..' --e='..string.format('%q', query)..' > '..fi)

    for av in io.open(fi, 'r'):lines() do table.insert(t,split(av, 't')) end; os.remove(fi);
    for i = 2, table.getn(t) do table.foreach(t[i],function(a, 
        out[i-1]               = out[i-1] or {}
        out[i-1][a]            = tonumber( or b
        out[t[1][a]]           = out[t[1][a]] or {}
        out[t[1][a]][i-1]      = tonumber( or b
    end) end
    return out
end

function split(str, delim, maxNb)
    if str == nil then
        return str
    end

    if string.find(str, delim) == nil then
        return { str }
    end

    if maxNb == nil or maxNb < 1 then maxNb = 0 end

    local result = {}
    local pat = "(.-)" .. delim .. "()"
    local nb = 0
    local lastPos

    for part, pos in string.gfind(str, pat) do
        nb = nb + 1
        result[nb] = part
        lastPos = pos
        if nb == maxNb then break end
    end

    if nb ~= maxNb then result[nb + 1] = string.sub(str, lastPos)
    end
    return result
end

 

Quest

[53001]     = { 34001, pet_name_read() ,0},

 

http://prntscr.com/4yx8vs

 

 

  • Love 1

If you're going to do something, then do it right.

Link to comment

2 answers to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Announcements

  • -15% Discount in Metin2 Dev Store (01/10/2021 => 31/12/2021) => Code => 15_PCT_OCT_TO_DEC_2021


  • Read our Rules
  • Activity

    1. 0

      Visual Studio 2010 Ultimate

    2. 1

      Reduce server memory usage

    3. 31

      Metin2 Project - How to create à Metin2 private server on virtual machine

    4. 1

      Use BeltInventory slots without Belt

    5. 47

      Paid service - Vegas Projects

    6. 44

      Changelogs

    7. 79

      3D Shop - Mark Service

  • Recently Browsing

    • No registered users viewing this page.

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.