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

Remove Item

smstR

offline, bye
Joined
Nov 2, 2007
Messages
95
Reaction score
0
Hello,

i need a script, which removes X item if you walk through X teleporter.


Thanks for attention.
All the best,
smstR
 
The fail is here, as I see:
This script is onStepIn movement script, and you set it's action ID to the teleport, that's why it doesn't work.

Set the action ID to the tile beneath the teleport. (and teleport should have coords 0-0-0 in RME).
 
You mean that I need to ad the action ID to the title beneath the telport?, and the teleport should just have coords 0-0-0 without an action ID?
 
Edit: I did what you said and nothing happened /:, the titles now have the action ID, and the teleport coords are 0-0-0, without an action ID, but, is there a way when the player enters throught the teleport it automatically removes X item, and if the player don't have it, the teleport won't let him to enter throught it?

Edit 2.
I've tried using this movevent
citizen.lua
LUA:
function onStepIn(cid, item, position, fromPosition)
	if(item.actionid > 50020 and item.actionid < 50100) then
		local townId = (item.actionid - 50020)
		doPlayerSetTown(cid, townId)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
	end

	return true
end
	local cfg = {
		aid = 59906 -- action id of the teleport
	}
	if item.actionid == cfg.aid then
		if isPlayer(cid) then
			if not doPlayerRemoveItem(cid, 2148, 1) then
				doTeleportThing(cid, fromPosition, true)
			end
		end
	end

and got this error at console
Code:
[21:42:39.560] [Error - MoveEvents Interface]
[21:42:39.560] data/movements/scripts/citizen.lua
[21:42:39.560] Description:
[21:42:39.560] data/movements/scripts/citizen.lua:13: attempt to index global 'item' (a nil value)
[21:42:39.560] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/citizen.lua)

And of course, script did not work in-game /:

Thanks for all your help so far.
 
Last edited:
Okay, I changed just a few things in script, tested - works 100%.

Code:
local c = {
		tpt = {x=1508, y=1575, z=7}, -- position where tp tp player
		tpItem = 2491 -- here item id numer
	}
function onStepIn(cid, item, position, fromPosition)
	if(not isPlayer(cid)) then return false end
 
	if getPlayerItemCount(cid, c.tpItem) >= 1 then
		doPlayerRemoveItem(cid, c.tpItem, 1)
		doTeleportThing(cid, c.tpt, false)
		doSendMagicEffect(c.tpt, CONST_ME_TELEPORT)
	else
		addEvent(doTeleportThing, 1, cid, fromPosition)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to have a "..getItemNameById(c.tpItem).." in order to pass.")
	end
	return true
end

Carefully follow these steps again and there should be no problems:
1. Make sure script is correctly loaded and that you use the correct ID in map editor (same as in movements.xml)
2. Open RME, disable autoborder (A)
2. Make a clean ground tile, with no borders or anything on it, and give it this action ID from movements.xml
3. Put a teleport on that tile, and teleport coords should be 0-0-0.

Also don't forget to change back to your own ID and positions in script. (using invalid coordinates to teleport player to may cause script to malfunction also)

I hope there won't be problems.
 
Well, actually I did everything what you said, and it did not work, when I step into the teleport, nothing happens, also there are no console errors /:

Edit.

Title below the teleport,
17:55 You see a stone tile.
ItemID: [415], ActionID: [59906].

The teleport have 0-0-0 coords, and the action ID of the title is the same as moveevents.xml
 
Last edited:
I really don't know what's the problem, it worked for me. In movements .xml it should look like this to you:
Code:
<movevent type="StepIn" actionid="59906" event="script" value="[COLOR="#FF0000"]scriptname.lua[/COLOR]"/>

You can test if the script is even being loaded onStepIn by writing this line inside of the script:
Code:
print("Testing if this part of script was loaded.")
If you put it inside the function and when you step in, this text gets printed in your console, the script gets executed but something's wrong inside it. I never encountered a behavior of script like this before, especially since it was tested [by that other guy too]. :|
 
Back
Top