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

My script needs small rework

Darqneez

ShaC-Ohhhh
Joined
Dec 30, 2009
Messages
72
Reaction score
2
Location
Poland/Wroclaw
I have a small problem. My script works, but console gives me an error, and there is also a small freeze while using my plant. Can someone rework my script so that there was no error?
Here's Code:
Code:
-- Script made by Darqneez --
local blossom = {x=2073, y=1866, z=11}  -- TOP LEFT tile

function onUse (cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 60017) == -1 then
        for itemid = 4144, 4147 do
            for itemuid = 60017, 60020 do
               if getThing(itemuid).itemid == getThing(itemid).itemid then
               return TRUE
               else
               doPlayerSendTextMessage(cid,25,"It is not a good leaf.")
               end
            end
        end
     doPlayerSendTextMessage(cid,25,"You have cut a leaf from this mysterious plant.")

     doSummonCreature("Serpent Spawn", {x=blossom.x,y=blossom.y + 4,z=blossom.z})
     doSummonCreature("Serpent Spawn", {x=blossom.x,y=blossom.y - 2,z=blossom.z})
     doSummonCreature("Serpent Spawn", {x=blossom.x + 3,y=blossom.y,z=blossom.z})
     doSummonCreature("Serpent Spawn", {x=blossom.x - 2,y=blossom.y,z=blossom.z})
     doSummonCreature("Serpent Spawn", {x=blossom.x - 1,y=blossom.y - 13,z=blossom.z - 1})
     doSummonCreature("Serpent Spawn", {x=blossom.x + 1,y=blossom.y - 17,z=blossom.z -1})

     doPlayerAddItem(cid,7249,1)
     setPlayerStorageValue(cid, 60017, 1)
     else
     doPlayerSendTextMessage(cid,25,"You have nothing to do with this plant.")
     end
return TRUE
end
Here's error in console (When I use plant this error appears like 16 times :D):
Code:
[26/08/2010 10:17:45] [Error - Action Interface] 
[26/08/2010 10:17:46] data/actions/scripts/quests/heavenblossom/heavenblossom.lua:onUse
[26/08/2010 10:17:46] Description: 
[26/08/2010 10:17:46] (luaGetThing) Thing not found
 
PHP:
-- Script made by Darqneez --
local blossom = {x=2073, y=1866, z=11}  -- TOP LEFT tile

function onUse (cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 60017) == -1 then
        for itemid = 4144, 4147 do
            for itemuid = 60017, 60020 do
               if getThing(itemuid).itemid == getThing(itemid).itemid then
               return TRUE
               else
               doPlayerSendTextMessage(cid,25,"It is not a good leaf.")
               end
            end
        end
     doPlayerSendTextMessage(cid,25,"You have cut a leaf from this mysterious plant.")

     doSummonCreature("Serpent Spawn", {x=blossom.x,y=blossom.y + 4,z=blossom.z})
     doSummonCreature("Serpent Spawn", {x=blossom.x,y=blossom.y - 2,z=blossom.z})
     doSummonCreature("Serpent Spawn", {x=blossom.x + 3,y=blossom.y,z=blossom.z})
     doSummonCreature("Serpent Spawn", {x=blossom.x - 2,y=blossom.y,z=blossom.z})
     doSummonCreature("Serpent Spawn", {x=blossom.x - 1,y=blossom.y - 13,z=blossom.z - 1})
     doSummonCreature("Serpent Spawn", {x=blossom.x + 1,y=blossom.y - 17,z=blossom.z -1})

     doPlayerAddItem(cid,7249,1)
     setPlayerStorageValue(cid, 60017, 1)
     else
     doPlayerSendTextMessage(cid,25,"You have nothing to do with this plant.")
     end
return TRUE
end
I think the error its on this line:
PHP:
               if getThing(itemuid).itemid == getThing(itemid).itemid then
I think you need to put this:
PHP:
               if getThing(item.uid).itemid == getThing(itemid).itemid then
 
PHP:
-- Script made by Darqneez --
local blossom = {x=2073, y=1866, z=11}  -- TOP LEFT tile

function onUse (cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 60017) == -1 then
        for itemid = 4144, 4147 do
            for itemuid = 60017, 60020 do
               if getThing(itemuid).itemid == getThing(itemid).itemid then
               return TRUE
               else
               doPlayerSendTextMessage(cid,25,"It is not a good leaf.")
               end
            end
        end
     doPlayerSendTextMessage(cid,25,"You have cut a leaf from this mysterious plant.")

     doSummonCreature("Serpent Spawn", {x=blossom.x,y=blossom.y + 4,z=blossom.z})
     doSummonCreature("Serpent Spawn", {x=blossom.x,y=blossom.y - 2,z=blossom.z})
     doSummonCreature("Serpent Spawn", {x=blossom.x + 3,y=blossom.y,z=blossom.z})
     doSummonCreature("Serpent Spawn", {x=blossom.x - 2,y=blossom.y,z=blossom.z})
     doSummonCreature("Serpent Spawn", {x=blossom.x - 1,y=blossom.y - 13,z=blossom.z - 1})
     doSummonCreature("Serpent Spawn", {x=blossom.x + 1,y=blossom.y - 17,z=blossom.z -1})

     doPlayerAddItem(cid,7249,1)
     setPlayerStorageValue(cid, 60017, 1)
     else
     doPlayerSendTextMessage(cid,25,"You have nothing to do with this plant.")
     end
return TRUE
end
I think the error its on this line:
PHP:
               if getThing(itemuid).itemid == getThing(itemid).itemid then
I think you need to put this:
PHP:
               if getThing(item.uid).itemid == getThing(itemid).itemid then
Still the same error :\
 
Lua:
function onUse (cid, item, fromPosition, itemEx, toPosition)

	action = false
	if(getPlayerStorageValue(cid, 60017) == -1) then
		if(item.uid == 5000) then
			for i = 4144, 4147 do
				if(itemEx.itemid == i and itemEx.actionid == 5001) then
					action = true
				end
			end
		else
			doPlayerSendTextMessage(cid, 25, "You have nothing to do with this plant.")
			return true
		end
	else
		doPlayerSendTextMessage(cid, 25, "You have nothing to do with this plant.")
		return true
	end
	if(action == true) then
		for x = getPlayerPosition(cid).x - 1, getPlayerPosition(cid).x + 1 do
			for y = getPlayerPosition(cid).y - 1, getPlayerPosition(cid).y + 1 do
				position = {x = x, y = y, z = getPlayerPosition(cid).z}
				if(position ~= getPlayerPosition(cid)) then
					doSummonCreature("serpent spawn", position)
				end
			end
		end
		doPlayerAddItem(cid, 7249, 1)
		setPlayerStorageValue(cid, 60017, 1)
	else
		doPlayerSendTextMessage(cid, 25, "You have nothing to do with this plant.")
	end
	return true
end

I dont know if you mean this, but this script adds to you a storage and gives you an item if its itemEx.itemid == 4144, 4147, if it has actionid 5001 and if item.uid == 5000.

Not tested, but should work
 
Uhm, I didnt test your script, but I didnt mean it. In my quest there is a Plant that contains 4 tiles, their id are 4144, 4145, 4146 and 4147 (You can look at map editor), and I give an UID to every tile, and player can use every of these tiles and he gets the same result. So I thought that my script should work so: It checks if tiles with id from 4144 to 4147 have uid from 60017 to 60020, every of this tile has its own uid. If result is true player gets item etc. It should work like a chest script, but it doesnt have 1 tile and 1 uid but 4. If you still dont understand I'll make a ss of quest room :p
 
Uhm, I didnt test your script, but I didnt mean it. In my quest there is a Plant that contains 4 tiles, their id are 4144, 4145, 4146 and 4147 (You can look at map editor), and I give an UID to every tile, and player can use every of these tiles and he gets the same result. So I thought that my script should work so: It checks if tiles with id from 4144 to 4147 have uid from 60017 to 60020, every of this tile has its own uid. If result is true player gets item etc. It should work like a chest script, but it doesnt have 1 tile and 1 uid but 4. If you still dont understand I'll make a ss of quest room :p

Oh, now i understand. This should work:
Lua:
local plant = {
	[4144] = 60017,
	[4145] = 60018,
	[4146] = 60019,
	[4147] = 60020
}

function onUse (cid, item, fromPosition, itemEx, toPosition)
 
	if(getPlayerStorageValue(cid, 60017) == -1) then
		if(plant[item.itemid] and item.uid == plant[item.itemid]) then
			for x = getPlayerPosition(cid).x - 1, getPlayerPosition(cid).x + 1 do
				for y = getPlayerPosition(cid).y - 1, getPlayerPosition(cid).y + 1 do
					position = {x = x, y = y, z = getPlayerPosition(cid).z}
					if(position ~= getPlayerPosition(cid)) then
						doSummonCreature("serpent spawn", position)
					end
				end
			end
			doPlayerAddItem(cid, 7249, 1)
			setPlayerStorageValue(cid, 60017, 1)
			doPlayerSendTextMessage(cid, 25, "You have cut a leaf from this mysterious plant.")
		else
			doPlayerSendTextMessage(cid, 25, "You have nothing to do with this plant.")
		end
	else
		doPlayerSendTextMessage(cid, 25, "You have already cut a leaf from this mysterious plant.")
	end
	return true
end
 
Back
Top