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

Premium Points to the winner of EVENT.

ohman

Member
Joined
Oct 24, 2008
Messages
294
Reaction score
8
Location
Sweden
Hi! I want the players who wins the event to get premium points to there account. I use 0.3.7 rev 5969 and Gesior AAC.

This is a part of the event: (its called rush event)

Code:
            if blue >= t.v then
                doBroadcastMessage(t.y, MESSAGE_STATUS_WARNING)
                setGlobalStorageValue(t.h, 1)
                for _, pid in ipairs(getPlayersOnline()) do
                    if(getPlayerStorageValue(pid, t.f_1) == 1) then
        doPlayerAddItem(cid, 2160, 30)
                    end
                end
            elseif red >= t.v then
                doBroadcastMessage(t.o, MESSAGE_STATUS_WARNING)
                setGlobalStorageValue(t.h, 1)
                for _, pid in ipairs(getPlayersOnline()) do
                    if(getPlayerStorageValue(pid, t.f_2) == 1) then
                    doPlayerAddItem(cid, 2160, 30)
                    end
                end
            end
          
</mod>


Thanks for the help! :)
 
Code:
if blue >= t.v then
doBroadcastMessage(t.y, MESSAGE_STATUS_WARNING)
setGlobalStorageValue(t.h, 1)
for _, pid in ipairs(getPlayersOnline()) do
if(getPlayerStorageValue(pid, t.f_1) == 1) then
db.executeQuery('UPDATE accounts SET premium_points=premium_points+'10' WHERE id=' .. getPlayerAccountId(cid))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You received some premium points!')
end
end
elseif red >= t.v then
doBroadcastMessage(t.o, MESSAGE_STATUS_WARNING)
setGlobalStorageValue(t.h, 1)
for _, pid in ipairs(getPlayersOnline()) do
if(getPlayerStorageValue(pid, t.f_2) == 1) then
db.executeQuery('UPDATE accounts SET premium_points=premium_points+'5' WHERE id=' .. getPlayerAccountId(cid))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You received some premium points!')
end
end
end

Also make sure to remove
from lib/0100-compact.lua this line:
Code:
db.Query=db.executeQuery


:p
 
Code:
if blue >= t.v then
doBroadcastMessage(t.y, MESSAGE_STATUS_WARNING)
setGlobalStorageValue(t.h, 1)
for _, pid in ipairs(getPlayersOnline()) do
if(getPlayerStorageValue(pid, t.f_1) == 1) then
db.executeQuery('UPDATE accounts SET premium_points=premium_points+'10' WHERE id=' .. getPlayerAccountId(cid))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You received some premium points!')
end
end
elseif red >= t.v then
doBroadcastMessage(t.o, MESSAGE_STATUS_WARNING)
setGlobalStorageValue(t.h, 1)
for _, pid in ipairs(getPlayersOnline()) do
if(getPlayerStorageValue(pid, t.f_2) == 1) then
db.executeQuery('UPDATE accounts SET premium_points=premium_points+'5' WHERE id=' .. getPlayerAccountId(cid))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You received some premium points!')
end
end
end

Also make sure to remove
from lib/0100-compact.lua this line:
Code:
db.Query=db.executeQuery


:p

Thanks for the help, but it didnt work.

This line didnt existed in 0100-compact.lua
"db.Query=db.executeQuery"

Its something wrong with this line. I get a error in console. But there is no error if I just change this line to "doPlayerAddItem(cid, 2160, 30)"
db.executeQuery('UPDATE accounts SET premium_points=premium_points+'10' WHERE id=' .. getPlayerAccountId(cid))


The error in console:

Code:
[12:25:04.458] > Loading battle.xml...[Error - LuaInterface::loadBuffer] [string "LuaInterface::loadBuffer"]:69: ')' expected near '5'
[12:25:04.459] [Error - Event::checkScript] Cannot load script (    domodlib('re')
[12:25:04.459]    function onPrepareDeath(cid, deathList)
[12:25:04.459]        if(not isPlayer(cid)) then
[12:25:04.459]            return true
[12:25:04.459]        end
[12:25:04.459]        if getGlobalStorageValue(t.a) == 1 then
[12:25:04.460]            local strings = {""}
[12:25:04.460]            local j, position, corpse = 1, 1, 0
[12:25:04.460]            for _, pid in ipairs(deathList) do
[12:25:04.460]                if isCreature(pid) == true then
[12:25:04.460]                    strings[position] = j == 1 and "" or strings[position] .. ", "
[12:25:04.460]                    strings[position] = strings[position] .. getCreatureName(pid) .. ""
[12:25:04.460]                    j = j + 1
[12:25:04.460]                else
[12:25:04.461]                    strings[position] = j == 1 and "" or strings[position] .. ", "
[12:25:04.461]                    strings[position] = strings[position] .."a field item"
[12:25:04.461]                    j = j + 1
[12:25:04.461]                end
[12:25:04.461]            end
[12:25:04.461]            for i, str in ipairs(strings) do
[12:25:04.461]                if(str:sub(str:len()) ~= ",") then
[12:25:04.461]                    str = str .. "."
[12:25:04.462]                end
[12:25:04.462]                desc = "You recognize "
[12:25:04.462]                desc = desc .. "" .. getCreatureName(cid) .. ". He was killed by " .. str
[12:25:04.462]            end
[12:25:04.462]            if(getPlayerSex(cid) == 1) then
[12:25:04.462]                corpse = doCreateItem(3058, getCreaturePosition(cid))
[12:25:04.462]            else
[12:25:04.462]                corpse = doCreateItem(3065, getCreaturePosition(cid))
[12:25:04.462]            end
[12:25:04.463]            doItemSetAttribute(corpse, "description", desc)
[12:25:04.463]            if((getPlayerStorageValue(cid, t.g) % 2) == 1) then
[12:25:04.463]                setGlobalStorageValue(t.u, getGlobalStorageValue(t.u)+1)
[12:25:04.463]            else
[12:25:04.463]                setGlobalStorageValue(t.l, getGlobalStorageValue(t.l)+1)
[12:25:04.463]            end
[12:25:04.463]            local red = getGlobalStorageValue(t.l)
[12:25:04.463]            local blue = getGlobalStorageValue(t.u)
[12:25:04.464]            if blue < t.v or red < t.v then   
[12:25:04.464]                if(isPlayer(cid) == false) then
[12:25:04.464]                    return true
[12:25:04.464]                end       
[12:25:04.464]                if((getPlayerStorageValue(cid, t.g) % 2) == 1) then
[12:25:04.464]                    doTeleportThing(cid, t.d_1)
[12:25:04.464]                    doSendMagicEffect(getCreaturePosition(cid), 10)
[12:25:04.464]                    doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
[12:25:04.465]                    doCreatureAddMana(cid, getCreatureMaxMana(cid))
[12:25:04.465]                    doPlayerRemoveLethalConditions(cid)
[12:25:04.465]                    if getCreatureSkullType(cid) == SKULL_WHITE then
[12:25:04.465]                        doCreatureSetSkullType(cid, 0)
[12:25:04.465]                    end
[12:25:04.465]                else
[12:25:04.466]                    doTeleportThing(cid, t.d_2)
[12:25:04.466]                    doSendMagicEffect(getCreaturePosition(cid), 10)
[12:25:04.466]                    doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
[12:25:04.466]                    doCreatureAddMana(cid, getCreatureMaxMana(cid))
[12:25:04.466]                    doPlayerRemoveLethalConditions(cid)
[12:25:04.466]                    if getCreatureSkullType(cid) == SKULL_WHITE then
[12:25:04.467]                        doCreatureSetSkullType(cid, 0)
[12:25:04.467]                    end
[12:25:04.467]                end   
[12:25:04.467]            end
[12:25:04.467]            if blue >= t.v then
[12:25:04.467]            doBroadcastMessage(t.y, MESSAGE_STATUS_WARNING)
[12:25:04.467]            setGlobalStorageValue(t.h, 1)
[12:25:04.467]                    for _, pid in ipairs(getPlayersOnline()) do
[12:25:04.468]                    if(getPlayerStorageValue(pid, t.f_1) == 1) then
[12:25:04.468]                    db.executeQuery('UPDATE accounts SET premium_points=premium_points+'5' WHERE id=' .. getPlayerAccountId(cid))
[12:25:04.468]                end
[12:25:04.468]            end
[12:25:04.468]            elseif red >= t.v then
[12:25:04.468]            doBroadcastMessage(t.o, MESSAGE_STATUS_WARNING)
[12:25:04.468]            setGlobalStorageValue(t.h, 1)
[12:25:04.468]                    for _, pid in ipairs(getPlayersOnline()) do
[12:25:04.469]                    if(getPlayerStorageValue(pid, t.f_2) == 1) then
[12:25:04.469]                    db.executeQuery('UPDATE accounts SET premium_points=premium_points+'5' WHERE id=' .. getPlayerAccountId(cid))
[12:25:04.469]                    end
[12:25:04.469]                end
[12:25:04.469]            end
[12:25:04.469]            if getGlobalStorageValue(t.h) == 1 then
[12:25:04.469]                setGlobalStorageValue(t.a, 0)
[12:25:04.469]                setGlobalStorageValue(t.h, 0)
[12:25:04.469]                setGlobalStorageValue(t.wv, -1)
[12:25:04.469]                setPlayerStorageValue(cid, t.f, -1)
[12:25:04.469]                setPlayerStorageValue(cid, t.g, 0)
[12:25:04.469]                setPlayerStorageValue(cid, t.l, 0)
[12:25:04.469]                setPlayerStorageValue(cid, t.u, 0)
[12:25:04.469]                setPlayerStorageValue(cid, t.f_1, -1)
[12:25:04.469]                setPlayerStorageValue(cid, t.f_2, -1)
[12:25:04.469]                setPlayerStorageValue(cid, t.h, -1)
[12:25:04.469]                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
[12:25:04.469]                doSendMagicEffect(getCreaturePosition(cid), 10)
[12:25:04.469]                doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
[12:25:04.469]                doCreatureAddMana(cid, getCreatureMaxMana(cid))
[12:25:04.469]                doPlayerRemoveLethalConditions(cid)
[12:25:04.469]                for _, pid in ipairs(getPlayersOnline()) do
[12:25:04.469]                    if(getPlayerStorageValue(pid, t.f_1) == 1 or getPlayerStorageValue(pid, t.f_2) == 1) then
[12:25:04.469]                        setPlayerStorageValue(pid, t.f, -1)
[12:25:04.469]                        doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
[12:25:04.469]                        doSendMagicEffect(getCreaturePosition(pid), CONST_ME_TELEPORT)
[12:25:04.469]                        setPlayerStorageValue(pid, t.g, 0)
[12:25:04.469]                        setPlayerStorageValue(pid, t.l, 0)
[12:25:04.469]                        setPlayerStorageValue(pid, t.u, 0)
[12:25:04.469]                        setPlayerStorageValue(pid, t.f_1, -1)
[12:25:04.469]                        setPlayerStorageValue(pid, t.f_2, -1)
[12:25:04.469]                        setPlayerStorageValue(pid, t.h, -1)
[12:25:04.469]                        doCreatureAddHealth(pid, getCreatureMaxHealth(pid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
[12:25:04.469]                        doCreatureAddMana(pid, getCreatureMaxMana(pid))
[12:25:04.469]                        doPlayerRemoveLethalConditions(pid)
[12:25:04.469]                    end
[12:25:04.469]                end
[12:25:04.469]                return false
[12:25:04.469]            end
[12:25:04.469]            return false
[12:25:04.469]        end
[12:25:04.469]        return true
[12:25:04.469]    end
[12:25:04.470] )
[12:25:04.470] [string "LuaInterface::loadBuffer"]:69: ')' expected near '5'
[12:25:04.475]  done.
[12:25:04.475] > 3 mods were loaded.


Thanks! :)
 
Okay I'll give you my script (premium points on desired level advancement)
then try to figure something out copying from my script to yours since they use the same function (add points)
Code:
local t, storage = {
 -- level -- amount points (delete this line)..
 {200, 6},
 {300, 8},
 {400, 10} 
}, 259
 function onAdvance(cid, skill, oldLevel, newLevel)
 if skill ~= SKILL__LEVEL thenreturn true
 endfor i = 1, #t dolocal v = t[i]
 if newLevel >= v[1] and getCreatureStorage(cid, storage) < i then
 db.executeQuery('UPDATE accounts SET premium_points=premium_points+'.. v[2] ..' WHERE id=' .. getPlayerAccountId(cid))doCreatureSetStorage(cid, storage, i)doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Congratulations! You have advanced to level ' .. v[1] .. ' and you have earned '.. v[2] ..' Premium Points!')end
 endreturn true
end
 
I changed this:

db.executeQuery('UPDATE accounts SET premium_points=premium_points+'10' WHERE id=' .. getPlayerAccountId(cid))
To this: (deleted ' ')
db.executeQuery('UPDATE accounts SET premium_points=premium_points+10 WHERE id=' .. getPlayerAccountId(cid))

and the error disapeared. but didnt work.

EDIT: Wait!! its "working" but... the wrong team gets the points.
 
Here is the description on english:

Code:
<description>
Configuration tutorial:
q - message displayed when event starts
d_1 - red team start position
d_2 - blue team start position
x - message displayed when event is not ready
w - waiting room position
lvl - minimal level to join event
v - number of frags team needs to earn to win event
mn - minimal amount of players to start event
m - maximal amount of players to start event
o - message displayed when red team wins
y - message displayed when blue team wins
i_1 - reward id (now is crystal coin = 2160)
i_2 - amount of reward (now it is 10 crystal coins)
t - time to start event (now it is 5 minutes)
r - time that results of the battle will be shown to players (now it is 3 minutes)

Add this to 050-function.lua:
-------------------------------------------------------------------------------------------------
function doPlayerRemoveLethalConditions(cid)
local tmp = {1, 2, 4, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 32768, 65536}
for i = 1, #tmp do
if(hasCondition(cid, tmp)) then doRemoveCondition(cid, tmp) end
end
return true
end
-------------------------------------------------------------------------------------------------
Add this to login.lua:
-------------------------------------------------------------------------------------------------
registerCreatureEvent(cid, "RushCombat")
registerCreatureEvent(cid, "RushAttack")
registerCreatureEvent(cid, "RushDead")
registerCreatureEvent(cid, "RushOutfit")
-------------------------------------------------------------------------------------------------
According to tutorial above you may set configuration yourself here(and something about locking knowledge):
</description>
 
"16:42 Event was completed, RED TEAM has won Rush Event!"

Thats also wrong, the blue team was the winners.


EDIT: changed script and the "winning broadcast msg" is now correct. But still wrong with the reward.
 
Last edited:
There is 1 more problem with the script. When a team wins and all players get teleported back to temple the white skulls should disapear. But it dont :/
 
Guys, this might help you guys!!

When I changed
  1. db.executeQuery('UPDATE accounts SET premium_points=premium_points+7 WHERE id=' .. getPlayerAccountId(cid))

back to:
doPlayerAddItem(pid, t.i_1, t.i_2)

the reward gets to the winning team. But I dont want it to add a item to the winner. I want premium points as reward.
 
db.executeQuery('UPDATE accounts SET premium_points=premium_points+7 WHERE id=' .. getPlayerAccountId(pid))
 
Back
Top