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

Script for online time.

1268995

Member
Joined
Sep 9, 2010
Messages
422
Reaction score
13
Hello Guys.

I need (please xD) a script that every 1 hour player are online he wins a premium point on gesior (that points used to buy itens on site)

So if player stays 24h online on the server, he will win 24 points -> each hour online = 1 premium point.

Ideas?
 
If someone login on mc 5 characters it will be:
1h = 5
24h (1day) = 120
168h (7 days) = 840
instead of:
1h = 1
24h = 24
168h = 168
Its huge difference if you look on it like this, thats the only thing i could imagine about abusing (mc).
 
If someone login on mc 5 characters it will be:
1h = 5
24h (1day) = 120
168h (7 days) = 840
instead of:
1h = 1
24h = 24
168h = 168
Its huge difference if you look on it like this, thats the only thing i could imagine about abusing (mc).

Ye, but since i will add items with 500 points price, player must make a lot of mcs + 21 days 24h afk (500 points) to buy a full set.
Each player + 5 mcs = new players coming to ot, since they will see too much players online XD what u think?
 
Yeah its ok if you made high prices :p
I upgraded script for you.

creaturescripts/creaturescripts.xml
Code:
<event type="think" name="addpointTimer" event="script" value="addpointTimer.lua"/>
creaturescripts/scripts/addpointTimer.lua
Code:
function onThink(cid, interval)

    local time = 1*60*60 -- 1s*60s = 60s * 60s = 60min
    local count = 1 -- points to add

    if getPlayerStorageValue(cid, 455577) < os.time() then
        db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. count .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You gained 1 premium point for 1 hour online status.")
        setPlayerStorageValue(cid, 455577, os.time() + time)
    end
    local remaining = math.ceil(getPlayerStorageValue(cid, 455577) - os.time())
    if getPlayerStorageValue(cid, 455578) ~= 0 then
        doPlayerSendCancel(cid, "!c to hide counter. Time to get point: "..remaining.."s.")
    else
        return remaining
    end
    return true
end
talkactions/talkactions.xml
Code:
<talkaction words="!c" event="script" value="hideCounter.lua"/>
talkactions/scripts/hideCounter.lua
Code:
function onSay(cid, words, param)
if(not checkExhausted(cid, 554, 5)) then
    return true
end

    if getPlayerStorageValue(cid, 455578) ~= 0 then
        setPlayerStorageValue(cid, 455578, 0)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Timer hidden!")
    else
        setPlayerStorageValue(cid, 455578, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Timer shown!")
    end
    return true
end
talkactions/lib/talkactions.lua
Code:
function checkExhausted(cid, storage, seconds)
    local v = exhaustion.get(cid, storage)
    if(not v) then
        exhaustion.set(cid, storage, seconds)
    else
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Please wait " .. v .. " seonds before using this command again.")
        return false
    end

    return true
end
creaturescripts/login.lua
Code:
local time = 1*60*60 -- 1s*60s = 60s * 60s = 60min
    registerCreatureEvent(cid, "addpointTimer")
    setPlayerStorageValue(cid, 455577, os.time() + time)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Every 1 hour online you will get 1 premium point.")
 
Last edited:
1 yes
2 yes
3 i dont see bugs


Thank you! xD

Oh boys..

Look:
Code:
function onThink(cid, interval)
woot not only interval and lastExecution =D

Yeah I checked with 1.2 not 0.x, my mistake.
Code:
uint32_t CreatureEvent::executeThink(Creature* creature, uint32_t interval)
{
    //onThink(cid, interval)
    if(m_interface->reserveEnv())
    {
        ScriptEnviroment* env = m_interface->getEnv();
        if(m_scripted == EVENT_SCRIPT_BUFFER)
        {
            env->setRealPos(creature->getPosition());
            std::stringstream scriptstream;

            scriptstream << "local cid = " << env->addThing(creature) << std::endl;
            scriptstream << "local interval = " << interval << std::endl;

            if(m_scriptData)
                scriptstream << *m_scriptData;

            bool result = true;
            if(m_interface->loadBuffer(scriptstream.str()))
            {
                lua_State* L = m_interface->getState();
                result = m_interface->getGlobalBool(L, "_result", true);
            }

            m_interface->releaseEnv();
            return result;
        }
        else
        {
            #ifdef __DEBUG_LUASCRIPTS__
            char desc[35];
            sprintf(desc, "%s", creature->getName().c_str());
            env->setEvent(desc);
            #endif

            env->setScriptId(m_scriptId, m_interface);
            env->setRealPos(creature->getPosition());

            lua_State* L = m_interface->getState();
            m_interface->pushFunction(m_scriptId);

            lua_pushnumber(L, env->addThing(creature));
            lua_pushnumber(L, interval);

            bool result = m_interface->callFunction(2);
            m_interface->releaseEnv();
            return result;
        }
    }
    else
    {
        std::clog << "[Error - CreatureEvent::executeThink] Call stack overflow." << std::endl;
        return 0;
    }
}
 
Yeah I checked with 1.2 not 0.x, my mistake.
Really? Then i use magic.
Code:
function onThink(player, interval)
local cid = player
    local time = 1*60*60 -- 1s*60s = 60s * 60s = 60min
    local count = 1 -- points to add

    if getPlayerStorageValue(cid, 455577) < os.time() then
        db.query("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. count .. " WHERE `id` = " .. player:getAccountId() .. ";")
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You gained 1 premium point for 1 hour online status.")
        setPlayerStorageValue(cid, 455577, os.time() + time)
    end
    local remaining = math.ceil(getPlayerStorageValue(cid, 455577) - os.time())
    if getPlayerStorageValue(cid, 455578) ~= 0 then
        doPlayerSendCancel(cid, "!c to hide counter. Time to get point: "..remaining.."s.")
    else
        return remaining
    end
    return false
end
magicpng_wqreapx.png
 
Last edited:
Yeah its ok if you made high prices :p
I upgraded script for you.

creaturescripts/creaturescripts.xml
Code:
<event type="think" name="addpointTimer" event="script" value="addpointTimer.lua"/>
creaturescripts/scripts/addpointTimer.lua
Code:
function onThink(cid, interval)

    local time = 1*60*60 -- 1s*60s = 60s * 60s = 60min
    local count = 1 -- points to add

    if getPlayerStorageValue(cid, 455577) < os.time() then
        db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. count .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You gained 1 premium point for 1 hour online status.")
        setPlayerStorageValue(cid, 455577, os.time() + time)
    end
    local remaining = math.ceil(getPlayerStorageValue(cid, 455577) - os.time())
    if getPlayerStorageValue(cid, 455578) ~= 0 then
        doPlayerSendCancel(cid, "!c to hide counter. Time to get point: "..remaining.."s.")
    else
        return remaining
    end
    return true
end
talkactions/talkactions.xml
Code:
<talkaction words="!c" event="script" value="hideCounter.lua"/>
talkactions/scripts/hideCounter.lua
Code:
function onSay(cid, words, param)
if(not checkExhausted(cid, 554, 5)) then
    return true
end

    if getPlayerStorageValue(cid, 455578) ~= 0 then
        setPlayerStorageValue(cid, 455578, 0)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Timer hidden!")
    else
        setPlayerStorageValue(cid, 455578, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Timer shown!")
    end
    return true
end
talkactions/lib/talkactions.lua
Code:
function checkExhausted(cid, storage, seconds)
    local v = exhaustion.get(cid, storage)
    if(not v) then
        exhaustion.set(cid, storage, seconds)
    else
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Please wait " .. v .. " seonds before using this command again.")
        return false
    end

    return true
end
creaturescripts/login.lua
Code:
local time = 1*60*60 -- 1s*60s = 60s * 60s = 60min
    registerCreatureEvent(cid, "addpointTimer")
    setPlayerStorageValue(cid, 455577, os.time() + time)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Every 1 hour online you will get 1 premium point.")

What this talkaction do?
 
Really? Then i use magic.
Code:
function onThink(player, interval)
local cid = player
    local time = 1*60*60 -- 1s*60s = 60s * 60s = 60min
    local count = 1 -- points to add

    if getPlayerStorageValue(cid, 455577) < os.time() then
        db.query("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. count .. " WHERE `id` = " .. player:getAccountId() .. ";")
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You gained 1 premium point for 1 hour online status.")
        setPlayerStorageValue(cid, 455577, os.time() + time)
    end
    local remaining = math.ceil(getPlayerStorageValue(cid, 455577) - os.time())
    if getPlayerStorageValue(cid, 455578) ~= 0 then
        doPlayerSendCancel(cid, "!c to hide counter. Time to get point: "..remaining.."s.")
    else
        return remaining
    end
    return false
end
magicpng_wqreapx.png

Ex.
https://github.com/orts/server/blob/master/data/globalevents/scripts/others/checkMount.lua#L3
https://github.com/orts/server/blob...s/wrath of the emperor quest/spyHoles.lua#L11
https://github.com/orts/server/blob/master/data/globalevents/scripts/demon oak quest/voices.lua#L16

And why do you even go through the compat files when you have the userdata value?
 
And why do you even go through the compat files when you have the userdata value?
What do you mean? Do you have to speak with language that only you understand?
If you want show something do it by example and explain how it works, its the only way someone can understand this.

example look like this:
I see your post
And why do you even go bla blabla bla when you have the blabla bla?

I know what is compat and userdata value, but i dont know how did i used compat and how to use userdata value and why? wtf

If you mean that i used cid instead of player:function, i did it to test only, didnt wanted to change everything just to show you that it works.
 
Last edited:
What do you mean? Do you have to speak with language that only you understand?
If you want show something do it by example and explain how it works, its the only way someone can understand this.

example look like this:
I see your post


I know what is compat and userdata value, but i dont know how did i used compat and how to use userdata value and why? wtf

If you mean that i used cid instead of player:function, i did it to test only, didnt wanted to change everything just to show you that it works.

Functions* You should have understood that since that is the only things the compat file has in it.
Since you don't seem to know what compat means ill explain it.
We have the new Lua interface and the legacy interface, getPlayerName(cid) - Player:getName()

Wut?

It's like saying you are trying to get to point B, but insted of going directly to point B you go first to point A to redirect you to point B.
Exaclly as a compat function works, it takes the old function, sends you to the new function.
The function ex. getPlayerName does no longer exist, except in compat.lua.

Change everything? It's quicker and better to use.
No reason to continue this here, if you wanna keep talking - send me a pm.
 
Back
Top