• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Test: onStepIn (RemoveStone)

Ates.tr

Im back
Joined
Nov 11, 2007
Messages
1,046
Reaction score
2
Location
Sweden
Hhahah my third script!

:::NOT TESTED YET:::

Code:
-- Script by Ates, [onStepIn_RemoveStone]
-- Edited by Zoriath
-- Help by Gelio
function onStepIn(cid, item, position, fromPosition)

local pos = {X=1000, Y=1000, Z=7}  -- Pos
local stone = 1304  -- ID of stone
local tile = 426  -- ID of tile
local tile1 = 425 -- ID of tile (The one you stand on)
local stoneFromPos = getThingfromPos(pos)  -- It get item uid

   if item.itemid == tile and item.actionid == 5100 then -- Higher click on the tile and write ActionID 5100
      doRemoveItem(stoneFromPos.uid, 1)
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You removed the Stone.")
      doTransformItem(item.uid, tile1)
   elseif item.itemid == tile1 and item.actionid == 5100 then
      doCreateItem(stone, 1, pos)
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You added the Stone.")
      doTransformItem(item.uid, tile)
end
end


Thank's Gelio he helped me a lot!
 
Last edited:
Code:
-- Script by Ates, [onStepIn_RemoveStone]
function onStepIn(cid, item, position, fromPosition)

local pos = {X=1000, Y=1000, Z=7}  -- Pos
local stone = 1304  -- ID of stone
local tile = 426  -- ID of tile
local tile1 = 425 -- ID of tile (The one you stand on)
local stoneFromPos = getThingfromPos(pos)  -- It get item uid

   if item.itemid == tile and item.actionid == 5100 then
      doRemoveItem(stoneFromPos.uid, 1)
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You removed the Stone.")
      doTransformItem(item.uid, tile1)
   elseif item.itemid == tile1 and item.actionid == 5100 then
      doCreateItem(stone, 1, pos)
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You added the Stone.")
      doTransformItem(item.uid, tile)
   end
end
 
Last edited:
Code:
-- Script by Ates, [onStepIn_RemoveStone]
function onStepIn(cid, item, position, fromPosition)

local pos = {X=1000, Y=1000, Z=7}  -- Pos
local stone = 1304  -- ID of stone
local tile = 426  -- ID of tile
local tile1 = 425 -- ID of tile (The one you stand on)
local stoneFromPos = getThingfromPos(pos)  -- It get item uid

   if item.itemid == tile and item.actionid == 5100 then
      doRemoveItem(stoneFromPos, 1)
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You removed the Stone.")
      doTransformItem(item.uid, tile1)
   elseif item.itemid == tile1 and item.actionid == 5100 then
      doCreateItem(stone, 1, pos)
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You added the Stone.")
      doTransformItem(item.uid, tile)
end
end



Thanks you.... ;)
 
Ok. Few bugs. Bye don't end ifs and functions. Transform bye to end. Good script (red - bugs):
Code:
-- Script by Ates, [onStepIn_RemoveStone]
-- fixed by Gelio
function onStepIn(cid, item, frompos, item2, topos)
local pos = {X=1000, Y=1000, Z=7}  -- Pos
local stone = 1304  -- ID of stone
local tile = 426  -- ID of tile
local tile1 = 425 -- ID of tile (The one you stand on)
local stoneFromPos = getThingfromPos(pos)  -- It get item uid

if item.itemid == tile then
doRemoveItem(stoneFromPos[COLOR="Red"].uid[/COLOR], 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You removed the Stone.")
doTransformItem(item.uid, tile1)
elseif item.itemid == tile1 then
doCreateItem(stone, 1, pos)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You added the Stone.")
doTransformItem(item.uid, tile)
[COLOR="Red"]end
end[/COLOR]
And that's it :D You write better scripts than on start. Nice script.

Yours,
Gelio
 
Won't work:
doRemoveItem(stoneFromPos, 1)

you need to add ".uid"

Edit: too late hueahaeu :D
 
Ok. Few bugs. Bye don't end ifs and functions. Transform bye to end. Good script (red - bugs):
Code:
-- Script by Ates, [onStepIn_RemoveStone]
-- fixed by Gelio
function onStepIn(cid, item, frompos, item2, topos)
local pos = {X=1000, Y=1000, Z=7}  -- Pos
local stone = 1304  -- ID of stone
local tile = 426  -- ID of tile
local tile1 = 425 -- ID of tile (The one you stand on)
local stoneFromPos = getThingfromPos(pos)  -- It get item uid

if item.itemid == tile then
doRemoveItem(stoneFromPos[COLOR="Red"].uid[/COLOR], 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You removed the Stone.")
doTransformItem(item.uid, tile1)
elseif item.itemid == tile1 then
doCreateItem(stone, 1, pos)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You added the Stone.")
doTransformItem(item.uid, tile)
[COLOR="Red"]end
end[/COLOR]
And that's it :D You write better scripts than on start. Nice script.

Yours,
Gelio



Thank you... , im very glad that you peoples helping me with scripting!
 
I wont work..
You forget to add stackpos
@thread = [action] and this script is onStepIn :eek: xD [Movements]plx

Heres a working script by me use a lever stone open.

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)

-- script by Zonet
stonePos = {x=100, y=100, z=7, stackpos=1}
local effect = math.random (1, 215)

if item.itemid == 1945 then
doRemoveItem(getThingfromPos(stonePos).uid, 1)
doSendAnimatedText(stonePos, "Open", effect)
elseif item.itemid == 1946 then
doCreateItem(1304, 1, stonePos)
doSendAnimatedText(stonePos, "Closed", effect)
end
return TRUE
end

;)
 
Last edited:
I wont work..
You forget to add stackpos
@thread = [action] and this script is onStepIn :eek: xD [Movements]plx

Heres a working script by me use a lever stone open.

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)

-- script by Zonet
stonePos = {x=100, y=100, z=7, stackpos=1}
local effect = math.random (1, 215)

if item.itemid == 1945 then
doRemoveItem(getThingfromPos(stonePos).uid, 1)
doSendAnimatedText(stonePos, "Open", effect)
elseif item.itemid == 1946 then
doCreateItem(1304, 1, stonePos)
doSendAnimatedText(stonePos, "Closed", effect)
end
return TRUE
end

;)

You forget, doTransformItem(item.uid, 1946) == this work for me
You forget, doTransformItem(item.id, 1946) == idk if id work :D
 
The main thing about scripting is that you actually understand (might just be a tiny bit, or all of it, doesn't really matter) what you are doing. You can't just toss in several lines, modify them a bit and hope for the better. I'm not trying to discourage you, or make you quit scripting. Obviously not, but what I am saying is that you should take your time, try to understand your script and even test it.

For example - the item id check is just unnecessary as you added an action id for it. Other then that you should also use the LUA_Functions document (atleast it exists in the forgotten server, can't speak for the other servers as I'm only using TFS myself).

So what I'm basically saying is that you should try to test your scripts, experiment with it and don't rely to much on others. Better to try several times by yourself and THEN ask incase you are stuck.

Anywho, keep it up.
 
Before your script don't work. I have edited, removed tiles ID, doTransformItem and onStepIn functions, and added switchs, onUse function, and magicseffects. You forget stackpos, (Zonet).

Cya ;* ;)
 
Back
Top