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

Lua Metin Stone Event --reward premium points for ZNOTE ACC

tuduras

Well-Known Member
Joined
Jun 4, 2017
Messages
340
Solutions
2
Reaction score
58
Hello Otlanders.. Can someone repair me script of metin stone.
As a reward is 5 premium points but for Gesior not for Znote . I'm already using Znote ACC and there is another code line for "points" not "premium_points". Here post metin scirpt :

LUA:
local config = {
    points = 5, -- how many points winner get?
    }

    local names = {'earth stone', 'icy stone', 'fire stone', 'wind stone'}

function onDeath(cid, corpse, deathList)
    if (isInArray(names, getCreatureName(cid):lower())) then
        --local mostdmg = deathList[2] ~= nil and deathList[2] or deathList[1]
        local mostdmg = isPlayer(deathList[1]) and deathList[1] or (deathList[2] ~= nil and deathList[2])
        if isPlayer(mostdmg) then
      
            db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` +" .. config.points .. " WHERE `name` = '".. getAccountByName(getCreatureName(mostdmg)) .."';")
            doPlayerSendTextMessage(mostdmg, 22, "You have killed " .. getCreatureName(cid) .. ". You won 5 points to sms shop.")
            db.executeQuery("INSERT INTO metin_wins (name, reward, reward_id, stone, date) VALUES ('" .. getCreatureName(mostdmg) .. "', '5 points', '2', '" .. getCreatureName(cid) .. "', " .. os.time() .. ")")
      
        else
            doBroadcastMessage("No one has destroyed the stone")
        end
    end
    return TRUE
end

LUA:
db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` + " .. addPoints .. " WHERE `account_id` = " .. getPlayerAccountId(cid))
Post automatically merged:

I change line account to znote_account and premium_points to points.
and get The error : name column.webp
 
Last edited:
If you look at your error, the query says "WHERE name = 'amber'". There is no column called "name" in your znote_accounts table.
You need to replace it with the code you have already provided: "WHERE account_id = " ..getPlayerAccountId(cid)
 
and can you do this for me ?I see
not so much

EDIT:
I have this : account to znote_account . premium points for points

LUA:
local config = {
    points = 5, -- how many points winner get?
    }

    local names = {'earth stone', 'icy stone', 'fire stone', 'wind stone'}

function onDeath(cid, corpse, deathList)
    if (isInArray(names, getCreatureName(cid):lower())) then
        --local mostdmg = deathList[2] ~= nil and deathList[2] or deathList[1]
        local mostdmg = isPlayer(deathList[1]) and deathList[1] or (deathList[2] ~= nil and deathList[2])
        if isPlayer(mostdmg) then
      
            db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` +" .. config.points .. " WHERE `name` = '".. getAccountByName(getCreatureName(mostdmg)) .."';")
            doPlayerSendTextMessage(mostdmg, 22, "You have killed " .. getCreatureName(cid) .. ". You won 5 points to sms shop.")
            db.executeQuery("INSERT INTO metin_wins (name, reward, reward_id, stone, date) VALUES ('" .. getCreatureName(mostdmg) .. "', '5 points', '2', '" .. getCreatureName(cid) .. "', " .. os.time() .. ")")
      
        else
            doBroadcastMessage("No one has destroyed the stone")
        end
    end
    return TRUE
end
 
LUA:
local config = {
    points = 5, -- how many points winner get?
}

local names = {'earth stone', 'icy stone', 'fire stone', 'wind stone'}

function onDeath(cid, corpse, deathList)
    if (isInArray(names, getCreatureName(cid):lower())) then
        --local mostdmg = deathList[2] ~= nil and deathList[2] or deathList[1]
        local mostdmg = isPlayer(deathList[1]) and deathList[1] or (deathList[2] ~= nil and deathList[2])
        if isPlayer(mostdmg) then
    
            db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` + " .. config.points .. " WHERE `account_id` = " .. getPlayerAccountId(cid))
            doPlayerSendTextMessage(mostdmg, 22, "You have killed " .. getCreatureName(cid) .. ". You won 5 points to sms shop.")
            db.executeQuery("INSERT INTO metin_wins (name, reward, reward_id, stone, date) VALUES ('" .. getCreatureName(mostdmg) .. "', '5 points', '2', '" .. getCreatureName(cid) .. "', " .. os.time() .. ")")
    
        else
            doBroadcastMessage("No one has destroyed the stone")
        end
    end
    return TRUE
end
 
metinscreen.webp
after your edited script post.

You know what, look at line
LUA:
db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` +" .. config.points .. " WHERE `name` = '".. getAccountByName(getCreatureName(mostdmg)) .."';")

there is somethink like (mostdmg) in this line. Maybe this must be in line.
 
yup my bad, change it to
LUA:
db.executeQuery("UPDATE `znote_accounts` SET `points` = `points` + " .. config.points .. " WHERE `account_id` = " .. getAccountByName(getCreatureName(mostdmg)))
 
I am not familiar with the old OTX engine, you just need to find the correct function to get the account id of the player and match that against the account_id column in the znote_accounts table.
 
Who wants to take this script . I give script with reward item and not points as a reward

LUA:
local names = {'earth stone', 'icy stone', 'fire stone', 'wind stone'}
local rewards = {{2160, 50}, {5080, 1}, {9969, 1}, {5785, 1}, {2349, 1}}


function onDeath(cid, corpse, deathList)
    if (isInArray(names, getCreatureName(cid):lower())) then
        --local mostdmg = deathList[2] ~= nil and deathList[2] or deathList[1]
        local mostdmg = isPlayer(deathList[1]) and deathList[1] or (deathList[2] ~= nil and deathList[2])
        if isPlayer(mostdmg) then
            local rand = math.random(1, #rewards)
        
            doPlayerAddItem(mostdmg, rewards[rand][1], rewards[rand][2])
            doPlayerSendTextMessage(mostdmg, 22, "You have killed " .. getCreatureName(cid) .. ". You won " .. rewards[rand][2] .. " " .. getItemNameById(rewards[rand][1]) .. ".")
            db.executeQuery("INSERT INTO metin_wins (name, reward, reward_id, stone, date) VALUES ('" .. getCreatureName(mostdmg) .. "', '" .. getItemNameById(rewards[rand][1]) .. "', '" .. rewards[rand][1] .. "', '" .. getCreatureName(cid) .. "', " .. os.time() .. ")")
        
        else
            doBroadcastMessage("No one has destroyed the stone")
        end
    end
    return TRUE
end

best regards
 
Back
Top