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

TFS 0.3.6 Kickdoor function after 5mins

Dkadsfe

Member
Joined
Apr 1, 2016
Messages
280
Reaction score
22
Hey how would i be able to fix this? i believe it is the cause of this
<globalevent name="kickDoor" interval="60000" script="kickDoor.lua" />
and here is the kickdoor.lua
I tried using this script to make a player use a door and after 5mins it would teleport the player who used the door back to temple
Code:
function onThink(interval)
for i, v in ipairs(getPlayersOnline()) do
    if getPlayerStorageValue(v, storage) + minutes > os.time() then
        doTeleportThing(v, temple)
        doPlayerSendTextMessage(v, MESSAGE_STATUS_CONSOLE_BLUE, "Your time has run out.")
        setPlayerStorageValue(v, storage, 0)
    end
end
end
This is the error
Code:
[24/06/2016 21:41:09] [Error - GlobalEvent Interface]
[24/06/2016 21:41:09] data/globalevents/scripts/kickDoor.lua:onThink
[24/06/2016 21:41:09] Description:
[24/06/2016 21:41:09] data/globalevents/scripts/kickDoor.lua:3: attempt to perform arithmetic on global 'minutes' (a nil value)
[24/06/2016 21:41:10] stack traceback:
[24/06/2016 21:41:10]     data/globalevents/scripts/kickDoor.lua:3: in function <data/globalevents/scripts/kickDoor.lua:1>
[24/06/2016 21:41:10] [Error - GlobalEvents::think] Couldn't execute event: kickDoor

This is the lua idk if i made it work correctly but this action script corresponds with the globalevent script
<action actionid="4034" event="script" value="exptimer/exp.lua"/>
Code:
local storage = 4034
local minutes = 14
local cost = 100
local temple = {x = 2000, y = 2000, z = 7}
local enter_pos = {x = 1000, y = 1000, z = 7}

function onUse(cid, item, fromPosition, item2, toPosition)
    if getPlayerStorageValue(cid, storage) + minutes < os.time() and getPlayerStorageValue(cid, storage) > 0 then
        doTeleportThing(cid, enter_pos)
    return true
    end
  
    if doPlayerRemoveMoney(cid, cost) then
        setPlayerStorageValue(cid, storage, os.time())
        doTeleportThing(cid, enter_pos)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You now have access for "..minutes.." minutes.")
    else
        doPlayerSendCancelMessage(cid, "This door requires "..cost.." gold to enter.")
    end
return true
end
 
First u dont need to use globalevent and u can use addevent in action script
Code:
local function back (cid)
if isplayer(cid) then
doTeleportThing(cid, temple)
setPlayerStorageValue(cid, storage, 0)
end
return true
end

local storage = 4034
local cost = 100
local temple = {x = 2000, y = 2000, z = 7}
local enter_pos = {x = 1000, y = 1000, z = 7}
function onUse(cid, item, fromPosition, item2, toPosition)
if doPlayerRemoveMoney(cid, cost) then
doTeleportThing(cid, enter_pos)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You now have access for "..minutes.." minutes.")
setPlayerStorageValue(cid, storage, 1)
Addevent (cid, 300000 * 1000, back) ---- this time in million seconds
else
doPlayerSendCancelMessage(cid, "This door requires "..cost.." gold to enter.")
end
return true
end
Im use mobile so u can found error cods idk
 
Last edited:
First u dont need to use globalevent and u can use addevent in action script
Code:
local function back (cid)
if isplayer(cid) then
doTeleportThing(cid, temple)
setPlayerStorageValue(cid, storage, 0)
end
return true
end

local storage = 4034
local cost = 100
local temple = {x = 2000, y = 2000, z = 7}
local enter_pos = {x = 1000, y = 1000, z = 7}
function onUse(cid, item, fromPosition, item2, toPosition)
if doPlayerRemoveMoney(cid, cost) then
doTeleportThing(cid, enter_pos)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You now have access for "..minutes.." minutes.")
setPlayerStorageValue(cid, storage, 1)
Addevent (cid, 300000 * 1000, back) ---- this time in million seconds
else
doPlayerSendCancelMessage(cid, "This door requires "..cost.." gold to enter.")
end
return true
end
Im use mobile so u can found error cods idk
if your going to use addEvent to teleport a player back, you'll also need to create a login script, in case the player logs out for any reason, or if the server crashed.

Either method is acceptable, however as-is, yours is not.

As @Thexamx advised, you don't have the locals from the actionscript defined in the globalevent.
 
He can add if player login in area (quest area ) add player storage 1 else add player storage 0
really i cant make it now im use fucking mobile atm and im in work
 
and in login.lua
Code:
setPlayerStorageValue(cid, 4034, 0)
registerCreatureEvent(cid, "arealogin")

Create new lua
Code:
local from, to = {x = 100, y = 100, z = 7},
{x = 100, y = 100, z = 7}
function onLogin(cid)
for _, cid in ipairs(getPlayersOnline()) do
if not isInRange(getThingPosition(cid), from, to) then
doTeleportThing(cid, {x = 1000, y = 1000, z = 7})  --- add temple position
end
end
return true
end

and in creaturescript add

Code:
<event type="login" name="arealogin" event="script" value="namescript.lua"/>

this mean anyplayer will login here will get teleport to temple and set storage to 0
 
Last edited:
or when you enter the door, you set a storage to 1, when you leave you set it to 0
if you log in and have 1, if position is in room tp to temple and set to 0 else set to 0
no point registering events for it
 
Back
Top