• 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 Need help with script error.

sdog1234

New Member
Joined
Dec 18, 2010
Messages
17
Reaction score
4
This is a deletion rune script for an 8.0 server I'm working on. (Armonia)

I'm not a good scripter at all so....





function onUse(cid, item, frompos, item2, topos)

local destroy = {x=topos.x, y=topos.y, z=topos.z, stackpos=255}
local destroyitem = getThingfromPos(destroy)

if getPlayerAccess(cid) > 4 then
if destroyitem.itemid > 1025 or (destroyitem.itemid > 3139 and destroyitem.itemid < 3324) or (destroyitem.itemid > 5814 and destroyitem.itemid < 5851) or (destroyitem.itemid > 6695 and destroyitem.itemid < 6718) then
doRemoveItem(destroyitem.uid,100)
return 1
else
end
doPlayerSendTextMessage(cid,22,"You may not delete ground.")
return 0
end
else
end
doPlayerSendTextMessage(cid,22,"Only characters with the access of GMs or above may use this rune.")
return 0
end






It gets this error:

data/actions/scripts/deletion.lua:15: 'end' expected (to close 'function' at line 1) near 'else'




Please just fix the script don't tell me what to do because I'll just screw it up.

Thanks!
 
You are kinda new to lua programming aint u?^_^

Well i fixed it for u:ninja:
Lua:
local grounds = {id,id,id,and so on}--Ground Ids.. guess there are simpler ways but im not really awake right now xD

function onUse(cid, item, frompos, item2, topos)
local destroy = {x=topos.x, y=topos.y, z=topos.z, stackpos=255}
local destroyitem = getThingfromPos(destroy)

	if getPlayerAccess(cid) > 4 then
		if not(isInArray(grounds,destroyitem.itemid) then
			doRemoveItem(destroyitem.uid,100)
		return true
		else
			doPlayerSendTextMessage(cid,22,"You may not delete ground.")
		return false
		end
	else
		doPlayerSendTextMessage(cid,22,"Only characters with the access of GMs or above may use this rune.")
		return false
	end
	
	return true
end
 
Last edited:
Umm... could you fix it so it actually deletes everything except Ground? It doesn't delete anything.. it just says You may not delete ground. I'm using Armonia ot server for 8.0 tibia.
 
Lua:
function onUse(cid, item, frompos, item2, topos)
	if getPlayerAccess(cid) > 4 then
	doCleanTile(topos)
	else
		doPlayerSendTextMessage(cid,22,"Only characters with the access of GMs or above may use this rune.")
	end 
	return true
end

if you only want it to work like "/r all" this will work..
 
Lua:
function onUse(cid, item, frompos, item2, topos)
	if getPlayerAccess(cid) > 4 then
	doCleanTile(topos)
	else
		doPlayerSendTextMessage(cid,22,"Only characters with the access of GMs or above may use this rune.")
	end 
	return true
end

if you only want it to work like "/r all" this will work..

doCleanTile
This function is not inside TFS 8.0



Try this one:

Lua:
local notallowed = {id,id,id,and so on}-- Items not allowed to destroy
 
function onUse(cid, item, frompos, item2, topos)
local destroyitem
 
	if getPlayerAccess(cid) > 4 then

		for i = 1, 255 do

			
			destroyitem = getThingfromPos({x=topos.x, y=topos.y, z=topos.z, stackpos=i})
			if destroyitem.itemid > 0 then
				if not(isInArray(notallowed,destroyitem.itemid) then
				doRemoveItem(destroyitem.uid,100)	
			end
		end

		else
		doPlayerSendTextMessage(cid,22,"Only characters with the access of GMs or above may use this rune.")
		return false
	end
 
	return true
end
 
I'm not sure if it worked because shortly after you guys posted, I stopped playing tibia... heh.. but it's set for a favorite just incase someday I come back :)
 
Back
Top