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

Lua Creating event history from .lua

enzo boaroli

Dreamer
Joined
Jan 21, 2014
Messages
41
Reaction score
0
Location
Brazil
Hi guys, I'm trying to generate an history after every event, I started with zombie tevent:

lua code:

Code:
local config = {
    website = "yes"
    playerCount = 2001, -- Global storage for counting the players left/entered in the event
   
    goblet = 5805, -- id of the gold goblet you'll get when finishing the event.
    rewards = {2195, 2152, 2160}, -- You will get this +  a gold goblet with your name on.
    --        {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
    moneyReward = {2160, 10, 1},
   
    -- Should be same as in the globalevent!
    -- The zombies will spawn randomly inside this area
    fromPosition = {x = 20029, y = 20030, z = 7}, -- top left cornor of the playground
    toPosition = {x = 20100, y = 20096, z = 7}, -- bottom right cornor of the playground
    }

function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(cid) and isMonster(attacker) then
        if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
            if getGlobalStorageValue(config.playerCount) >= 2 then
                doBroadcastMessage(getPlayerName(cid) .. " have been eated by Zombies!", MESSAGE_STATUS_CONSOLE_RED)
                local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)-1)
            elseif getGlobalStorageValue(config.playerCount) == 1 then
                if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
                    doBroadcastMessage(getPlayerName(cid) .. " won the Zombie event! Congratulations!", MESSAGE_STATUS_WARNING)
                    local goblet = doPlayerAddItem(cid, config.goblet, 1)
                    doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
                    local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                    doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                    doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                    for _,items in ipairs(config.rewards) do
                        doPlayerAddItem(cid, items, 1)
                    end
                    if config.moneyReward[3] == 1 then
                        doPlayerAddItem(cid, config.moneyReward[1], config.moneyReward[2])
                    end
                      if(config.website == "yes") then
                            db.executeQuery("INSERT INTO `event` (`eventname`, `name`, `time`) VALUES ('Zombie Event', '".. getPlayerName(cid) .."', '".. date('Y-m-d H:i:s') .."');")
                        end


                end
                       
                for x = config.fromPosition.x, config.toPosition.x do
                    for y = config.fromPosition.y, config.toPosition.y do
                        for z = config.fromPosition.z, config.toPosition.z do
                            areapos = {x = x, y = y, z = z, stackpos = 253}
                            getMonsters = getThingfromPos(areapos)
                            if isMonster(getMonsters.uid) then
                                doRemoveCreature(getMonsters.uid)
                            end
                        end
                    end
                end
            end
            return false
        end
    end



return true
end


Important part:

Code:
if(config.website == "yes") then
db.executeQuery("INSERT INTO `event` (`eventname`, `name`, `time`) VALUES ('Zombie Event', '".. getPlayerName(cid) .."', '".. date('Y-m-d H:i:s') .."');")
end

The problem is that I can't make time to be insert properly into my sql tables... I'd like to insert my machine's current time. Isn't the synthax right?

".. date('Y-m-d H:i:s') .."

Thanks
 
You Should Save a Variable with os.time and use it This Variable Should Be Saved After Wining on Arena
Code:
local i = os.time()
os.date("%a %b %d %X %Y", i)
 
@enzo boaroli Did you get your web page working? I think it's a really cool idea but I have no idea how to make the page, I was wondering if you wouldn't mind sharing your page? :D

But if not that's fine too I know you must have worked hard on it. :)
 
Well I have been working on more important things on my sv, I thought event history was not such important atm, but I have an ideia, you just have to update some queries when the event ends (like I did in the first post) and put them in a table on PHP, must not be difficult, I'll try and post here later.
 
Awesome! :D I thought it would be cool if you could see like Zombie Highscores. one table would show how many times they have won and another table would show who made it the farthest in a single event. Like Player lasted against 36 Zombies.
 
Back
Top