• 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 Where to put exhaustion?

Alyhide

Banned User
Joined
Aug 21, 2010
Messages
1,945
Reaction score
55
Location
Switzerland
How would I put..

LUA:
 	if getPlayerStorageValue(cid, exhaustStorage) < os.time() then
        setPlayerStorageValue(cid, exhaustStorage, os.time() + (exhaustTime * 60))
    else 
     	 doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
	end

in..

LUA:
local exhaustStorage = 24022
local exhaustTime = 1 --Minutes
local scroll = 1949 --Item ID of Scroll or Writeable Object
local places = {
	['temple'] = {x=3000,y=2098,z=7},
	['teleports'] = {x=2815,y=2025,z=7},
	['addons'] = {x=1266,y=880,z=7},
	['addon bosses'] = {x=1127,y=907,z=6},
	['trainers'] = {x=2877,y=2005,z=7},
	['donation quest'] = {x=3160,y=1572,z=7},
	['shops'] = {x=2940,y=2075,z=7},
	['sailors quarter'] = {x=3010,y=2192,z=6},
}
 
function onTextEdit(cid, item, newText)
	if item.itemid ~= scroll or getPlayerItemById(cid, true, scroll).uid ~= item.uid then
		return true
	end
 
	if isPlayerPzLocked(cid) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_PLAYERISPZLOCKED)
		return true
	end
 
	if isInArray({'locations','location','place','places'},newText:lower()) then --Words to be said to get list of places.
		local i = ''
		for j, k in pairs(places) do
			i = i .. ' [' .. j .. ']'
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Current Teleportation Locations: ' .. i) --When player says location.
		return true
	end
 
	if not places[newText:lower()] then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Invalid location. Please write Locations in the paper to see a list of the current locations.') --If Invalid Location.
		return true
	end
	
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You have been teleported to your location. Please wait one minute before teleporting again.' .. i) --When teleported.
	doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
	doTeleportThing(cid, places[newText:lower()])
	doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
	return true
end
 
Last edited:
I tried to do it..

Code:
[05/08/2011 22:20:28] [Error - CreatureScript Interface] 
[05/08/2011 22:20:28] data/creaturescripts/scripts/teleportpaper.lua:onTextEdit
[05/08/2011 22:20:28] Description: 
[05/08/2011 22:20:28] data/creaturescripts/scripts/teleportpaper.lua:39: attempt to concatenate global 'i' (a nil value)
[05/08/2011 22:20:28] stack traceback:
[05/08/2011 22:20:28] 	data/creaturescripts/scripts/teleportpaper.lua:39: in function <data/creaturescripts/scripts/teleportpaper.lua:15>

LUA:
local exhaustStorage = 24022
local exhaustTime = 1 --Minutes
local scroll = 1949 --Item ID of Scroll or Writeable Object
local places = {
	['temple'] = {x=3000,y=2098,z=7},
	['teleports'] = {x=2815,y=2025,z=7},
	['addons'] = {x=1266,y=880,z=7},
	['addon bosses'] = {x=1127,y=907,z=6},
	['trainers'] = {x=2877,y=2005,z=7},
	['donation quest'] = {x=3160,y=1572,z=7},
	['shops'] = {x=2940,y=2075,z=7},
	['sailors quarter'] = {x=3010,y=2192,z=6},
}
 
function onTextEdit(cid, item, newText)
	if item.itemid ~= scroll or getPlayerItemById(cid, true, scroll).uid ~= item.uid then
    return true
end
	if isPlayerPzLocked(cid) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_PLAYERISPZLOCKED)
		return true
	end
 
	if isInArray({'locations','location','place','places'},newText:lower()) then --Words to be said to get list of places.
		local i = ''
		for j, k in pairs(places) do
			i = i .. ' [' .. j .. ']'
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Current Teleportation Locations: ' .. i) --When player says location.
		return true
	end
 
	if not places[newText:lower()] then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Invalid location. Please write Locations in the paper to see a list of the current locations.') --If Invalid Location.
		return true
	end

	if getPlayerStorageValue(cid, exhaustStorage) < os.time() then
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You have been teleported to your location. Please wait one minute before teleporting again.' .. i) --When teleported.
	doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
	doTeleportThing(cid, places[newText:lower()])
	doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
    setPlayerStorageValue(cid, exhaustStorage, os.time() + (exhaustTime * 60))
    else 
     	 doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
	end
	return true
end
 
With each destination having their own storage & time, it allows players to travel to other locations while waiting for the previous one to expire.

If you don't like that idea, just make the storage the same for all destinations. Enjoy! :thumbup:

LUA:
 local t = {
	["Temple"] = {
		{x = 857, y = 964, z = 7}, storage = 1337, time = 30
	},
}

local scroll = 1947
function onTextEdit(cid, item, newText)
	if item.itemid == scroll then
		if isInArray({'locations', 'places', 'place'}, newText) then
			local i = ''
			for text, x in pairs(t) do
				i = i .. " [" .. text .. "]"
			end
 
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Current Teleportation Locations: " .. i)
			return true
		end
 
		if isPlayerPzLocked(cid) then
			doCreatureSay(cid, "You are in a battle!", TALKTYPE_MONSTER)
			return true
		end
 
		local st = t[newText].storage
		if getCreatureStorage(cid, st) > os.time() then
			doCreatureSay(cid, "You must wait another " .. getCreatureStorage(cid, st) - os.time() .. ' second' .. ((getCreatureStorage(cid, st) - os.time()) == 1 and "" or "s") .. " to travel here again.", TALKTYPE_MONSTER)
			return true
		end
 
		local ti = t[newText].time
		local pos = t[newText][1]
		doTeleportThing(cid, pos, false)
		doSendMagicEffect(pos, CONST_ME_TELEPORT)
		doCreatureSetStorage(cid, st, os.time() + ti)
		doCreatureSay(cid, "You have been teleported!", TALKTYPE_MONSTER)
	end
 
	return true
end
 
Last edited:
Back
Top