• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Onuse Im Haveing problems with elseif

Angel Of Death

Rise Of Tibia ServerOwner
Joined
Mar 12, 2012
Messages
91
Reaction score
0
LUA:
function onUse(cid, item, frompos, item2, topos)
local id = 3490
local time = 20
local pos1 = {x = 1568, y = 1550, z = 10}
local pos2 = {x = 1568, y = 1550, z = 10}

if item.itemid == 8551 then
    if getPlayerStorageValue(cid, 11200)==0 then
    doCleanTile(pos1,false)
	doPlayerSendTextMessage(cid,22,"The Rat Just Broke Through The Wall!!!!")
	doSummonCreature("hurt rat", pos1)
	setPlayerStorageValue(cid, 11200, 1)
	addEvent(doCreateItem,time * 1000, id,1,pos1)
 elseif
	getPlayerStorageValue(cid, 11200)== 1then
	doCleanTile(pos1,false)
	addEvent(doCreateItem,time * 1000, id,1,pos1)
    end
    return true
end
end


so what is suposto happen is you click the door the wall gets removed and a rat spawns few seconds later the wall reappears people are farming the rat by constantly clicking the door do i wanna make it set a storage after you click the door the first time and if you click it again it opens the wall but does not spawn rat
 
Try this:

LUA:
function onUse(cid, item, frompos, item2, topos)
local xx = 3490
local xxx = 20
local pos1 = {x = 1568, y = 1550, z = 10}
local clean = doCleanTile(pos1,false)
 
if( item.itemid == 8551 ) then
       doCleanTile(pos1,false)
	  doPlayerSendTextMessage(cid,22,"The Rat Just Broke Through The Wall!!!!")
	       doSummonCreature("hurt rat", pos1)
                    addEvent(clean,xxx * 999)
	                addEvent(doCreateItem,xxx * 1000, xx,1,pos1)
                         end
              return 1
        end
end

Assuming you are using TFS 3.6 , it should work fine.

EDIT: Also , excuse me if it doesnt work on the first try, its been a long time since i've worked on scripting..
 
Last edited:
LUA:
function onUse(cid, item, frompos, item2, topos)
local id = 3490
local time = 20
local pos1 = {x = 1568, y = 1550, z = 10}
local pos2 = {x = 1568, y = 1550, z = 10}

if item.itemid == 8551 then 
    doCleanTile(pos1,false)
	doPlayerSendTextMessage(cid,22,"The Rat Just Broke Through The Wall!!!!")
	doSummonCreature("hurt rat", pos1)
	addEvent(doCreateItem,time * 1000, id,1,pos1)
    end
    return true
end

it works like this but people are farming it

- - - Updated - - -

this didnt seem to work

Try this:

LUA:
function onUse(cid, item, frompos, item2, topos)
local xx = 3490
local xxx = 20
local pos1 = {x = 1568, y = 1550, z = 10}
local pos2 = {x = 1568, y = 1550, z = 10}
 
if( item.itemid == 8551 ) then
    if( getPlayerStorageValue(cid, 11200) == 0 ) then
       doCleanTile(pos1,false)
	  doPlayerSendTextMessage(cid,22,"The Rat Just Broke Through The Wall!!!!")
	       doSummonCreature("hurt rat", pos1)
	          setPlayerStorageValue(cid, 11200, 1)
	             addEvent(doCreateItem,xxx * 1000, xx,1,pos1)
 elseif( getPlayerStorageValue(cid, 11200) == 1 ) then
	doCleanTile(pos1,false)
	     addEvent(doCreateItem,xxx * 1000, xx,1,pos1)
                         end
              return 1
        end
end

Assuming you are using TFS 3.6 , it should work fine.

EDIT: Also , excuse me if it doesnt work on the first try, its been a long time since i've worked on scripting..

EDIT 2: I have noticed a small problem , this action script should work by actionid or uniqueid in the XML file , which means the new door doesnt get created with your action id... the only thing i can think of is SetItemAttribute , i dont remember how that function works however... Ill try to remember it
 
there nothing wrong with postions i am trying to make it so if you used it once it will not spawn a rat but will still remove the walll

Aha... I needed this piece of information ... Give me a second i will edit this in a moment

LUA:
function onUse(cid, item, frompos, item2, topos)
local xx = 3490
local xxx = 20
local pos1 = {x = 1568, y = 1550, z = 10}
 
if item.itemid == 8551  then
   if getPlayerStorageValue(cid, 11200) == 0  then
      doCleanTile(pos1,false)
	 doPlayerSendTextMessage(cid,22,"The Rat Just Broke Through The Wall!!!!")
	      doSummonCreature("hurt rat", pos1)
                 setPlayerStorageValue(cid, 11200, 1)
	              addEvent(doCreateItem,xxx * 1000, xx,1,pos1)
       elseif getPlayerStorageValue(cid, 11200) == 1  then
                  doCleanTile(pos1,false)
                      addEvent(doCreateItem,xxx * 1000, xx,1,pos1)
                         end
              return 1
        end
end

Does this work like it was intended?
 
Last edited:
thats my im putting the sorage values in there im trying to make it allow you to spawn the one rat on your first click but if you deicde oh i wanna sit here and keep spawning rats buy clicking the door it will check the storage value and only remove the wall every click after the first one

- - - Updated - - -

its not working i dont think checking
if getPlayerStorageValue(cid, 11200) == 0

Aha... I needed this piece of information ... Give me a second i will edit this in a moment

LUA:
function onUse(cid, item, frompos, item2, topos)
local xx = 3490
local xxx = 20
local pos1 = {x = 1568, y = 1550, z = 10}
 
if item.itemid == 8551  then
   if getPlayerStorageValue(cid, 11200) == 0  then
      doCleanTile(pos1,false)
	 doPlayerSendTextMessage(cid,22,"The Rat Just Broke Through The Wall!!!!")
	      doSummonCreature("hurt rat", pos1)
                 setPlayerStorageValue(cid, 11200, 1)
	              addEvent(doCreateItem,xxx * 1000, xx,1,pos1)
       elseif getPlayerStorageValue(cid, 11200) == 1  then
                  doCleanTile(pos1,false)
                      addEvent(doCreateItem,xxx * 1000, xx,1,pos1)
                         end
              return 1
        end
end

Does this work like it was intended?

- - - Updated - - -

i ahev fixed it the script works thanks for your help
 
LUA:
function onUse(cid,item,fromPosition,itemEx,toPosition)
local id,time = 3490,20
local wall,ratp = {x = 1568, y = 1550, z = 10, stackpos = 1},{x = 1569, y = 1550, z = 10}
doRemoveItem(getThingFromPos(wall).uid)
doCleanTile(ratp,false)
if getPlayerStorageValue(cid, 11207) <= 0 then
doPlayerSendTextMessage(cid,22,"The Rat Just Broke Through The Wall!!!!")
doSummonCreature("hurt rat", ratp)
setPlayerStorageValue(cid, 1127, 1)
end
addEvent(doCreateItem,time*1000, id, 1, wall)
return true
end
 
Back
Top