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

Solved Step in and summon

eardrums

Member
Joined
May 27, 2010
Messages
101
Solutions
1
Reaction score
11
Hi!
So I made this very simple script of stepping on a tile and summoning monster.
Code:
function onStepIn(cid, item, pos)
            doSummonCreature("giant", {x= 955, y= 727, z= 1})
        return TRUE
    end
I need help making it so you cant summon the creature even if you step again except after 1 minute.
 
5. Incomplete Problem Description
- Post as much useful information as possible. If the problem is about something on your server, post the server version and client version. Also always post the errors you get and the scripts with the problems.
http://otland.net/threads/updated-rules-for-the-support-board.217087/

Every time you create a new thread, you need to add the server version you use.
 
I dont really have a problem with a script but I just dont know how to do the addevent thing or adding time to things :) thanks anyways

forgot to say :D 0.2.13 is my tfs version
 
Last edited by a moderator:
Code:
local config = {
    monsterName = 'Giant',
    monsterPosition = {x= 955, y= 727, z= 1},
    time = 30 --seconds
}

function doSummonMonster()
    local ret = doSummonCreature(config.monsterName, config.monsterPosition)
    if ret then
        doSendMagicEffect(getCreaturePosition(ret), CONST_ME_TELEPORT)
    end
    return true
end

function onStepIn(cid, item, pos)
    if not isPlayer(cid) then
        retrun false
    end

    addEvent(doSummonMonster, config.time * 1000)
    return true
end
 
Code:
local storage = 34537 -- above function onStepIn
Code:
if getPlayerStorageValue(cid, storage) >= os.time() then
    return true
end
-- summon monster here and other things the script should do
setPlayerStorageValue(cid, storage, os.time() + 60)

Btw, read rule 2 aswell.
 
Oh >.< i miss read the request. I thougt he wanted the monster get summoned after certain time :P
 
Hey Limos! I did the code exactly as you said but it gives me an error saying
in main chunk.

Code:
local storage = 34537
function onStepIn(cid, item, pos)
if getPlayerStorageValue(cid, storage) >= os.time() then
    return true
end
doSummonCreature("rotten meat giant", {x= 955, y= 727, z= 1})
setPlayerStorageValue(cid, storage, os.time() + 60)

Why cant the code just be like this?

Code:
local storage = 34537
function onStepIn(cid, item, pos)
if getPlayerStorageValue(cid, storage) >= os.time() then
doSummonCreature("rotten meat giant", {x= 955, y= 727, z= 1})
setPlayerStorageValue(cid, storage, os.time() + 60)
end
return true
end

I tried it the 2nd way but it doesnt do anything.
Thanks for the support channel rule guide ill try to follow them as best as I can :D
 
>= os.time() this check if the "cooldown" still exsist. You should do then < os.time() then you can use the second example.
 
If you get an error, post the full error.
If it's possible for npcs or monsters to step on that you should add an isPlayer if statement like Printer posted, else the script will give errors if npcs or monsters step on it.
 
Okay so Im currently using this script
Code:
local storage = 34537
function onStepIn(cid, item, pos)
if getPlayerStorageValue(cid, storage) >= os.time() then
doSummonCreature("rotten meat giant", {x= 955, y= 727, z= 1})
setPlayerStorageValue(cid, storage, os.time() + 60)
end
return true
end
It doesnt give me any errors and it doesnt do anything when i step on the sqm. Also doesnt give any errors when i step on the sqm.
What do I need to change in this script to make it work? If possible could u rewrite the script for me so I can take a look at a working example and try to understand it. Thanks again
 
if getPlayerStorageValue(cid, storage) < os.time() then

~~~~

If the storage value is more it means the time isn't over yet.
 
Back
Top