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

Little fix on script

Dankoo

Active Member
Joined
Sep 4, 2010
Messages
1,007
Reaction score
27
I've seen this script:

LUA:
-- Credits --
	-- References: Shawak & Colandus.
	-- Modifications: Guitar Freak.
 
	local level = 8 -- Minimum level to send a report.
	local minimum = 3 -- Minimum characters per report.
	local maximum = 85 -- Maximum characters per report.
 
	local useExhaust = true -- True if you want to use exhaustion, false if not.
	local storageValue = 8000 -- Needed for exhaustion to work. Set to any unused value you wish.
	local exhaustTime = 15 -- Exhaust time between each report (15 = 15 seconds).
 
	local getVoc = getPlayerVocationName(cid)
	local position = getCreaturePosition(cid)
 
function onSay(cid, words, param, channel)
 
	if getPlayerLevel(cid) < level then
			doPlayerSendTextMessage(cid,20,"Report Manager:")
			doPlayerSendTextMessage(cid,18,"You need to be at least level "..level.." to send a report.")
 
		elseif (useExhaust and isExhausted(cid, storageValue, exhaustTime) == TRUE) then
			doPlayerSendTextMessage(cid,20,"Report Manager:")
			doPlayerSendTextMessage(cid,18,"Sorry, you need to wait "..exhaustTime.." seconds before sending another report.")
 
		elseif param:len() < minimum then
			doPlayerSendTextMessage(cid,20,"Report Manager:")
			doPlayerSendTextMessage(cid,18,"Sorry, you need to enter atleast " .. minimum .. " characters to send in a report.")
 
		elseif param:len() > maximum then
			doPlayerSendTextMessage(cid,20,"Report Manager:")
			doPlayerSendTextMessage(cid,18,"Sorry, you can only write max. " .. maximum .. " characters per report.")
 
		else
			Log = io.open(getDataDir().."logs/Reports.txt", "a+")
			Log:write("Sent: "..os.date("%A %I:%M:%S %p.").."\n")
			Log:write("From position: X = "..position.x.." | Y = "..position.y.." | Z = "..position.z.."\n")
			Log:write(""..getPlayerName(cid).." ["..getPlayerLevel(cid).."] ("..getVoc.."): "..param.."\n\n")
			Log:close()
				doPlayerSendTextMessage(cid,20,"Report Manager:")
				doPlayerSendTextMessage(cid,27,"You have successfully sent your report. Thanks for your support.")
				setExhaust(cid, storageValue)
		end
		return TRUE
end

If I remove this line, the script runs smooth, but this is a crucial line:
LUA:
Log:write("From position: X = "..position.x.." | Y = "..position.y.." | Z = "..position.z.."\n")

attempt to index upvalue 'position' <a boolean value>

I've tried to fix, but couldn't... Ideas? :peace::peace:
 
LUA:
-- Credits --
-- References: Shawak & Colandus.
-- Modifications: Guitar Freak.

local level = 8 -- Minimum level to send a report.
local minimum = 3 -- Minimum characters per report.
local maximum = 85 -- Maximum characters per report.

local key = 8000 -- set to any unused player storage key
local time = 15 -- exhaust in seconds between each report

function onSay(cid, words, param, channel)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Report Manager:')
	if not param or param:len() < minimum then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'Sorry, you need to enter atleast ' .. minimum .. ' characters to send in a report.')
	elseif param:len() > maximum then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'Sorry, you can only write max. ' .. maximum .. ' characters per report.')
	elseif getPlayerLevel(cid) < level then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'You need to be at least level '..level..' to send a report.')
	elseif exhaustion.check(cid, key) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'Sorry, you need to wait '..time..' seconds before sending another report.')
	else
		exhaustion.set(cid, key, time)
		local f, p = io.open(getDataDir()..'logs/Reports.txt', 'a+'), getThingPos(cid)
		f:write('Sent: '..os.date('%A %I:%M:%S %p.')..'\nFrom position: X = '..p.x..' | Y = '..p.y..' | Z = '..p.z..'\n' .. getCreatureName(cid)..' ['..getPlayerLevel(cid)..'] ('..getPlayerVocationName(cid)..'): '..param..'\n\n')
		f:close()
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have successfully sent your report. Thanks for your support.')
	end
	return true
end
 
Back
Top